1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4
<title>rstory's NET-SNMP Developers Frequently Asked Questions Page</title>
7
<body bgcolor="#ffffff" background="ucd-snmp-bg3.gif">
9
<h1>rstory's NET-SNMP Developers Frequently Asked Questions Page</h1>
14
<a href="FAQ.html">[Official FAQ]</a> |
15
<a href="#tokens">[Debug tokens]</a> |
16
<a href="#agentx">[AgentX]</a> |
17
<a href="#install">[Install]</a> |
18
<a href="#disable">[Disable]</a> |
19
<a href="#errors">[Errors]</a> |
20
<a href="#bits">[Bits]</a> |
21
<a href="#embedded">[embedded perl]</a> |
22
<a href="#smux">[SMUX]</a> |
23
<a href="#entid">[Enterprise OID]</a> |
24
<a href="#autodeps">[Automatic dependencies]</a> |
25
<a href="#cross">[Cross compiling]</a> |
26
<a href="#static">[Static linking]</a> |
27
<a href="#readfds">[readfds]</a> |
28
<a href="#sharing">[Sharing data]</a> |
29
<a href="man1-mib2c.1.html">[mib2c.array-user.conf]</a> |
30
<a href="#steps">[Baby Steps flow]</a> |
34
This is just a quick page to answer some common questions that aren't covered
35
in the <a href="/FAQ.html">official FAQ</a>.
37
<a name="agentx"></a> <h2>AgentX</h2>
38
<pre> To have the sub-agent communicate on a different socket, or with
39
different permissions, add these line to your snmpd.conf
42
agentxsocket /tmp/agentx
44
# perms socket directory userid groupid
45
agentxperms 777 777 rstory rstory
48
and add this line to your subagent:
50
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "/tmp/agentx");
52
*before* you call init_agent().
56
<a name="install"></a><h2>install</h2>
57
<pre> INSTALL_PREFIX goes before everything.. so, with the defaults, just
58
setting INSTALL_PREFIX=/tmp would result in /tmp/usr/local..
59
so INSTALL_PREFIX=/tmp prefix=/usr exec_prefix=/usr would go into /tmp/usr
62
<a name="disable"></a><h2>disable</h2>
63
<pre> If you are using net-snmp Version >= 5.1, then the following configure
64
options may be useful to you:
66
--disable-agent Do not build the agent (snmpd).
67
--disable-applications Do not build the apps (snmpget, ...).
68
--disable-manuals Do not install the manuals.
69
--disable-scripts Do not install the scripts (mib2c, ...).
70
--disable-mibs Do not install the mib files.
71
--disable-mib-loading Do not include code that parses and
72
manipulates the mib files.
75
<a name="errors"></a><h2>errors</h2>
80
noSuchName(2), -- for proxy compatibility
81
badValue(3), -- for proxy compatibility
82
readOnly(4), -- for proxy compatibility
90
inconsistentValue(12),
91
resourceUnavailable(13),
94
authorizationError(16),
99
<a name="bits"></a><h2>bits</h2>
100
<pre> SNMPv1 use BIT STRINGs (RFC 1212, 5.1.1):
102
(3) An object with BIT STRING syntax containing no more than
103
32 bits becomes an INTEGER defined as a sum; otherwise if
104
more than 32 bits are present, the object becomes an
105
OCTET STRING, with the bits numbered from left-to-right,
106
in which the least significant bits of the last octet may
107
be "reserved for future use".
109
SNMPv2 and beyond uses BITS (RFC 3417, 8.1):
111
(3) When encoding an object whose syntax is described using the
112
BITS construct, the value is encoded as an OCTET STRING, in
113
which all the named bits in (the definition of) the bitstring,
114
commencing with the first bit and proceeding to the last bit,
115
are placed in bits 8 (high order bit) to 1 (low order bit) of
116
the first octet, followed by bits 8 to 1 of each subsequent
117
octet in turn, followed by as many bits as are needed of the
118
final subsequent octet, commencing with bit 8. Remaining bits,
119
if any, of the final octet are set to zero on generation and
123
<a name="embedded"></a> <h2>embedded perl</h2>
124
<pre> Add the following line to snmpd.conf:
126
perl do "/path/to/perl_module.pl"
131
1) Try staring up snmpd, like so: 'snmpd -Dperl'. Check your log files for:
133
perl: initializing perl (/tmp/snmp_perl.pl)
134
starting perl_module.pl
135
perl_module.pl loaded ok
136
registering at netSnmp.999
140
perl: initializing perl (/usr/local/share/snmp/snmp_perl.pl)
141
Can't open perl script "/usr/local/share/snmp/snmp_perl.pl": No such file or directory
142
embedded perl support failed to initalize
144
Then you need to locate snmp_perl.pl, and put it in the correct path, OR put
145
the path in your snmpd.conf:
147
perlInitFile /tmp/snmp_perl.pl
150
2) Once it's loaded ok, try a walk:
152
snmpwalk -v2c -c public localhost netSnmp.999
154
You should see something like this in your logs:
156
refs: NetSNMP::agent::netsnmp_mib_handler, NetSNMP::agent::reginfo, NetSNMP::agent::netsnmp_agent_request_info, NetSNMP::agent::netsnmp_request_infoPtr
157
processing a request of type 161
158
processing request of nsTransactionEntry.3
159
.1.3.6.1.4.1.8072.999.1.2.1 -> hello world
162
3) If not, maybe check /path/to/perl_module.pl and make sure it is executable.
168
<a name="smux"></a> <h2>SMUX</h2>
169
<pre> To turn off SMUX when you don't have the options of recompiling from source
170
to disable SMUX support, you have to give it an invalid IP address to bind
171
to. This may be OS specific. On Linux, if I put this in my snmpd.conf:
175
I get an error at startup, and lsof or netstat show that snmpd is no longer
176
listenting on port 199. If you get and error message about the smuxsocket
177
token not being recongnized, then you're out of luck. You'll have to recompile
178
from source (or just use local firewall rules to block connections to port
182
<a name="entid"></a> <h2>Enterprise OID</h2>
183
<pre> From: Dave Shield, RObert Story
185
Recent Versions (5.x)
186
---------------------
187
If you want to *just* change the sysObjectID numbering,
188
(and leave the notifications using the Net-SNMP enterprise OID)
189
then use --with-enterprise-sysoid
190
Or you could just use the snmpd.conf directive 'sysobjectid'
191
to set this at run time.
194
If you want to *just* change enterprise-specific notification OID
195
(and leave the sysObjectID using the Net-SNMP values)
196
then use --with-enterprise-notification-oid
199
If you want to change *both* of these,
200
then use --with-enterprise-oid
202
Older Versions (4.2.x)
203
----------------------
204
In older version, you have to manuall update the version_id in
205
agent/agent_trap.c:80
207
oid version_id[] = { EXTENSIBLEMIB, AGENTID, OSTYPE };
211
<a name="autodeps"></a> <h2>Automatic dependencies</h2>
212
<pre> For auto-dependencies, add the following to your Makefile:
218
@echo "Generating makefile $@ ..."
219
@set -e; $(CC) -M $(COPTS) $(CFLAGS) $(CPPFLAGS) $< \
220
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
221
[ -s $@ ] || $(RM) $(RMFLAGS) $@
223
include $(SOURCES:.c=.d)
227
<a name="cross"></a> <h2>Cross compiling</h2>
228
<pre> From the net-snmp INSTALL file:
230
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
232
Specifying the System Type
233
==========================
235
There may be some features `configure' can not figure out
236
automatically, but needs to determine by the type of host the package
237
will run on. Usually `configure' can figure that out, but if it prints
238
a message saying it can not guess the host type, give it the
239
`--host=TYPE' option. TYPE can either be a short name for the system
240
type, such as `sun4', or a canonical name with three fields:
243
See the file `config.sub' for the possible values of each field. If
244
`config.sub' isn't included in this package, then this package doesn't
245
need to know the host type.
247
If you are building compiler tools for cross-compiling, you can also
248
use the `--target=TYPE' option to select the type of system they will
249
produce code for and the `--build=TYPE' option to select the type of
250
system on which you are compiling the package.
252
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
254
The most important configure options are:
256
--with-cc=[cross-compiler]
257
--with-ld=[cross-linker]
258
--target=[target-environment]
259
--with-endianness=[big|little]
261
Other potentially useful options:
271
Two simple examples of cross-compiling:
273
./configure --target=ppc-linux --with-cc=ppc_405-gcc --with-endianness=big
275
./configure --target=powerpc-snmc-linux-gnu --build=i386-redhat-linux \
276
--with-endianness=big
278
A more complex example involves setting environment variables for all
279
the flags for the tools needed for the cross compile:
281
export TOOLPATH=/opt/hardhat/devkit/ppc/405
282
export PATH=$TOOLPATH/bin:$PATH
283
export CFLAGS=' -g -fPIC -msoft-float -D_SOFT_FLOAT -Dlinux -mcpu=403'
284
export CPPFLAGS='-I$TOOLPATH/include -I$TOOLPATH/target/usr/include'
285
export ASFLAGS='-g -gstabs'
286
export LDFLAGS='-Wl,-soname,-Bdynamic -lc'
289
./configure --build=i686-pc-linux-gnu --host=powerpc \
290
--target=powerpc-hardhat-linux-gnu --with-endianness=big
294
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
296
The mibgroup section is the most OS specific part of the agent. It's likely
297
that you will have to remove some of them. You just need to figure out which
300
For example, agent/mibgroup/mibII/tcpTable.c is a common module that doesn't
301
work on new platforms. So if it isn't working, omit it during configure, like
304
./configure --with-out-mib-modules=mibII/tcpTable
307
Alternatively, you could work the other way. Start with a minimal
310
./configure --enable-mini-agent
312
and then start adding MIB modules one-by-one:
314
./configure --enable-mini-agent
315
--with-mib-modules=mibII/system_mib,mibII/sysORTable
320
<a name="static"></a> <h2>Static linking</h2>
321
<pre> mXaureliu: I want to compile the 5.1 snmptrapd binary with statically linked libraries.. Can anyone help me with this? Is it just a simple configure switch
322
rstory: mXaureliu: you want static snmp libraries, or totally static (system libraries too)?
323
mXaureliu: totally static.. everything in one executable
324
mXaureliu: actually, how do i do both ways?
325
rstory: for snmp libs, try 'configure --enable-shared=no'.. that won't build the shared libraries
326
rstory: (though if you have previous versions of net-snmp libraries installed, the linker might pick those up and try and use them)
327
rstory: for totally static, you'll have to tweak the Makefile
328
rstory: add -Bstatic to LDFLAGS
330
[note: actually, for totally static, 'configure --with-ldflags=-Bstatic']
333
<a name="readfds"></a> <h2>readfds</h2>
334
<pre> > can you please tell me the meaning of the third argument. obviously the
335
> first parameter to register_readfd is a file descriptor and second is the
339
The third parameter is arbitrary data that you can specify when you
340
register the file descriptor, and will then be passed to the callback
341
function when it's invoked.
344
So if you were listening on two separate sockets, for very similar
345
types of data, then you could use the same callback for both and
346
use this third parameter to distinguish between them:
349
fd1 = open( "/proc/tweedledum" );
350
fd2 = open( "/proc/tweedledee" );
352
register_readfd( fd1, who_broke_the_rattle(), "tweedledee" );
353
register_readfd( fd2, who_broke_the_rattle(), "tweedledum" );
357
who_broke_the_rattle( int fd, void *data )
359
char *he_did = (char *)data;
361
printf("%s broke the rattle!\n", he_did );
366
<a name="sharing"></a> <h2>sharing data</h2>
367
<pre> If two modules are compiled into the same agent/subagent, then just use a
368
normal C global var. No need to involve net-snmp in the process.
370
if they are different sub-agents, you are better off using tradition IPC
371
mechanisms. there is no net-snmp api for sharing data between subagents.
373
That said, *IF* you only need the data during processing of GET requests, or
374
when you aren't processing a request at all, you send a snmp request to the
375
master, which will query the other subagent. If you are processing a GET
376
request and are compiled into the master, you will have to delegate the
379
It's a little inefficient, compared to direct communication w/the other
380
subagent and it *will not* work during set processing.
383
<a name="tokens"></a> <h2>Debug Tokens</h2>
384
<pre> Some of the more common ones are:
386
Agent: agent, agentx, dlmod, handler, helper, snmpd, trap, table
387
MIBs: init_mib, mib_init, parse-file, parse-mibs
390
Add them to your snmp.conf like so:
392
# optionally turn on time stamps
395
debugTokens agentx/config
397
If you put them in a different conf file, like snmpd.conf or myapp.conf,
398
prefix each with '[snmp]', like so:
403
This list was generated by running the following command in the main CVS branch:
405
find . -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \" | cut -f 2 -d\" | sort -u
415
agentx/config/retries
416
agentx/config/timeout
426
check_getnext_results
432
container_iterator:results
435
container:null:find_next
436
container:null:for_each
438
container:null:get_null
439
container:null:get_null_factory
440
container:null:get_null_noalloc
441
container:null:insert
442
container:null:remove
446
deinit_usm_post_config
465
header_complex_add_data
467
header_complex_extract_entry
468
header_complex_generate_oid
469
header_complex_generate_varoid
470
header_complex_parse_oid
486
helper:watcher:spinlock
487
helper:watcher:timestamp
499
host/hr_swrun::GetNextHR_SWRun
502
initialize_table_ipCidrRouteTable
503
initialize_table_mteEventNotificationTable
504
initialize_table_mteEventTable
505
initialize_table_netSnmpHostsTable
506
initialize_table_nlmLogTable
507
initialize_table_nlmLogVariableTable
508
initialize_table_nsModuleTable
509
initialize_table_nsTransactionTable
516
lcd_get_enginetime_ex
526
mibII/mta_sendmail.c:mta_sendmail_parse_config
527
mibII/mta_sendmail.c:open_sendmailst
528
mibII/mta_sendmail.c:read_sendmailcf
539
mteEventTable:send_events
541
mteTriggerBooleanTable
543
mteTriggerExistenceTable
547
mteTriggerTest:send_mte_trap
548
mteTriggerThresholdTable
550
netsnmp_agent_check_packet
551
netsnmp_deregister_agent_nsap
552
netsnmp_ds_handle_config
553
netsnmp_ds_set_boolean
555
netsnmp_ds_set_string
557
netsnmp_ds_toggle_boolean
558
netsnmp_instance_counter32_handler
559
netsnmp_instance_int_handler
560
netsnmp_instance_long_handler
561
netsnmp_instance_ulong_handler
563
netsnmp_register_agent_nsap
564
netsnmp_register_mib_table_row
568
netsnmp_table_data_set
573
netsnmp_udp6_getSecName
574
netsnmp_udp6_parse_security
575
netsnmp_udp_getSecName
576
netsnmp_udp_parse_security
578
netsnmp_unix_getSecName
579
netsnmp_unix_parse_security
580
netsnmp_unix_transport
600
read_config_copy_word
604
read_config_read_data
605
read_config_read_memory
606
read_config_read_objid
607
read_config_read_octet_string
608
read_config_store_data_prefix
609
read_config:traphandle
640
snmp_clean_persistent
645
snmpd_register_app_config_handler
648
snmpNotifyFilterProfileTable
649
snmpNotifyFilterTable
654
snmp_pdu_realloc_rbuild
663
snmpTargetParamsEntry
691
ucd-snmp/pass_persist
694
ucd-snmp/vmstat_aix4.c:update_stats
695
ucd-snmp/vmstat_dynix.c:update_stats
696
ucd-snmp/vmstat_hpux.c:update_stats
697
ucd-snmp/vmstat_solaris2.c:update_stats
714
<a name="steps"></a> <h2>Baby Steps Flow</h2>
716
* Baby Steps Flow diagram (rev 2003.09.29.1330)
718
* Legend: (test) [optional] <required>
721
* ======== ============================================
724
* (row exists?) N ->(row_creation) N >-->+
726
* |<------------------+ |
728
* RESERVE1 <object_syntax_checks> |
730
* (err?) Y >------------------------>+
733
* +++ (row existed?) N --->[row_creation] |
735
* |<--------------N (err?) |
738
* | [row_creation_cleanup]--->+
740
* RESERVER2 [undo_setup] |
742
* (err?) Y --->-------->--------->+ |
744
* ACTION <set_values> | |
746
* (err?) Y >---------+ \|/ |
748
* +++ [consistency_checks] | | |
750
* UNDO (err?) Y >-------[undo]-------->+ |
752
* [reversible_commit] | |
754
* (err?) Y >--[reverse_commit] | |
756
* COMMIT <final_commit> | | |
758
* (err?) Y >--[log msg] | |
761
* | <-----------<+---<-----------+ |
763
* FREE [undo_cleanup] |
765
* |<--------------<-----------------+
775
<!-- Created: Thu Jul 24 10:08:26 MET DST 1997 -->
777
Last modified: Wed Mar 12 13:49:32 PST 2003
779
</td><td align=right>
781
<A href="http://sourceforge.net">
782
<IMG src="http://sourceforge.net/sflogo.php?group_id=12694&type=1" width="88" height="31" border="0" alt="SourceForge Logo"></A>