1SNMP(3)               User Contributed Perl Documentation              SNMP(3)
2
3
4

NAME

6       SNMP - The Perl5 'SNMP' Extension Module for the Net-SNMP SNMP package.
7

SYNOPSIS

9        use SNMP;
10        ...
11        $sess = new SNMP::Session(DestHost => localhost, Community => public);
12        $val = $sess->get('sysDescr.0');
13        ...
14        $vars = new SNMP::VarList([sysDescr,0], [sysContact,0], [sysLocation,0]);
15        @vals = $sess->get($vars);
16        ...
17        $vb = new SNMP::Varbind();
18        do {
19           $val = $sess->getnext($vb);
20           print "@{$vb}\n";
21        } until ($sess->{ErrorNum});
22        ...
23        $SNMP::save_descriptions = 1;
24        SNMP::initMib(); # assuming mib is not already loaded
25        print "$SNMP::MIB{sysDescr}{description}\n";
26

DESCRIPTION

28       Note: The perl SNMP 5.0 module which comes with net-snmp 5.0 and higher
29       is different than previous versions in a number of ways.  Most impor‐
30       tantly, it behaves like a proper net-snmp application and calls
31       init_snmp properly, which means it will read configuration files and
32       use those defaults where appropriate automatically parse MIB files,
33       etc.  This will likely affect your perl applications if you have, for
34       instance, default values set up in your snmp.conf file (as the perl
35       module will now make use of those defaults).  The docmuentation, how‐
36       ever, has sadly not been updated yet (aside from this note), nor is the
37       read_config default usage implementation fully complete.
38
39       The basic operations of the SNMP protocol are provided by this module
40       through an object oriented interface for modularity and ease of use.
41       The primary class is SNMP::Session which encapsulates the persistent
42       aspects of a connection between the management application and the man‐
43       aged agent. Internally the class is implemented as a blessed hash ref‐
44       erence. This class supplies 'get', 'getnext', 'set', 'fget', and 'fget‐
45       next' method calls. The methods take a variety of input argument for‐
46       mats and support both syncronous and asyncronous operation through a
47       polymorphic API (i.e., method behaviour varies dependent on args passed
48       - see below).
49

SNMP::Session

51       $sess = new SNMP::Session(DestHost => 'host', ...)
52
53       The following arguments may be passed to new as a hash.
54
55       DestHost
56           default 'localhost', hostname or ip addr of SNMP agent
57
58       Community
59           default 'public', SNMP community string (used for both R/W)
60
61       Version
62           default taken from library configuration - probably 3 [1, 2 (same
63           as 2c), 2c, 3]
64
65       RemotePort
66           default '161', allow remote UDP port to be overriden
67
68       Timeout
69           default '1000000', micro-seconds before retry
70
71       Retries
72           default '5', retries before failure
73
74       RetryNoSuch
75           default '0', if enabled NOSUCH errors in 'get' pdus will be
76           repaired, removing the varbind in error, and resent - undef will be
77           returned for all NOSUCH varbinds, when set to '0' this feature is
78           disabled and the entire get request will fail on any NOSUCH error
79           (applies to v1 only)
80
81       SecName
82           default 'initial', security name (v3)
83
84       SecLevel
85           default 'noAuthNoPriv', security level [noAuthNoPriv, authNoPriv,
86           authPriv] (v3)
87
88       SecEngineId
89           default <none>, security engineID, will be probed if not supplied
90           (v3)
91
92       ContextEngineId
93           default <SecEngineId>, context engineID, will be probed if not sup‐
94           plied (v3)
95
96       Context
97           default '', context name (v3)
98
99       AuthProto
100           default 'MD5', authentication protocol [MD5, SHA] (v3)
101
102       AuthPass
103           default <none>, authentication passphrase
104
105       PrivProto
106           default 'DES', privacy protocol [DES, AES] (v3)
107
108       PrivPass
109           default <none>, privacy passphrase (v3)
110
111       authMasterKey
112       privMasterKey
113       authLocalizedKey
114       privLocalizedKey
115           Directly specified SNMPv3 USM user keys (used if you want to spec‐
116           ify the keys instead of deriving them from a password as above).
117
118       VarFormats
119           default 'undef', used by 'fget[next]', holds an hash reference of
120           output value formatters, (e.g., {<obj> => <sub-ref>, ... }, <obj>
121           must match the <obj> and format used in the get operation. A spe‐
122           cial <obj>, '*', may be used to apply all <obj>s, the supplied sub
123           is called to translate the value to a new format. The sub is called
124           passing the Varbind as the arg
125
126       TypeFormats
127           default 'undef', used by 'fget[next]', holds an hash reference of
128           output value formatters, (e.g., {<type> => <sub-ref>, ... }, the
129           supplied sub is called to translate the value to a new format,
130           unless a VarFormat mathces first (e.g., $sess->{TypeFormats}{INTE‐
131           GER} = \&mapEnum(); although this can be done more efficiently by
132           enabling $SNMP::use_enums or session creation param 'UseEnums')
133
134       UseLongNames
135           defaults to the value of SNMP::use_long_names at time of session
136           creation. set to non-zero to have <tags> for 'getnext' methods gen‐
137           erated preferring longer Mib name convention (e.g., system.sysDescr
138           vs just sysDescr)
139
140       UseSprintValue
141           defaults to the value of SNMP::use_sprint_value at time of session
142           creation. set to non-zero to have return values for 'get' and 'get‐
143           next' methods formatted with the libraries snprint_value function.
144           This will result in certain data types being returned in non-canon‐
145           ical format Note: values returned with this option set may not be
146           appropriate for 'set' operations (see discussion of value formats
147           in <vars> description section)
148
149       UseEnums
150           defaults to the value of SNMP::use_enums at time of session cre‐
151           ation. set to non-zero to have integer return values converted to
152           enumeration identifiers if possible, these values will also be
153           acceptable when supplied to 'set' operations
154
155       UseNumeric
156           defaults to the value of SNMP::use_numeric at time of session cre‐
157           ation. set to non-zero to have <tags> for get methods returned as
158           numeric OID's rather than descriptions.  UseLongNames will be set
159           so that the full OID is returned to the caller.
160
161       BestGuess
162           defaults to the value of SNMP::best_guess at time of session cre‐
163           ation. this setting controls how <tags> are parsed.  setting to 0
164           causes a regular lookup.  setting to 1 causes a regular expression
165           match (defined as -Ib in snmpcmd) and setting to 2 causes a random
166           access lookup (defined as -IR in snmpcmd).
167
168       NonIncreasing
169           defaults to the value of SNMP::non_increasing at time of session
170           creation. this setting controls if a non-increasing OID during
171           bulkwalk will causes an error. setting to 0 causes the default be‐
172           haviour (which may, in very badly performing agents, result in a
173           never-ending loop).  setting to 1 causes an error (OID not increas‐
174           ing) when this error occur.
175
176       ErrorStr
177           read-only, holds the error message assoc. w/ last request
178
179       ErrorNum
180           read-only, holds the snmp_err or staus of last request
181
182       ErrorInd
183           read-only, holds the snmp_err_index when appropriate
184
185       Private variables:
186
187       DestAddr
188           internal field used to hold the translated DestHost field
189
190       SessPtr
191           internal field used to cache a created session structure
192
193       SNMP::Session methods
194
195       $sess->update(<fields>)
196           Updates the SNMP::Session object with the values fields passed in
197           as a hash list (similar to new(<fields>)) (WARNING! not fully
198           implemented)
199
200       $sess->get(<vars> [,<callback>])
201           do SNMP GET, multiple <vars> formats accepted.  for syncronous
202           operation <vars> will be updated with value(s) and type(s) and will
203           also return retrieved value(s). If <callback> supplied method will
204           operate asyncronously
205
206       $sess->fget(<vars> [,<callback>])
207           do SNMP GET like 'get' and format the values according the handlers
208           specified in $sess->{VarFormats} and $sess->{TypeFormats}
209
210       $sess->getnext(<vars> [,<callback>])
211           do SNMP GETNEXT, multiple <vars> formats accepted, returns
212           retrieved value(s), <vars> passed as arguments are updated to indi‐
213           cate next lexicographical <obj>,<iid>,<val>, and <type>
214
215           Note: simple string <vars>,(e.g., 'sysDescr.0') form is not
216           updated. If <callback> supplied method will operate asyncronously
217
218       $sess->fgetnext(<vars> [,<callback>])
219           do SNMP GETNEXT like getnext and format the values according the
220           handlers specified in $sess->{VarFormats} and $sess->{TypeFormats}
221
222       $sess->set(<vars> [,<callback>])
223           do SNMP SET, multiple <vars> formats accepted.  the value field in
224           all <vars> formats must be in a canonical format (i.e., well known
225           format) to ensure unambiguous translation to SNMP MIB data value
226           (see discussion of canonical value format <vars> description sec‐
227           tion), returns snmp_errno. If <callback> supplied method will oper‐
228           ate asyncronously
229
230       $sess->getbulk(<non-repeaters>, <max-repeaters>, <vars>)
231           do an SNMP GETBULK, from the list of Varbinds, the single next lex‐
232           ico instance is fetched for the first n Varbinds as defined by
233           <non-repeaters>. For remaining Varbinds, the m lexico instances are
234           retrieved each of the remaining Varbinds, where m is
235           <max-repeaters>.
236
237       $sess->bulkwalk(<non-repeaters>, <max-repeaters>, <vars> [,<callback>])
238           Do a "bulkwalk" of the list of Varbinds.  This is done by sending a
239           GETBULK request (see getbulk() above) for the Varbinds.  For each
240           requested variable, the response is examined to see if the next
241           lexico instance has left the requested sub-tree.  Any further
242           instances returned for this variable are ignored, and the walk for
243           that sub-tree is considered complete.
244
245           If any sub-trees were not completed when the end of the responses
246           is reached, another request is composed, consisting of the remain‐
247           ing variables.  This process is repeated until all sub-trees have
248           been completed, or too many packets have been exchanged (to avoid
249           loops).
250
251           The bulkwalk() method returns an array containing an array of
252           Varbinds, one for each requested variable, in the order of the
253           variable requests.  Upon error, bulkwalk() returns undef and sets
254           $sess->ErrorStr and $sess->ErrorNum.  If a callback is supplied,
255           bulkwalk() returns the SNMP request id, and returns immediately.
256           The callback will be called with the supplied argument list and the
257           returned variables list.
258
259           Note: Because the client must "discover" that the tree is complete
260           by comparing the returned variables with those that were requested,
261           there is a potential "gotcha" when using the max-repeaters value.
262           Consider the following code to print a list of interfaces and byte
263           counts:
264
265               $numInts = $sess->get('ifNumber.0');
266               ($desc, $in, $out) = $sess->bulkwalk(0, $numInts,
267                             [['ifDescr'], ['ifInOctets'], ['ifOutOctets']]);
268
269               for $i (0..($numInts - 1)) {
270                   printf "Interface %4s: %s inOctets, %s outOctets\n",
271                             $$desc[$i]->val, $$in[$i]->val, $$out[$i]->val;
272               }
273
274           This code will produce *two* requests to the agent -- the first to
275           get the interface values, and the second to discover that all the
276           information was in the first packet.  To get around this, use
277           '$numInts + 1' for the max_repeaters value.  This asks the agent to
278           include one additional (unrelated) variable that signals the end of
279           the sub-tree, allowing bulkwalk() to determine that the request is
280           complete.
281
282       $results = $sess->gettable(<TABLE OID>, <OPTIONgt)
283           This will retrieve an entire table of data and return a hash refer‐
284           ence to that data.  The returned hash reference will have indexes
285           of the OID suffixes for the index data as the key.  The value for
286           each entry will be another hash containing the data for a given
287           row.  The keys to that hash will be the column names, and the val‐
288           ues will be the data.
289
290           Example:
291
292             #!/usr/bin/perl
293
294             use SNMP;
295             use Data::Dumper;
296
297             my $s = new SNMP::Session(DestHost => 'localhost');
298
299             print Dumper($s->gettable('ifTable'));
300
301           On my machine produces:
302
303             $VAR1 = {
304                       '6' => {
305                                'ifMtu' => '1500',
306                                'ifPhysAddress' => 'PV',
307                                # ...
308                                'ifInUnknownProtos' => '0'
309                              },
310                       '4' => {
311                                'ifMtu' => '1480',
312                                'ifPhysAddress' => '',
313                                # ...
314                                'ifInUnknownProtos' => '0'
315                              },
316                       # ...
317                      };
318
319           By default, it will try to do as optimized retrieval as possible.
320           It'll request multiple columns at once, and use GETBULK if possi‐
321           ble.  A few options may be specified by passing in an OPTIONS hash
322           containing various parameters:
323
324           noindexes => 1
325               Instructs the code not to parse the indexes and place the
326               results in the second hash.  If you don't need the index data,
327               this will be faster.
328
329           columns => [ colname1, ... ]
330               This specifies which columns to collect.  By default, it will
331               try to collect all the columns defined in the MIB table.
332
333           repeat => COUNT
334               Specifies a GETBULK repeat COUNT.  IE, it will request this
335               many varbinds back per column when using the GETBULK operation.
336               Shortening this will mean smaller packets which may help going
337               through some systems.  By default, this value is calculated and
338               attepmts to guess at what will fit all the results into 1000
339               bytes.  This calculation is fairly safe, hopefully, but you can
340               either raise or lower the number using this option if desired.
341               In lossy networks, you want to make sure that the packets don't
342               get fragmented and lowering this value is one way to help that.
343
344           nogetbulk => 1
345               Force the use of GETNEXT rather than GETBULK.  (always true for
346               SNMPv1, as it doesn't have GETBULK anyway).  Some agents are
347               great implementers of GETBULK and this allows you to force the
348               use of GETNEXT oprations instead.
349
350           callback => \&subroutine
351           callback => [\&subroutine, optarg1, optarg2, ...]
352               If a callback is specified, gettable will return quickly with‐
353               out returning results.  When the results are finally retrieved
354               the callback subroutine will be called (see the other sections
355               defining callback behaviour and how to make use of SNMP::Main‐
356               Loop which is required fro this to work).  An additional argu‐
357               ment of the normal hash result will be added to the callback
358               subroutine arguments.
359
360               Note 1: internally, the gettable function uses it's own call‐
361               backs which are passed to getnext/getbulk as appropriate.
362
363               Note 2: callback support is only available in the SNMP module
364               version 5.04 and above.  To test for this in code intending to
365               support both versions prior to 5.04 and and 5.04 and up, the
366               following should work:
367
368                 if ($response = $sess->gettable('ifTable', callback => \&my_sub)) {
369                     # got a response, gettable doesn't support callback
370                     my_sub($response);
371                     $no_mainloop = 1;
372                 }
373
374               Deciding on whether to use SNMP::MainLoop is left as an excer‐
375               size to the reader since it depends on whether your code uses
376               other callbacks as well.
377

SNMP::TrapSession

379       $sess = new SNMP::Session(DestHost => 'host', ...)
380
381       supports all applicable fields from SNMP::Session (see above)
382
383       SNMP::TrapSession methods
384
385       $sess->trap(enterprise, agent, generic, specific, uptime, <vars>)
386               $sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
387                           agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
388                           generic => specific,  # can be omitted if 'specific' supplied
389                           specific => 5,        # can be omitted if 'generic' supplied
390                           uptime => 1234,       # dflt to localhost uptime (0 on win32)
391                           [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
392                                                                        # always last
393
394       trap(oid, uptime, <vars>) - v2 format
395               $sess->trap(oid => 'snmpRisingAlarm',
396                           uptime => 1234,
397                           [[ifIndex, 1, 1],[sysLocation, 0, "here"]]); # optional vars
398                                                                        # always last
399

Acceptable variable formats:

401       <vars> may be one of the following forms:
402
403       SNMP::VarList
404           represents an array of MIB objects to get or set, implemented as a
405           blessed reference to an array of SNMP::Varbinds, (e.g.,
406           [<varbind1>, <varbind2>, ...])
407
408       SNMP::Varbind
409           represents a single MIB object to get or set, implemented as a
410           blessed reference to a 4 element array; [<obj>, <iid>, <val>,
411           <type>].
412
413           <obj>
414               one of the following forms:
415
416               1)  leaf identifier (e.g., 'sysDescr') assumed to be unique for
417                   practical purposes
418
419               2)  fully qualified identifier (e.g., '.iso.org.dod.inter‐
420                   net.mgmt.mib-2.system.sysDescr')
421
422               3)  fully qualified, dotted-decimal, numeric OID (e.g.,
423                   '.1.3.6.1.2.1.1.1')
424
425           <iid>
426               the dotted-decimal, instance identifier. for scalar MIB objects
427               use '0'
428
429           <val>
430               the SNMP data value retrieved from or being set to the agents
431               MIB. for (f)get(next) operations <val> may have a variety of
432               formats as determined by session and package settings. However
433               for set operations the <val> format must be canonical to ensure
434               unambiguous translation. The canonical forms are as follows:
435
436               OBJECTID
437                   dotted-decimal (e.g., .1.3.6.1.2.1.1.1)
438
439               OCTETSTR
440                   perl scalar containing octets
441
442               INTEGER
443                   decimal signed integer (or enum)
444
445               NETADDR
446                   dotted-decimal
447
448               IPADDR
449                   dotted-decimal
450
451               COUNTER
452                   decimal unsigned integer
453
454               COUNTER64
455                   decimal unsigned integer
456
457               GAUGE
458                   decimal unsigned integer
459
460               UINTEGER
461                   decimal unsigned integer
462
463               TICKS
464                   decimal unsigned integer
465
466               OPAQUE
467                   perl scalar containing octets
468
469               NULL
470                   perl scalar containing nothing
471
472           <type>
473               SNMP data type (see list above), this field is populated by
474               'get' and 'getnext' operations. In some cases the programmer
475               needs to populate this field when passing to a 'set' operation.
476               this field need not be supplied when the attribute indicated by
477               <tag> is already described by loaded Mib modules. for 'set's,
478               if a numeric OID is used and the object is not currently in the
479               loaded Mib, the <type> field must be supplied
480
481       simple string
482           light weight form of <var> used to 'set' or 'get' a single
483           attribute without constructing an SNMP::Varbind.  stored in a perl
484           scalar, has the form '<tag>.<iid>', (e.g., 'sysDescr.0'). for 'set'
485           operations the value is passed as a second arg. Note: This argument
486           form is not updated in get[next] operations as are the other forms.
487

Acceptable callback formats

489       <callback> may be one of the following forms:
490
491       without arguments
492           \&subname
493           sub { ... }
494       or with arguments
495           [ \&subname, $arg1, ... ]
496           [ sub { ... }, $arg1, ... ]
497           [ "method", $obj, $arg1, ... ]
498
499       callback will be called when response is received or timeout occurs.
500       the last argument passed to callback will be a SNMP::VarList reference.
501       In case of timeout the last argument will be undef.
502
503       &SNMP::MainLoop([<timeout>, [<callback>]])
504           to be used with async SNMP::Session calls. MainLoop must be called
505           after initial async calls so return packets from the agent will not
506           be processed.  If no args suplied this function enters an infinite
507           loop so program must be exited in a callback or externally
508           interupted. If <timeout(sic)
509
510       &SNMP::finish()
511           This function, when called from an SNMP::MainLoop() callback func‐
512           tion, will cause the current SNMP::MainLoop() to return after the
513           callback is completed.  finish() can be used to terminate an other‐
514           wise-infinite MainLoop.  A new MainLoop() instance can then be
515           started to handle further requests.
516

SNMP package variables and functions

518       $SNMP::VERSION
519           the current version specifier (e.g., 3.1.0)
520
521       $SNMP::auto_init_mib
522           default '1', set to 0 to disable automatic reading of the MIB upon
523           session creation. set to non-zero to call initMib at session cre‐
524           ation which will result in MIB loading according to Net-SNMP env.
525           variables (see man mib_api)
526
527       $SNMP::verbose
528           default '0', controls warning/info output of SNMP module, 0 => no
529           output, 1 => enables warning/info output from SNMP module itself
530           (is also controlled by SNMP::debugging - see below)
531
532       $SNMP::use_long_names
533           default '0', set to non-zero to enable the use of longer Mib iden‐
534           tifiers. see translateObj. will also influence the formatting of
535           <tag> in varbinds returned from 'getnext' operations. Can be set on
536           a per session basis (UseLongNames)
537
538       $SNMP::use_sprint_value
539           default '0', set to non-zero to enable formatting of response val‐
540           ues using the snmp libraries snprint_value function. can also be
541           set on a per session basis (see UseSprintValue) Note: returned val‐
542           ues may not be suitable for 'set' operations
543
544       $SNMP::use_enums
545           default '0',set non-zero to return values as enums and allow sets
546           using enums where appropriate. integer data will still be accepted
547           for set operations. can also be set on a per session basis (see
548           UseEnums)
549
550       $SNMP::use_numeric
551           default to '0',set to non-zero to have <tags> for 'get' methods
552           returned as numeric OID's rather than descriptions.  UseLongNames
553           will be set so that the entire OID will be returned.  Set on a per-
554           session basis (see UseNumeric).
555
556       $SNMP::best_guess
557           default '0'.  This setting controls how <tags> are parsed.  Setting
558           to 0 causes a regular lookup.  Setting to 1 causes a regular
559           expression match (defined as -Ib in snmpcmd) and setting to 2
560           causes a random access lookup (defined as -IR in snmpcmd).  Can
561           also be set on a per session basis (see BestGuess)
562
563       $SNMP::save_descriptions
564           default '0',set non-zero to have mib parser save attribute descrip‐
565           tions. must be set prior to mib initialization
566
567       $SNMP::debugging
568           default '0', controlls debugging output level within SNMP module
569           and libsnmp
570
571           1   enables 'SNMP::verbose' (see above)
572
573           2   level 1 plus snmp_set_do_debugging(1)
574
575           3   level 2 plus snmp_set_dump_packet(1)
576
577       $SNMP::dump_packet
578           default '0', set [non-]zero to independently set
579           snmp_set_dump_packet()
580

%SNMP::MIB

582       a tied hash to access parsed MIB information. After the MIB has been
583       loaded this hash allows access to to the parsed in MIB meta-data(the
584       structure of the MIB (i.e., schema)). The hash returns blessed refer‐
585       ences to SNMP::MIB::NODE objects which represent a single MIB
586       attribute. The nodes can be fetched with multiple 'key' formats - the
587       leaf name (e.g.,sysDescr) or fully/partially qualified name (e.g., sys‐
588       tem.sysDescr) or fully qualified numeric OID. The returned node object
589       supports the following fields:
590
591       objectID
592           dotted decimal fully qualified OID
593
594       label
595           leaf textual identifier (e.g., 'sysDescr')
596
597       subID
598           leaf numeric OID component of objectID (e.g., '1')
599
600       moduleID
601           textual identifier for module (e.g., 'RFC1213-MIB')
602
603       parent
604           parent node
605
606       children
607           array reference of children nodes
608
609       nextNode
610           next lexico node (BUG!does not return in lexico order)
611
612       type
613           returns application type (see getType for values)
614
615       access
616           returns ACCESS (ReadOnly, ReadWrite, WriteOnly, NoAccess, Notify,
617           Create)
618
619       status
620           returns STATUS (Mandatory, Optional, Obsolete, Deprecated)
621
622       syntax
623           returns 'textualConvention' if defined else 'type'
624
625       textualConvention
626           returns TEXTUAL-CONVENTION
627
628       TCDescription
629           returns the TEXTUAL-CONVENTION's DESCRIPTION field.
630
631       units
632           returns UNITS
633
634       hint
635           returns HINT
636
637       enums
638           returns hash ref {tag => num, ...}
639
640       ranges
641           returns array ref of hash ref [{low => num, high => num}, ...]
642
643       description
644           returns DESCRIPTION ($SNMP::save_descriptions must be set prior to
645           MIB initialization/parsing)
646
647       reference
648           returns the REFERENCE clause
649

MIB Functions

651       &SNMP::setMib(<file>)
652           allows dynamic parsing of the mib and explicit specification of mib
653           file independent of enviroment variables. called with no args acts
654           like initMib, loading MIBs indicated by environment variables (see
655           Net-SNMP mib_api docs). passing non-zero second arg forces previous
656           mib to be freed and replaced (Note: second arg not working since
657           freeing previous Mib is more involved than before).
658
659       &SNMP::initMib()
660           calls library init_mib function if Mib not already loaded - does
661           nothing if Mib already loaded. will parse directories and load mod‐
662           ules according to environment variables described in Net-SNMP docu‐
663           mentations.  (see man mib_api, MIBDIRS, MIBS, MIBFILE(S), etc.)
664
665       &SNMP::addMibDirs(<dir>,...)
666           calls library add_mibdir for each directory supplied. will cause
667           directory(s) to be added to internal list and made available for
668           searching in subsequent loadModules calls
669
670       &SNMP::addMibFiles(<file>,...)
671           calls library read_mib function. The file(s) supplied will be read
672           and all Mib module definitions contained therein will be added to
673           internal mib tree structure
674
675       &SNMP::loadModules(<mod>,...)
676           calls library read_module function. The module(s) supplied will be
677           searched for in the current mibdirs and and added to internal mib
678           tree structure. Passing special <mod>, 'ALL', will cause all known
679           modules to be loaded.
680
681       &SNMP::unloadModules(<mod>,...)
682           *Not Implemented*
683
684       &SNMP::translateObj(<var>[,arg,[arg]])
685           will convert a text obj tag to an OID and vice-versa.  Any iid suf‐
686           fix is retained numerically.  Default behaviour when converting a
687           numeric OID to text form is to return leaf identifier only
688           (e.g.,'sysDescr') but when $SNMP::use_long_names is non-zero or a
689           non-zero second arg is supplied it will return a longer textual
690           identifier.  An optional third argument of non-zero will cause the
691           module name to be prepended to the text name (e.g.
692           'SNMPv2-MIB::sysDescr').  When converting a text obj, the
693           $SNMP::best_guess option is used.  If no Mib is loaded when called
694           and $SNMP::auto_init_mib is enabled then the Mib will be loaded.
695           Will return 'undef' upon failure.
696
697       &SNMP::getType(<var>)
698           return SNMP data type for given textual identifier OBJECTID, OCTET‐
699           STR, INTEGER, NETADDR, IPADDR, COUNTER GAUGE, TIMETICKS, OPAQUE, or
700           undef
701
702       &SNMP::mapEnum(<var>)
703           converts integer value to enumertion tag defined in Mib or converts
704           tag to integer depending on input. the function will return the
705           corresponding integer value *or* tag for a given MIB attribute and
706           value. The function will sense which direction to perform the con‐
707           version. Various arg formats are supported
708
709           $val = SNMP::mapEnum($varbind);
710               where $varbind is SNMP::Varbind or equiv.  note: $varbind will
711               be updated
712
713           $val = SNMP::mapEnum('ipForwarding', 'forwarding');
714           $val = SNMP::mapEnum('ipForwarding', 1);
715

Exported SNMP utility functions

717       Note: utility functions do not support async operation yet.
718
719       &snmp_get()
720           takes args of SNMP::Session::new followed by those of SNMP::Ses‐
721           sion::get
722
723       &snmp_getnext()
724           takes args of SNMP::Session::new followed by those of SNMP::Ses‐
725           sion::getnext
726
727       &snmp_set()
728           takes args of SNMP::Session::new followed by those of SNMP::Ses‐
729           sion::set
730
731       &snmp_trap()
732           takes args of SNMP::TrapSession::new followed by those of
733           SNMP::TrapSession::trap
734

Trouble Shooting

736       If problems occur there are number areas to look at to narrow down the
737       possibilities.
738
739       The first step should be to test the Net-SNMP installation indepen‐
740       dently from the Perl5 SNMP interface.
741
742       Try running the apps from the Net-SNMP distribution.
743
744       Make sure your agent (snmpd) is running and properly configured with
745       read-write access for the community you are using.
746
747       Ensure that your MIBs are installed and enviroment variables are set
748       appropriately (see man mib_api)
749
750       Be sure to remove old net-snmp installations and ensure headers and
751       libraries from old CMU installations are not being used by mistake.
752
753       If the problem occurs during compilation/linking check that the snmp
754       library being linked is actually the Net-SNMP library (there have been
755       name conflicts with existing snmp libs).
756
757       Also check that the header files are correct and up to date.
758
759       Sometimes compiling the Net-SNMP library with 'position-indepen‐
760       dent-code' enabled is required (HPUX specifically).
761
762       If you cannot resolve the problem you can post to comp.lang.perl.mod‐
763       ules or net-snmp-users@net-snmp-users@lists.sourceforge.net
764
765       please give sufficient information to analyze the problem (OS type,
766       versions for OS/Perl/Net-SNMP/compiler, complete error output, etc.)
767

Acknowledgements

769       Many thanks to all those who supplied patches, suggestions and feed‐
770       back.
771
772        Joe Marzot (the original author)
773        Wes Hardaker and the net-snmp-coders
774        Dave Perkins
775        Marcel Wiget
776        David Blackburn
777        John Stofell
778        Gary Hayward
779        Claire Harrison
780        Achim Bohnet
781        Doug Kingston
782        Jacques Vidrine
783        Carl Jacobsen
784        Wayne Marquette
785        Scott Schumate
786        Michael Slifcak
787        Srivathsan Srinivasagopalan
788        Bill Fenner
789        Jef Peeraer
790        Daniel Hagerty
791        Karl "Rat" Schilke and Electric Lightwave, Inc.
792        Perl5 Porters
793        Alex Burger
794
795       Apologies to any/all who's patch/feature/request was not mentioned or
796       included - most likely it was lost when paying work intruded on my fun.
797       Please try again if you do not see a desired feature. This may actually
798       turn out to be a decent package with such excellent help and the fact
799       that I have more time to work on it than in the past.
800

AUTHOR

802       bugs, comments, questions to net-snmp-users@lists.sourceforge.net
803
805            Copyright (c) 1995-2000 G. S. Marzot. All rights reserved.
806            This program is free software; you can redistribute it and/or
807            modify it under the same terms as Perl itself.
808
809            Copyright (c) 2001-2002 Networks Associates Technology, Inc.  All
810            Rights Reserved.  This program is free software; you can
811            redistribute it and/or modify it under the same terms as Perl
812            itself.
813
814
815
816perl v5.8.8                       2006-08-15                           SNMP(3)
Impressum