1SNMP::Info(3) User Contributed Perl Documentation SNMP::Info(3)
2
3
4
6 SNMP::Info - OO Interface to Network devices and MIBs through SNMP
7
9 SNMP::Info - Version 3.82
10
12 SNMP::Info is maintained by team of Open Source authors headed by Eric
13 Miller, Bill Fenner, Max Baker, Jeroen van Ingen and Oliver Gorwits.
14
15 Please visit <https://github.com/netdisco/snmp-info/> for the most up-
16 to-date list of developers.
17
18 SNMP::Info was originally created at UCSC for the Netdisco project
19 <http://netdisco.org> by Max Baker.
20
22 There are now generic classes for most types of device and so the
23 authors recommend loading SNMP::Info with AutoSpecify, and then
24 reporting to the mail list any missing functionality (such as neighbor
25 discovery tables).
26
28 use SNMP::Info;
29
30 my $info = new SNMP::Info(
31 # Auto Discover more specific Device Class
32 AutoSpecify => 1,
33 Debug => 1,
34 # The rest is passed to SNMP::Session
35 DestHost => 'router',
36 Community => 'public',
37 Version => 2
38 ) or die "Can't connect to device.\n";
39
40 my $err = $info->error();
41 die "SNMP Community or Version probably wrong connecting to device. $err\n" if defined $err;
42
43 my $name = $info->name();
44 my $class = $info->class();
45 print "SNMP::Info is using this device class : $class\n";
46
47 # Find out the Duplex status for the ports
48 my $interfaces = $info->interfaces();
49 my $i_duplex = $info->i_duplex();
50
51 # Get CDP Neighbor info
52 my $c_if = $info->c_if();
53 my $c_ip = $info->c_ip();
54 my $c_port = $info->c_port();
55
56 # Print out data per port
57 foreach my $iid (keys %$interfaces){
58 my $duplex = $i_duplex->{$iid};
59 # Print out physical port name, not snmp iid
60 my $port = $interfaces->{$iid};
61
62 print "$port: ";
63 print "$duplex duplex" if defined $duplex;
64
65 # The CDP Table has table entries different than the interface tables.
66 # So we use c_if to get the map from cdp table to interface table.
67
68 my %c_map = reverse %$c_if;
69 my $c_key = $c_map{$iid};
70 unless (defined $c_key) {
71 print "\n\n";
72 next;
73 }
74 my $neighbor_ip = $c_ip->{$c_key};
75 my $neighbor_port = $c_port->{$c_key};
76
77 print " connected to $neighbor_ip / $neighbor_port\n" if defined $neighbor_ip;
78 print "\n";
79
80 }
81
83 Please direct all support, help, and bug requests to the snmp-info-
84 users Mailing List at
85 <http://lists.sourceforge.net/lists/listinfo/snmp-info-users>.
86
88 SNMP::Info gives an object oriented interface to information obtained
89 through SNMP.
90
91 This module is geared towards network devices. Subclasses exist for a
92 number of network devices and common MIBs.
93
94 The idea behind this module is to give a common interface to data from
95 network devices, leaving the device-specific hacks behind the scenes in
96 subclasses.
97
98 In the SYNOPSIS example we fetch the name of all the ports on the
99 device and the duplex setting for that port with two methods --
100 interfaces() and i_duplex().
101
102 The information may be coming from any number of MIB files and is very
103 vendor specific. SNMP::Info provides you a common method for all
104 supported devices.
105
106 Adding support for your own device is easy, and takes little SNMP
107 knowledge.
108
109 The module is not limited to network devices. Any MIB or device can be
110 given an objected oriented front-end by making a module that consists
111 of a couple hashes. See EXTENDING SNMP::INFO.
112
114 1. Net-SNMP
115 To use this module, you must have Net-SNMP installed on your
116 system. More specifically you need the Perl modules that come with
117 it.
118
119 DO NOT INSTALL SNMP:: or Net::SNMP from CPAN!
120
121 The SNMP module is matched to an install of net-snmp, and must be
122 installed from the net-snmp source tree.
123
124 The Perl module "SNMP" is found inside the net-snmp distribution.
125 Go to the perl/ directory of the distribution to install it, or run
126 "./configure --with-perl-modules" from the top directory of the
127 net-snmp distribution.
128
129 Net-SNMP can be found at http://net-snmp.sourceforge.net
130
131 Version 5.3.2 or greater is recommended.
132
133 Versions 5.0.1, 5.0301 and 5.0203 have issues with bulkwalk and are
134 not supported.
135
136 Redhat Users: Some versions that come with certain versions of
137 Redhat/Fedora don't have the Perl library installed. Uninstall the
138 RPM and install by hand.
139
140 2. MIBS
141 SNMP::Info operates on textual descriptors found in MIBs.
142
143 If you are using SNMP::Info separate from Netdisco, download the
144 Netdisco MIB package at
145 <https://github.com/netdisco/netdisco-mibs/releases/latest/>
146
147 Make sure that your snmp.conf is updated to point to your MIB
148 directory and that the MIBs are world-readable.
149
151 1. Use of textual MIB leaf identifier and enumerated values
152 • All values are retrieved via MIB Leaf node names
153
154 For example SNMP::Info has an entry in its %GLOBALS hash for
155 ``sysName'' instead of 1.3.6.1.2.1.1.5.
156
157 • Data returned is in the enumerated value form.
158
159 For Example instead of looking up 1.3.6.1.2.1.2.2.1.3 and
160 getting back 23
161
162 SNMP::Info will ask for "RFC1213-MIB::ifType" and will get back
163 "ppp".
164
165 2. SNMP::Info is easily extended to new devices
166 You can create a new subclass for a device by providing four hashes
167 : %GLOBALS, %MIBS, %FUNCS, and %MUNGE.
168
169 Or you can override any existing methods from a parent class by
170 making a short subroutine.
171
172 See the section EXTENDING SNMP::INFO for more details.
173
174 When you make a new subclass for a device, please be sure to send
175 it back to the developers (via a github pull request or the mailing
176 list) for inclusion in the next version.
177
179 These are the subclasses that implement MIBs and support devices:
180
181 Required MIBs not included in the install instructions above are noted
182 here.
183
184 MIB Subclasses
185 These subclasses implement method to access one or more MIBs. These
186 are not used directly, but rather inherited from device subclasses.
187
188 For more info run "perldoc" on any of the following module names.
189
190 SNMP::Info::AdslLine
191 SNMP Interface to the ADSL-LINE-MIB for ADSL interfaces.
192
193 Requires the ADSL-LINE-MIB, down loadable from Cisco.
194
195 See documentation in SNMP::Info::AdslLine for details.
196
197 SNMP::Info::Aggregate
198 SNMP Interface to IF-MIB "ifStackTable" Aggregated Links
199
200 See documentation in SNMP::Info::Aggregate for details.
201
202 SNMP::Info::Airespace
203 AIRESPACE-WIRELESS-MIB and AIRESPACE-SWITCHING-MIB. Inherited by
204 devices based on the Airespace wireless platform.
205
206 See documentation in SNMP::Info::Airespace for details.
207
208 SNMP::Info::AMAP
209 ALCATEL-IND1-INTERSWITCH-PROTOCOL-MIB. Alcatel Mapping Adjacency
210 Protocol (AMAP) Support.
211
212 See documentation in SNMP::Info::AMAP for details.
213
214 SNMP::Info::Bridge
215 BRIDGE-MIB (RFC1286). Q-BRIDGE-MIB. Inherited by devices with
216 Layer2 support.
217
218 See documentation in SNMP::Info::Bridge for details.
219
220 SNMP::Info::CDP
221 CISCO-CDP-MIB. Cisco Discovery Protocol (CDP) Support. Inherited
222 by Cisco, Enterasys, and HP devices.
223
224 See documentation in SNMP::Info::CDP for details.
225
226 SNMP::Info::CiscoAgg
227 SNMP Interface to Cisco Aggregated Links
228
229 See documentation in SNMP::Info::CiscoAgg for details.
230
231 SNMP::Info::CiscoBGP
232 CISCO-BGP4-MIB. Cisco BGPv4 support. Inherited by Cisco devices
233 with Layer3 support.
234
235 See documentation in SNMP::Info::CiscoBGP for details.
236
237 SNMP::Info::CiscoConfig
238 CISCO-CONFIG-COPY-MIB, CISCO-FLASH-MIB, and OLD-CISCO-SYS-MIB.
239 These OIDs facilitate the writing of configuration files.
240
241 See documentation in SNMP::Info::CiscoConfig for details.
242
243 SNMP::Info::CiscoPortSecurity
244 CISCO-PORT-SECURITY-MIB and CISCO-PAE-MIB.
245
246 See documentation in SNMP::Info::CiscoPortSecurity for details.
247
248 SNMP::Info::CiscoPower
249 CISCO-POWER-ETHERNET-EXT-MIB.
250
251 See documentation in SNMP::Info::CiscoPower for details.
252
253 SNMP::Info::CiscoQOS
254 CISCO-CLASS-BASED-QOS-MIB. A collection of OIDs providing
255 information about a Cisco device's QOS config.
256
257 See documentation in SNMP::Info::CiscoQOS for details.
258
259 SNMP::Info::CiscoRTT
260 CISCO-RTTMON-MIB. A collection of OIDs providing information about
261 a Cisco device's RTT values.
262
263 See documentation in SNMP::Info::CiscoRTT for details.
264
265 SNMP::Info::CiscoStack
266 CISCO-STACK-MIB.
267
268 See documentation in SNMP::Info::CiscoStack for details.
269
270 SNMP::Info::CiscoStats
271 OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB, and CISCO-MEMORY-POOL-MIB.
272 Provides common interfaces for memory, cpu, and os statistics for
273 Cisco devices.
274
275 See documentation in SNMP::Info::CiscoStats for details.
276
277 SNMP::Info::CiscoStpExtensions
278 CISCO-STP-EXTENSIONS-MIB
279
280 See documentation in SNMP::Info::CiscoStpExtensions for details.
281
282 SNMP::Info::CiscoVTP
283 CISCO-VTP-MIB, CISCO-VLAN-MEMBERSHIP-MIB, CISCO-VLAN-IFTABLE-
284 RELATIONSHIP-MIB
285
286 See documentation in SNMP::Info::CiscoVTP for details.
287
288 SNMP::Info::DocsisCM
289 SNMP Interface for DOCSIS Cable Modems
290
291 See documentation in SNMP::Info::DocsisCM for details.
292
293 SNMP::Info::DocsisHE
294 SNMP Interface for DOCSIS CMTS
295
296 See documentation in SNMP::Info::DocsisHE for details.
297
298 SNMP::Info::EDP
299 Extreme Discovery Protocol. EXTREME-EDP-MIB
300
301 See documentation in SNMP::Info::EDP for details.
302
303 SNMP::Info::Entity
304 ENTITY-MIB. Used for device info in Cisco and other vendors.
305
306 See documentation in SNMP::Info::Entity for details.
307
308 SNMP::Info::EtherLike
309 EtherLike-MIB (RFC1398) - Some Layer3 devices implement this MIB,
310 as well as some Aironet Layer 2 devices (non Cisco).
311
312 See documentation in SNMP::Info::EtherLike for details.
313
314 SNMP::Info::FDP
315 Foundry (Brocade) Discovery Protocol. FOUNDRY-SN-SWITCH-GROUP-MIB
316
317 See documentation in SNMP::Info::FDP for details.
318
319 SNMP::Info::IEEE802_Bridge
320 SNMP Interface to data available through the IEEE8021-Q-BRIDGE-MIB
321
322 See documentation in SNMP::Info::IEEE802_Bridge for details.
323
324 SNMP::Info::IEEE802dot11
325 IEEE802dot11-MIB. A collection of OIDs providing information about
326 standards based 802.11 wireless devices.
327
328 See documentation in SNMP::Info::IEEE802dot11 for details.
329
330 SNMP::Info::IEEE802dot3ad
331 SNMP Interface to IEEE Aggregated Links. IEEE8023-LAG-MIB
332
333 See documentation in SNMP::Info::IEEE802dot3ad for details.
334
335 SNMP::Info::IPv6
336 SNMP Interface for obtaining configured IPv6 addresses and mapping
337 IPv6 addresses to MAC addresses and interfaces, using information
338 from IP-MIB, IPV6-MIB and/or CISCO-IETF-IP-MIB.
339
340 See documentation in SNMP::Info::IPv6 for details.
341
342 SNMP::Info::LLDP
343 LLDP-MIB, LLDP-EXT-DOT1-MIB, and LLDP-EXT-DOT3-MIB. Link Layer
344 Discovery Protocol (LLDP) Support.
345
346 See documentation in SNMP::Info::LLDP for details.
347
348 SNMP::Info::MAU
349 MAU-MIB (RFC2668). Some Layer2 devices use this for extended
350 Ethernet (Medium Attachment Unit) interface information.
351
352 See documentation in SNMP::Info::MAU for details.
353
354 SNMP::Info::MRO
355 Method resolution introspection for SNMP::Info
356
357 See documentation in SNMP::Info::MRO for details.
358
359 SNMP::Info::NortelStack
360 S5-AGENT-MIB, S5-CHASSIS-MIB.
361
362 See documentation in SNMP::Info::NortelStack for details.
363
364 SNMP::Info::PowerEthernet
365 POWER-ETHERNET-MIB
366
367 See documentation in SNMP::Info::PowerEthernet for details.
368
369 SNMP::Info::RapidCity
370 RAPID-CITY. Inherited by Avaya switches for duplex and VLAN
371 information.
372
373 See documentation in SNMP::Info::RapidCity for details.
374
375 SNMP::Info::SONMP
376 SynOptics Network Management Protocol (SONMP) SYNOPTICS-ROOT-MIB,
377 S5-ETH-MULTISEG-TOPOLOGY-MIB. Inherited by
378 Avaya/Nortel/Bay/Synoptics switches and hubs.
379
380 See documentation in SNMP::Info::SONMP for details.
381
382 Device Subclasses
383 These subclasses inherit from one or more classes to provide a common
384 interface to data obtainable from network devices.
385
386 All the required MIB files are included in the netdisco-mib package.
387 (See Above).
388
389 SNMP::Info::Layer1
390 Generic Layer1 Device subclass.
391
392 See documentation in SNMP::Info::Layer1 for details.
393
394 SNMP::Info::Layer1::Allied
395 Subclass for Allied Telesis Repeaters / Hubs.
396
397 Requires ATI-MIB
398
399 See documentation in SNMP::Info::Layer1::Allied for details.
400
401 SNMP::Info::Layer1::Asante
402 Subclass for Asante 1012 Hubs.
403
404 Requires ASANTE-HUB1012-MIB
405
406 See documentation in SNMP::Info::Layer1::Asante for details.
407
408 SNMP::Info::Layer1::Bayhub
409 Subclass for Nortel/Bay hubs. This includes System 5000, 100
410 series, 200 series, and probably more.
411
412 See documentation in SNMP::Info::Layer1::Bayhub for details.
413
414 SNMP::Info::Layer1::Cyclades
415 Subclass for Cyclades/Avocent terminal servers.
416
417 See documentation in SNMP::Info::Layer1::Cyclades for details.
418
419 SNMP::Info::Layer1::S3000
420 Subclass for Bay/Synoptics hubs. This includes System 3000,
421 281X, and probably more.
422
423 See documentation in SNMP::Info::Layer1::S3000 for details.
424
425 SNMP::Info::Layer2
426 Generic Layer2 Device subclass.
427
428 See documentation in SNMP::Info::Layer2 for details.
429
430 SNMP::Info::Layer2::3Com
431 Subclass for L2 3Com Switches.
432
433 See documentation in SNMP::Info::Layer2::3Com for details.
434
435 SNMP::Info::Layer2::Adtran
436 Subclass for Adtran devices.
437
438 See documentation in SNMP::Info::Layer2::Adtran for details.
439
440 SNMP::Info::Layer2::Aerohive
441 Subclass for Aerohive / Extreme access points.
442
443 See documentation in SNMP::Info::Layer2::Aerohive for details.
444
445 SNMP::Info::Layer2::Airespace
446 Subclass for Cisco (Airespace) wireless controllers.
447
448 See documentation in SNMP::Info::Layer2::Airespace for details.
449
450 SNMP::Info::Layer2::Aironet
451 Class for Cisco Aironet wireless devices that run IOS. See
452 also SNMP::Info::Layer3::Aironet for Aironet devices that don't
453 run IOS.
454
455 See documentation in SNMP::Info::Layer2::Aironet for details.
456
457 SNMP::Info::Layer2::Allied
458 Allied Telesis switches.
459
460 See documentation in SNMP::Info::Layer2::Allied for details.
461
462 SNMP::Info::Layer2::Atmedia
463 Subclass for atmedia encryptors.
464
465 See documentation in SNMP::Info::Layer2::Atmedia for details.
466
467 SNMP::Info::Layer2::Baystack
468 Subclass for Avaya/Nortel/Bay Ethernet Switch/Baystack
469 switches. This includes 303, 304, 350, 380, 410, 420, 425,
470 450, 460, 470 series, 2500 series, 4000 series, 5000 series,
471 Business Ethernet Switch (BES), Business Policy Switch (BPS),
472 VSP 7000 series, and probably others.
473
474 See documentation in SNMP::Info::Layer2::Baystack for details.
475
476 SNMP::Info::Layer2::C1900
477 Subclass for Cisco Catalyst 1900 and 1900c Devices running
478 CatOS.
479
480 See documentation in SNMP::Info::Layer2::C1900 for details.
481
482 SNMP::Info::Layer2::C2900
483 Subclass for Cisco Catalyst 2900, 2950, 3500XL, and 3548
484 devices running IOS.
485
486 See documentation in SNMP::Info::Layer2::C2900 for details.
487
488 SNMP::Info::Layer2::Catalyst
489 Subclass for Cisco Catalyst switches running CatOS. These
490 switches usually report a model number that starts with "wsc".
491 Note that this class does not support everything that has the
492 name Catalyst.
493
494 See documentation in SNMP::Info::Layer2::Catalyst for details.
495
496 SNMP::Info::Layer2::Centillion
497 Subclass for Nortel/Bay Centillion and 5000BH ATM switches.
498
499 See documentation in SNMP::Info::Layer2::Centillion for
500 details.
501
502 SNMP::Info::Layer2::Cisco
503 Generic Cisco subclass for layer 2 devices that are not yet
504 supported in more specific subclasses and the base layer 2
505 Cisco class for other device specific layer 2 Cisco classes.
506
507 See documentation in SNMP::Info::Layer2::Cisco for details.
508
509 SNMP::Info::Layer2::CiscoSB
510 Subclass for Cisco's "Small Business" product line, acquired
511 from Linksys. This currently comprises the Sx300/500 line of
512 switches.
513
514 See documentation in SNMP::Info::Layer2::CiscoSB for details.
515
516 SNMP::Info::Layer2::Exinda
517 Subclass for Exinda / GFI Network Orchestrator traffic shapers.
518
519 See documentation in SNMP::Info::Layer2::Exinda for details.
520
521 SNMP::Info::Layer2::HP
522 Subclass for more recent HP Procurve Switches.
523
524 Requires HP-ICF-OID and ENTITY-MIB downloaded from HP.
525
526 See documentation in SNMP::Info::Layer2::HP for details.
527
528 SNMP::Info::Layer2::HP4000
529 Subclass for older HP Procurve Switches
530
531 Requires HP-ICF-OID and ENTITY-MIB downloaded from HP.
532
533 See documentation in SNMP::Info::Layer2::HP4000 for details.
534
535 SNMP::Info::Layer2::HPVC
536 Subclass for HP Virtual Connect Switches
537
538 See documentation in SNMP::Info::Layer2::HPVC for details.
539
540 SNMP::Info::Layer2::Kentrox
541 Class for Kentrox DataSMART DSU/CSU.
542
543 See documentation in SNMP::Info::Layer2::Kentrox for details.
544
545 SNMP::Info::Layer2::N2270
546 Subclass for Nortel 2270 wireless switches.
547
548 See documentation in SNMP::Info::Layer2::N2270 for details.
549
550 SNMP::Info::Layer2::NAP222x
551 Subclass for Nortel 222x series wireless access points.
552
553 See documentation in SNMP::Info::Layer2::NAP222x for details.
554
555 SNMP::Info::Layer2::Netgear
556 Subclass for Netgear switches
557
558 See documentation in SNMP::Info::Layer2::Netgear for details.
559
560 SNMP::Info::Layer2::Nexans
561 Subclass for Nexans switches
562
563 See documentation in SNMP::Info::Layer2::Nexans for details.
564
565 SNMP::Info::Layer2::NWSS2300
566 SNMP Interface to Avaya (Trapeze) Wireless Controllers
567
568 See documentation in SNMP::Info::Layer2::NWSS2300 for details.
569
570 SNMP::Info::Layer2::Orinoco
571 Subclass for Orinoco/Proxim wireless access points.
572
573 See documentation in SNMP::Info::Layer2::Orinoco for details.
574
575 SNMP::Info::Layer2::Trapeze
576 SNMP Interface to Juniper (Trapeze) Wireless Controllers
577
578 See documentation in SNMP::Info::Layer2::Trapeze for details.
579
580 SNMP::Info::Layer2::Sixnet
581 SNMP Interface to Sixnet industrial switches
582
583 See documentation in SNMP::Info::Layer2::Sixnet for details.
584
585 SNMP::Info::Layer2::Ubiquiti
586 SNMP Interface to Ubiquiti Access Points and other devices
587
588 See documentation in SNMP::Info::Layer2::Ubiquiti for details.
589
590 SNMP::Info::Layer2::ZyXEL_DSLAM
591 Zyxel DSLAMs. Need I say more?
592
593 See documentation in SNMP::Info::Layer2::ZyXEL_DSLAM for
594 details.
595
596 SNMP::Info::Layer3
597 Generic Layer3 and Layer2+3 Device subclass.
598
599 See documentation in SNMP::Info::Layer3 for details.
600
601 SNMP::Info::Layer3::Aironet
602 Subclass for Cisco Aironet wireless access points (AP) not
603 running IOS. These are usually older devices.
604
605 Note SNMP::Info::Layer2::Aironet
606
607 See documentation in SNMP::Info::Layer3::Aironet for details.
608
609 SNMP::Info::Layer3::AlcatelLucent
610 Alcatel-Lucent OmniSwitch Class.
611
612 See documentation in SNMP::Info::Layer3::AlcatelLucent for
613 details.
614
615 SNMP::Info::Layer3::AlteonAD
616 Subclass for Radware Alteon Series ADC switches and Nortel
617 BladeCenter Layer2-3 GbE Switch Modules.
618
619 See documentation in SNMP::Info::Layer3::AlteonAD for details.
620
621 SNMP::Info::Layer3::Altiga
622 See documentation in SNMP::Info::Layer3::Altiga for details.
623
624 SNMP::Info::Layer3::Arista
625 See documentation in SNMP::Info::Layer3::Arista for details.
626
627 SNMP::Info::Layer3::Aruba
628 Subclass for Aruba wireless switches.
629
630 See documentation in SNMP::Info::Layer3::Aruba for details.
631
632 SNMP::Info::Layer3::ArubaCX
633 SNMP Interface to L3 Devices running ArubaOS-CX
634
635 See documentation in SNMP::Info::Layer3::ArubaCX for details.
636
637 SNMP::Info::Layer3::BayRS
638 Subclass for Avaya/Nortel/Bay Multiprotocol/BayRS routers.
639 This includes BCN, BLN, ASN, ARN, AN, 2430, and 5430 routers.
640
641 See documentation in SNMP::Info::Layer3::BayRS for details.
642
643 SNMP::Info::Layer3::BlueCoatSG
644 Subclass for BlueCoat SG series proxy devices.
645
646 See documentation in SNMP::Info::Layer3::BlueCoatSG for
647 details.
648
649 SNMP::Info::Layer3::C3550
650 Subclass for Cisco Catalyst 3550,3540,3560 2/3 switches running
651 IOS.
652
653 See documentation in SNMP::Info::Layer3::C3550 for details.
654
655 SNMP::Info::Layer3::C4000
656 This class covers Catalyst 4000s and 4500s.
657
658 See documentation in SNMP::Info::Layer3::C4000 for details.
659
660 SNMP::Info::Layer3::C6500
661 This class covers Catalyst 6500 series running CatOS or IOS, as
662 well as Catalyst 2960, 2970, 3750 and 3850 series, including
663 blade switches CBS30x0 and CBS31x0 series, all running IOS.
664
665 See documentation in SNMP::Info::Layer3::C6500 for details.
666
667 SNMP::Info::Layer3::CheckPoint
668 Subclass for CheckPoint devices.
669
670 See documentation in SNMP::Info::Layer3::CheckPoint for
671 details.
672
673 SNMP::Info::Layer3::Ciena
674 Subclass for Ciena devices.
675
676 See documentation in SNMP::Info::Layer3::Ciena for details.
677
678 SNMP::Info::Layer3::Cisco
679 This is a simple wrapper around layer 3 for IOS devices and the
680 base layer 3 Cisco class for other device specific layer 3
681 Cisco classes.
682
683 See documentation in SNMP::Info::Layer3::Cisco for details.
684
685 SNMP::Info::Layer3::CiscoASA
686 Subclass for Cisco Adaptive Security Appliances.
687
688 See documentation in SNMP::Info::Layer3::CiscoASA for details.
689
690 SNMP::Info::Layer3::CiscoFWSM
691 Subclass for Cisco Firewall Services Modules.
692
693 See documentation in SNMP::Info::Layer3::CiscoFWSM for details.
694
695 SNMP::Info::Layer3::CiscoSwitch
696 Base class for L3 Cisco switches. See documentation in
697 SNMP::Info::Layer3::CiscoSwitch for details.
698
699 SNMP::Info::Layer3::Contivity
700 Subclass for Avaya/Nortel Contivity/VPN Routers.
701
702 See documentation in SNMP::Info::Layer3::Contivity for details.
703
704 SNMP::Info::Layer3::Cumulus
705 Subclass for Cumulus Networks Routers.
706
707 See documentation in SNMP::Info::Layer3::Cumulus for details.
708
709 SNMP::Info::Layer3::Dell
710 Subclass for Dell PowerConnect switches. The IBM BladeCenter
711 Gigabit Ethernet Switch Module and some Linksys switches also
712 use this module based upon MIB support.
713
714 See documentation in SNMP::Info::Layer3::Dell for details.
715
716 SNMP::Info::Layer3::DLink
717 Subclass for DLink devices.
718
719 See documentation in SNMP::Info::Layer3::DLink for details.
720
721 SNMP::Info::Layer3::Enterasys
722 Subclass for Enterasys devices.
723
724 See documentation in SNMP::Info::Layer3::Enterasys for details.
725
726 SNMP::Info::Layer3::ERX
727 Subclass for Juniper ERX switches.
728
729 See documentation in SNMP::Info::Layer3::ERX for details.
730
731 SNMP::Info::Layer3::Extreme
732 Subclass for Extreme Networks switches.
733
734 See documentation in SNMP::Info::Layer3::Extreme for details.
735
736 SNMP::Info::Layer3::F5
737 Subclass for F5 devices.
738
739 See documentation in SNMP::Info::Layer3::F5 for details.
740
741 SNMP::Info::Layer3::Force10
742 Subclass for Force10 devices.
743
744 See documentation in SNMP::Info::Layer3::Force10 for details.
745
746 SNMP::Info::Layer3::Fortinet
747 Subclass for Fortinet devices.
748
749 See documentation in SNMP::Info::Layer3::Fortinet for details.
750
751 SNMP::Info::Layer3::Foundry
752 Subclass for Brocade (Foundry) Network devices.
753
754 See documentation in SNMP::Info::Layer3::Foundry for details.
755
756 SNMP::Info::Layer3::Genua
757 Subclass for Genua security devices.
758
759 See documentation in SNMP::Info::Layer3::Genua for details.
760
761 SNMP::Info::Layer3::H3C
762 SNMP Interface to Layer 3 Devices, H3C & HP A-series.
763
764 See documentation in SNMP::Info::Layer3::H3C for details.
765
766 SNMP::Info::Layer3::HP9300
767 Subclass for HP network devices which Foundry Networks was the
768 Original Equipment Manufacturer (OEM) such as the HP ProCurve
769 9300 and 6300 series.
770
771 See documentation in SNMP::Info::Layer3::HP9300 for details.
772
773 SNMP::Info::Layer3::Huawei
774 SNMP Interface to Huawei Layer 3 switches and routers.
775
776 See documentation in SNMP::Info::Layer3::Huawei for details.
777
778 SNMP::Info::Layer3::IBMGbTor
779 SNMP Interface to IBM Rackswitch (formerly Blade Network
780 Technologies) network devices. Lenovo acquired these from IBM
781 and is now selling them under the Lenovo brand.
782
783 See documentation in SNMP::Info::Layer3::IBMGbTor for details.
784
785 SNMP::Info::Layer3::Juniper
786 Subclass for Juniper devices.
787
788 See documentation in SNMP::Info::Layer3::Juniper for details.
789
790 SNMP::Info::Layer3::Lantronix
791 Subclass for Lantronix devices.
792
793 See documentation in SNMP::Info::Layer3::Lantronix for details.
794
795 SNMP::Info::Layer3::Lenovo
796 Subclass for Lenovo switches running CNOS.
797
798 See documentation in SNMP::Info::Layer3::Lenovo for details.
799
800 SNMP::Info::Layer3::Microsoft
801 Subclass for Generic Microsoft Routers running Microsoft
802 Windows OS.
803
804 See documentation in SNMP::Info::Layer3::Microsoft for details.
805
806 SNMP::Info::Layer3::Mikrotik
807 Subclass for Mikrotik devices running RouterOS.
808
809 See documentation in SNMP::Info::Layer3::Mikrotik for details.
810
811 SNMP::Info::Layer3::N1600
812 Subclass for Avaya/Nortel Ethernet Routing Switch 1600 series.
813
814 See documentation in SNMP::Info::Layer3::N1600 for details.
815
816 SNMP::Info::Layer3::NetSNMP
817 Subclass for host systems running Net-SNMP.
818
819 See documentation in SNMP::Info::Layer3::NetSNMP for details.
820
821 SNMP::Info::Layer3::Netscreen
822 Subclass for Juniper NetScreen.
823
824 See documentation in SNMP::Info::Layer3::Netscreen for details.
825
826 SNMP::Info::Layer3::Nexus
827 Subclass for Cisco Nexus devices running NX-OS.
828
829 See documentation in SNMP::Info::Layer3::Nexus for details.
830
831 SNMP::Info::Layer3::OneAccess
832 Subclass for OneAccess routers.
833
834 See documentation in SNMP::Info::Layer3::OneAccess for details.
835
836 SNMP::Info::Layer3::PacketFront
837 Subclass for PacketFront DRG series CPE.
838
839 See documentation in SNMP::Info::Layer3::PacketFront for
840 details.
841
842 SNMP::Info::Layer3::PaloAlto
843 Subclass for Palo Alto firewalls.
844
845 See documentation in SNMP::Info::Layer3::PaloAlto for details.
846
847 SNMP::Info::Layer3::Passport
848 Subclass for Avaya/Nortel Ethernet Routing Switch/Passport 8000
849 series, Accelar, and VSP 9000 series switches.
850
851 See documentation in SNMP::Info::Layer3::Passport for details.
852
853 SNMP::Info::Layer3::Pf
854 Subclass for FreeBSD-Based Firewalls using Pf /Pf Sense
855
856 See documentation in SNMP::Info::Layer3::Pf for details.
857
858 SNMP::Info::Layer3::Pica8
859 Subclass for Pica8 devices.
860
861 See documentation in SNMP::Info::Layer3::Pica8 for details.
862
863 SNMP::Info::Layer3::Redlion
864 Subclass for redlion routers.
865
866 See documentation in SNMP::Info::Layer3::Redlion for details.
867
868 SNMP::Info::Layer3::Scalance
869 Subclass for Siemens Scalance devices.
870
871 See documentation in SNMP::Info::Layer3::Scalance for details.
872
873 SNMP::Info::Layer3::SonicWALL
874 Subclass for generic SonicWALL devices.
875
876 See documentation in SNMP::Info::Layer3::SonicWALL for details.
877
878 SNMP::Info::Layer3::Steelfusion
879 Subclass for Riverbed Steelfusion WAN optimization appliances.
880
881 See documentation in SNMP::Info::Layer3::Steelfusion for
882 details.
883
884 SNMP::Info::Layer3::Steelhead
885 Subclass for Riverbed Steelhead WAN optimization appliances.
886
887 See documentation in SNMP::Info::Layer3::Steelhead for details.
888
889 SNMP::Info::Layer3::SteelheadEx
890 Subclass for Riverbed SteelheadEx WAN optimization appliances.
891
892 See documentation in SNMP::Info::Layer3::SteelheadEx for
893 details.
894
895 SNMP::Info::Layer3::Sun
896 Subclass for Generic Sun Routers running SunOS.
897
898 See documentation in SNMP::Info::Layer3::Sun for details.
899
900 SNMP::Info::Layer3::Tasman
901 Subclass for Avaya Secure Routers.
902
903 See documentation in SNMP::Info::Layer3::Tasman for details.
904
905 SNMP::Info::Layer3::Teltonika
906 Subclass for Teltonika RUT9xx series routers.
907
908 See documentation in SNMP::Info::Layer3::Teltonika for details.
909
910 SNMP::Info::Layer3::Timetra
911 Alcatel-Lucent SR Class.
912
913 See documentation in SNMP::Info::Layer3::Timetra for details.
914
915 SNMP::Info::Layer3::VyOS
916 Subclass for VyOS routers.
917
918 See documentation in SNMP::Info::Layer3::VyOS for details.
919
920 SNMP::Info::Layer3::VMware
921 Subclass for VMware ESXi hosts.
922
923 See documentation in SNMP::Info::Layer3::VMware for details.
924
925 SNMP::Info::Layer3::Whiterabbit
926 Subclass for whiterabbit devices.
927
928 See documentation in SNMP::Info::Layer3::Whiterabbit for
929 details.
930
931 SNMP::Info::Layer7
932 Generic Layer7 Devices.
933
934 See documentation in SNMP::Info::Layer7 for details.
935
936 SNMP::Info::Layer7::APC
937 Subclass for APC UPS devices.
938
939 See documentation in SNMP::Info::Layer7::APC for details.
940
941 SNMP::Info::Layer7::Arbor
942 Subclass for Arbor appliances.
943
944 See documentation in SNMP::Info::Layer7::Arbor for details.
945
946 SNMP::Info::Layer7::CiscoIPS
947 Subclass for Cisco IPS devices.
948
949 See documentation in SNMP::Info::Layer7::CiscoIPS for details.
950
951 SNMP::Info::Layer7::Gigamon
952 Subclass for Gigamon devices.
953
954 See documentation in SNMP::Info::Layer7::Gigamon for details.
955
956 SNMP::Info::Layer7::Liebert
957 Subclass for Liebert devices.
958
959 See documentation in SNMP::Info::Layer7::Liebert for details.
960
961 SNMP::Info::Layer7::Neoteris
962 Subclass for Pulse Secure / Juniper SSL VPN appliances.
963
964 See documentation in SNMP::Info::Layer7::Neoteris for details.
965
966 SNMP::Info::Layer7::Netscaler
967 Subclass for Citrix Netscaler appliances.
968
969 See documentation in SNMP::Info::Layer7::Netscaler for details.
970
972 Thanks for testing and coding help (in no particular order) to :
973 Alexander Barthel, Andy Ford, Alexander Hartmaier, Andrew Herrick, Alex
974 Kramarov, Bernhard Augenstein, Bradley Baetz, Brian Chow, Brian Wilson,
975 Carlos Vicente, Dana Watanabe, David Pinkoski, David Sieborger, Douglas
976 McKeown, Greg King, Ivan Auger, Jean-Philippe Luiggi, Jeroen van Ingen,
977 Justin Hunter, Kent Hamilton, Matthew Tuttle, Michael Robbert, Mike
978 Hunter, Nicolai Petri, Ralf Gross, Robert Kerr, Nick Nauwelaerts and
979 people listed on the Netdisco README!
980
982 Constructor
983 new()
984 Creates a new object and connects via SNMP::Session.
985
986 my $info = new SNMP::Info( 'Debug' => 1,
987 'AutoSpecify' => 1,
988 'BigInt' => 1,
989 'BulkWalk' => 1,
990 'BulkRepeaters' => 20,
991 'IgnoreNetSNMPConf' => 1,
992 'LoopDetect' => 1,
993 'DestHost' => 'myrouter',
994 'Community' => 'public',
995 'Version' => 2,
996 'MibDirs' => ['dir1','dir2','dir3'],
997 ) or die;
998
999 SNMP::Info Specific Arguments :
1000
1001 AutoSpecify
1002 Returns an object of a more specific device class
1003
1004 (default 0, which means "off")
1005
1006 BigInt
1007 Return Math::BigInt objects for 64 bit counters. Sets on a
1008 global scope, not object.
1009
1010 (default 0, which means "off")
1011
1012 BulkWalk
1013 Set to 0 to turn off BULKWALK commands for SNMPv2 connections.
1014
1015 Note that BULKWALK is turned off for Net-SNMP versions 5.1.x
1016 because of a bug.
1017
1018 (default 1, which means "on")
1019
1020 BulkRepeaters
1021 Set number of MaxRepeaters for BULKWALK operation. See
1022 "perldoc SNMP" -> bulkwalk() for more info.
1023
1024 (default 20)
1025
1026 LoopDetect
1027 Detects looping during getnext table column walks by comparing
1028 IIDs for each instance. A loop is detected if the same IID is
1029 seen more than once and the walk is aborted. Note: This will
1030 not detect loops during a bulkwalk operation, Net-SNMP's
1031 internal bulkwalk function must detect the loop.
1032
1033 Set to 0 to turn off loop detection.
1034
1035 (default 1, which means "on")
1036
1037 IgnoreNetSNMPConf
1038 Net-SNMP version 5.0 and higher read configuration files,
1039 snmp.conf or snmp.local.conf, from /etc/snmp, /usr/share/snmp,
1040 /usr/lib(64)/snmp, or $HOME/.snmp and uses those settings to
1041 automatically parse MIB files, etc.
1042
1043 Set to 1 "on" to ignore Net-SNMP configuration files by
1044 overriding the "SNMPCONFPATH" environmental variable during
1045 object initialization. Note: MibDirs must be defined or Net-
1046 SNMP will not be able to load MIBs and initialize the object.
1047
1048 (default 0, which means "off")
1049
1050 Debug
1051 Prints Lots of debugging messages. Pass 2 to print even more
1052 debugging messages.
1053
1054 (default 0, which means "off")
1055
1056 DebugSNMP
1057 Set $SNMP::debugging level for Net-SNMP.
1058
1059 See SNMP for more details.
1060
1061 MibDirs
1062 Array ref to list of directories in which to look for MIBs.
1063 Note this will be in addition to the ones setup in snmp.conf at
1064 the system level.
1065
1066 (default use net-snmp settings only)
1067
1068 RetryNoSuch
1069 When using SNMP Version 1, try reading values even if they come
1070 back as "no such variable in this MIB". Set to false if so
1071 desired. This feature lets you read SNMPv2 data from an SNMP
1072 version 1 connection, and should probably be left on.
1073
1074 (default 1, which means "on")
1075
1076 Session
1077 SNMP::Session object to use instead of connecting on own.
1078
1079 (default creates session automatically)
1080
1081 Offline
1082 Causes SNMP::Info to avoid network activity and return data
1083 only from its cache. If you ask for something not in the cache,
1084 an error is thrown. See also the "cache()" and "offline()"
1085 methods.
1086
1087 (default 0, which means "online")
1088
1089 Cache
1090 Pass in a HashRef to prime the cache of retrieved data. Useful
1091 for creating an instance in "Offline" mode from a previously
1092 dumped cache. See also the "cache()" method to retrieve a cache
1093 after running actial queries.
1094
1095 OTHER
1096 All other arguments are passed to SNMP::Session.
1097
1098 See SNMP::Session for a list of other possible arguments.
1099
1100 A Note about the wrong Community string or wrong SNMP Version:
1101
1102 If a connection is using the wrong community string or the wrong
1103 SNMP version, the creation of the object will not fail. The device
1104 still answers the call on the SNMP port, but will not return
1105 information. Check the error() method after you create the device
1106 object to see if there was a problem in connecting.
1107
1108 A note about SNMP Versions :
1109
1110 Some older devices don't support SNMP version 2, and will not
1111 return anything when a connection under Version 2 is attempted.
1112
1113 Some newer devices will support Version 1, but will not return all
1114 the data they might have if you had connected under Version 1.
1115
1116 When trying to get info from a new device, you may have to try
1117 version 2 and then fallback to version 1.
1118
1119 update()
1120 Replace the existing session with a new one with updated values,
1121 without re-identifying the device. The only supported changes are
1122 to Community or Context.
1123
1124 Clears the object cache.
1125
1126 This is useful, e.g., when a device supports multiple contexts (via
1127 changes to the Community string, or via the SNMPv3 Context
1128 parameter), but a context that you want to access does not support
1129 the objects (e.g., "sysObjectID", "sysDescr") that we use to
1130 identify the device.
1131
1132 Data is Cached
1133 Methods and subroutines requesting data from a device will only load
1134 the data once, and then return cached versions of that data.
1135
1136 Run $info->load_METHOD() where method is something like 'i_name' to
1137 reload data from a method.
1138
1139 Run $info->clear_cache() to clear the cache to allow reload of both
1140 globals and table methods.
1141
1142 The cache can be retrieved or set using the $info->cache() method. This
1143 works together with the "Offline" option.
1144
1145 Object Scalar Methods
1146 These are for package related data, not directly supplied from SNMP.
1147
1148 $info->clear_cache()
1149 Clears the cached data. This includes GLOBALS data and TABLE
1150 METHOD data.
1151
1152 $info->debug(1)
1153 Returns current debug status, and optionally toggles debugging info
1154 for this object.
1155
1156 $info->offline([1|0])
1157 Returns if offline mode is currently turned on for this object.
1158
1159 Optionally sets the Offline parameter.
1160
1161 $info->cache([new_cache])
1162 Returns a HashRef of all cached data in this object. There will be
1163 a "store" key for table data and then one key for each leaf.
1164
1165 Optionally sets the cache parameters if passed a HashRef.
1166
1167 $info->bulkwalk([1|0])
1168 Returns if bulkwalk is currently turned on for this object.
1169
1170 Optionally sets the bulkwalk parameter.
1171
1172 $info->loopdetect([1|0])
1173 Returns if loopdetect is currently turned on for this object.
1174
1175 Optionally sets the loopdetect parameter.
1176
1177 $info->device_type()
1178 Returns the Subclass name for this device. "SNMP::Info" is
1179 returned if no more specific class is available.
1180
1181 First the device is checked for Layer 3 support and a specific
1182 subclass, then Layer 2 support and subclasses are checked.
1183
1184 This means that Layer 2 / 3 switches and routers will fall under
1185 the SNMP::Info::Layer3 subclasses.
1186
1187 If the device still can be connected to via SNMP::Info, then
1188 SNMP::Info is returned.
1189
1190 $info->error(no_clear)
1191 Returns Error message if there is an error, or undef if there is
1192 not.
1193
1194 Reading the error will clear the error unless you set the no_clear
1195 flag.
1196
1197 $info->has_layer(3)
1198 Returns non-zero if the device has the supplied layer in the OSI
1199 Model
1200
1201 Returns if the device doesn't support the layers() call.
1202
1203 $info->snmp_comm()
1204 Returns SNMP Community string used in connection.
1205
1206 $info->snmp_ver()
1207 Returns SNMP Version used for this connection
1208
1209 $info->specify()
1210 Returns an object of a more-specific subclass.
1211
1212 my $info = new SNMP::Info(...);
1213 # Returns more specific object type
1214 my $specific = $info->specify();
1215
1216 Usually this method is called internally from new(AutoSpecify => 1)
1217
1218 See device_type() entry for how a subclass is chosen.
1219
1220 $info->cisco_comm_indexing()
1221 Returns 0. Is an overridable method used for vlan indexing for
1222 snmp calls on certain Cisco devices.
1223
1224 See
1225 <ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html>
1226
1227 GLOBALS (Scalar Methods)
1228 These are methods to return scalar data from RFC1213.
1229
1230 Some subset of these is probably available for any network device that
1231 speaks SNMP.
1232
1233 $info->uptime()
1234 Uptime in hundredths of seconds since device became available.
1235
1236 ("sysUpTime")
1237
1238 $info->contact()
1239 ("sysContact")
1240
1241 $info->name()
1242 ("sysName")
1243
1244 $info->location()
1245 ("sysLocation")
1246
1247 $info->layers()
1248 This returns a binary encoded string where each digit represents a
1249 layer of the OSI model served by the device.
1250
1251 eg: 01000010 means layers 2 (physical) and 7 (Application)
1252 are served.
1253
1254 Note: This string is 8 digits long.
1255
1256 See $info->has_layer()
1257
1258 ("sysServices")
1259
1260 $info->ports()
1261 Number of interfaces available on this device.
1262
1263 Not too useful as the number of SNMP interfaces usually does not
1264 correspond with the number of physical ports
1265
1266 ("ifNumber")
1267
1268 $info->ipforwarding()
1269 The indication of whether the entity is acting as an IP gateway
1270
1271 Returns either forwarding or not-forwarding
1272
1273 ("ipForwarding")
1274
1275 Table Methods
1276 Each of these methods returns a hash_reference to a hash keyed on the
1277 interface index in SNMP.
1278
1279 Example : $info->interfaces() might return
1280
1281 { '1.12' => 'FastEthernet/0',
1282 '2.15' => 'FastEthernet/1',
1283 '9.99' => 'FastEthernet/2'
1284 }
1285
1286 The key is what you would see if you were to do an snmpwalk, and in
1287 some cases changes between reboots of the network device.
1288
1289 Partial Table Fetches
1290 If you want to get only a part of an SNMP table or a single instance
1291 from the table and you know the IID for the part of the table that you
1292 want, you can specify it in the call:
1293
1294 $local_routes = $info->ipr_route('192.168.0');
1295
1296 This will only fetch entries in the table that start with 192.168.0,
1297 which in this case are routes on the local network.
1298
1299 Remember that you must supply the partial IID (a numeric OID).
1300
1301 Partial table results are not cached.
1302
1303 Interface Information
1304 $info->interfaces()
1305 This methods is overridden in each subclass to provide a mapping
1306 between the Interface Table Index (iid) and the physical port name.
1307
1308 $info->if_ignore()
1309 Returns a reference to a hash where key values that exist are
1310 interfaces to ignore.
1311
1312 Ignored interfaces are ones that are usually not physical ports or
1313 Virtual Lans (VLANs) such as the Loopback interface, or the CPU
1314 interface.
1315
1316 $info->bulkwalk_no()
1317 Returns 0. Is an overridable method used for turn off bulkwalk for
1318 the device class.
1319
1320 $info->i_index()
1321 Default SNMP IID to Interface index.
1322
1323 ("ifIndex")
1324
1325 $info->i_description()
1326 Description of the interface. Usually a little longer single word
1327 name that is both human and machine friendly. Not always.
1328
1329 ("ifDescr")
1330
1331 $info->i_type()
1332 Interface type, such as Vlan, Ethernet, Serial
1333
1334 ("ifType")
1335
1336 $info->i_mtu()
1337 INTEGER. Interface MTU value.
1338
1339 ("ifMtu")
1340
1341 $info->i_speed()
1342 Speed of the link, human format. See munge_speed() later in
1343 document for details.
1344
1345 ("ifSpeed", "ifHighSpeed" if necessary)
1346
1347 $info->i_speed_raw()
1348 Speed of the link in bits per second without munging. If
1349 i_speed_high is available it will be used and multiplied by
1350 1_000_000.
1351
1352 ("ifSpeed", "ifHighSpeed" if necessary)
1353
1354 $info->i_speed_high()
1355 Speed of a high-speed link, human format. See munge_highspeed()
1356 later in document for details. You should not need to call this
1357 directly, as i_speed() will call it if it needs to.
1358
1359 ("ifHighSpeed")
1360
1361 $info->i_mac()
1362 MAC address of the interface. Note this is just the MAC of the
1363 port, not anything connected to it.
1364
1365 ("ifPhysAddress")
1366
1367 $info->i_up()
1368 Link Status of the interface. Typical values are 'up' and 'down'.
1369
1370 ("ifOperStatus")
1371
1372 $info->i_up_admin()
1373 Administrative status of the port. Typical values are 'enabled'
1374 and 'disabled'.
1375
1376 ("ifAdminStatus")
1377
1378 $info->i_lastchange()
1379 The value of "sysUpTime" when this port last changed states
1380 (up,down).
1381
1382 ("ifLastChange")
1383
1384 $info->i_name()
1385 Interface Name field. Supported by a smaller subset of devices,
1386 this fields is often human set.
1387
1388 ("ifName")
1389
1390 $info->i_alias()
1391 Interface Name field. For certain devices this is a more human
1392 friendly form of i_description(). For others it is a human set
1393 field like i_name().
1394
1395 ("ifAlias")
1396
1397 Interface Statistics
1398 $info->i_octet_in(), $info->i_octets_out(), $info->i_octet_in64(),
1399 $info->i_octets_out64()
1400 Bandwidth.
1401
1402 Number of octets sent/received on the interface including framing
1403 characters.
1404
1405 64 bit version may not exist on all devices.
1406
1407 NOTE: To manipulate 64 bit counters you need to use Math::BigInt,
1408 since the values are too large for a normal Perl scalar. Set the
1409 global $SNMP::Info::BIGINT to 1 , or pass the BigInt value to new()
1410 if you want SNMP::Info to do it for you.
1411
1412 ("ifInOctets") ("ifOutOctets") ("ifHCInOctets") ("ifHCOutOctets")
1413
1414 $info->i_errors_in(), $info->i_errors_out()
1415 Number of packets that contained an error preventing delivery. See
1416 "IF-MIB" for more info.
1417
1418 ("ifInErrors") ("ifOutErrors")
1419
1420 $info->i_pkts_ucast_in(), $info->i_pkts_ucast_out(),
1421 $info->i_pkts_ucast_in64(), $info->i_pkts_ucast_out64()
1422 Number of packets not sent to a multicast or broadcast address.
1423
1424 64 bit version may not exist on all devices.
1425
1426 ("ifInUcastPkts") ("ifOutUcastPkts") ("ifHCInUcastPkts")
1427 ("ifHCOutUcastPkts")
1428
1429 $info->i_pkts_nucast_in(), $info->i_pkts_nucast_out(),
1430 Number of packets sent to a multicast or broadcast address.
1431
1432 These methods are deprecated by i_pkts_multi_in() and
1433 i_pkts_bcast_in() according to "IF-MIB". Actual device usage may
1434 vary.
1435
1436 ("ifInNUcastPkts") ("ifOutNUcastPkts")
1437
1438 $info->i_pkts_multi_in() $info->i_pkts_multi_out(),
1439 $info->i_pkts_multi_in64(), $info->i_pkts_multi_out64()
1440 Number of packets sent to a multicast address.
1441
1442 64 bit version may not exist on all devices.
1443
1444 ("ifInMulticastPkts") ("ifOutMulticastPkts")
1445 ("ifHCInMulticastPkts") ("ifHCOutMulticastPkts")
1446
1447 $info->i_pkts_bcast_in() $info->i_pkts_bcast_out(),
1448 $info->i_pkts_bcast_in64() $info->i_pkts_bcast_out64()
1449 Number of packets sent to a broadcast address on an interface.
1450
1451 64 bit version may not exist on all devices.
1452
1453 ("ifInBroadcastPkts") ("ifOutBroadcastPkts")
1454 ("ifHCInBroadcastPkts") ("ifHCOutBroadcastPkts")
1455
1456 $info->i_discards_in() $info->i_discards_out()
1457 "The number of inbound packets which were chosen to be discarded
1458 even though no errors had been detected to prevent their being
1459 deliverable to a higher-layer protocol. One possible reason for
1460 discarding such a packet could be to free up buffer space."
1461 ("IF-MIB")
1462
1463 ("ifInDiscards") ("ifOutDiscards")
1464
1465 $info->i_bad_proto_in()
1466 "For packet-oriented interfaces, the number of packets received via
1467 the interface which were discarded because of an unknown or
1468 unsupported protocol. For character-oriented or fixed-length
1469 interfaces that support protocol multiplexing the number of
1470 transmission units received via the interface which were discarded
1471 because of an unknown or unsupported protocol. For any interface
1472 that does not support protocol multiplexing, this counter will
1473 always be 0."
1474
1475 ("ifInUnknownProtos")
1476
1477 $info->i_qlen_out()
1478 "The length of the output packet queue (in packets)."
1479
1480 ("ifOutQLen")
1481
1482 $info->i_specific()
1483 See "IF-MIB" for full description
1484
1485 ("ifSpecific")
1486
1487 IPv4 Address Table
1488 Each entry in this table is an IPv4 address in use on this device.
1489 Usually this is implemented in Layer3 Devices. These methods try the
1490 deprecated IPv4 address table "IP-MIB::ipAddrTable" first due to its
1491 prevalence and will try the current "IP-MIB::ipAddressTable" if it
1492 doesn't return any results. "IP-MIB::ipAddressTable" results are
1493 filtered to only return IPv4 unicast addresses and modified to match
1494 the return format of the older table for backwards compatibility.
1495
1496 See documentation in SNMP::Info::IPv6 for IPv6 Address Table.
1497
1498 $info->ip_index()
1499 Maps the IPv4 addresses to the interface index
1500
1501 ("ipAdEntIfIndex") or filtered and index modified
1502 ("ipAddressIfIndex")
1503
1504 $info->ip_table()
1505 Maps the Table to the IPv4 address
1506
1507 ("ipAdEntAddr") or address extracted from ("ipAddressIfIndex")
1508
1509 $info->ip_netmask()
1510 Gives netmask setting for IPv4 table entry.
1511
1512 ("ipAdEntNetMask") or netmask calculated from ("ipAddressPrefix")
1513
1514 $info->ip_broadcast()
1515 Gives the value of the least-significant bit in the IPv4 broadcast
1516 address either 1 or 0.
1517
1518 ("ipAdEntBcastAddr"), there is no equivalent from the
1519 "IP-MIB::ipAddressTable"
1520
1521 IP Routing Table
1522 $info->ipr_route()
1523 The route in question. A value of 0.0.0.0 is the default gateway
1524 route.
1525
1526 ("ipRouteDest")
1527
1528 $info->ipr_if()
1529 The interface (IID) that the route is on. Use interfaces() to map.
1530
1531 ("ipRouteIfIndex")
1532
1533 $info->ipr_1()
1534 Primary routing metric for this route.
1535
1536 ("ipRouteMetric1")
1537
1538 $info->ipr_2()
1539 If metrics are not used, they should be set to -1
1540
1541 ("ipRouteMetric2")
1542
1543 $info->ipr_3()
1544 ("ipRouteMetric3")
1545
1546 $info->ipr_4()
1547 ("ipRouteMetric4")
1548
1549 $info->ipr_5()
1550 ("ipRouteMetric5")
1551
1552 $info->ipr_dest()
1553 From RFC1213:
1554
1555 "The IP address of the next hop of this route.
1556 (In the case of a route bound to an interface
1557 which is realized via a broadcast media, the value
1558 of this field is the agent's IP address on that
1559 interface.)"
1560
1561 ("ipRouteNextHop")
1562
1563 $info->ipr_type()
1564 From RFC1213:
1565
1566 other(1), -- none of the following
1567 invalid(2), -- an invalidated route
1568 -- route to directly
1569 direct(3), -- connected (sub-)network
1570 -- route to a non-local
1571 indirect(4) -- host/network/sub-network
1572
1573
1574 "The type of route. Note that the values
1575 direct(3) and indirect(4) refer to the notion of
1576 direct and indirect routing in the IP
1577 architecture.
1578
1579 Setting this object to the value invalid(2) has
1580 the effect of invalidating the corresponding entry
1581 in the ipRouteTable object. That is, it
1582 effectively disassociates the destination
1583 identified with said entry from the route
1584 identified with said entry. It is an
1585 implementation-specific matter as to whether the
1586 agent removes an invalidated entry from the table.
1587 Accordingly, management stations must be prepared
1588 to receive tabular information from agents that
1589 corresponds to entries not currently in use.
1590 Proper interpretation of such entries requires
1591 examination of the relevant ipRouteType object."
1592
1593 ("ipRouteType")
1594
1595 $info->ipr_proto()
1596 From RFC1213:
1597
1598 other(1), -- none of the following
1599 -- non-protocol information,
1600 -- e.g., manually configured
1601 local(2), -- entries
1602 -- set via a network
1603 netmgmt(3), -- management protocol
1604 -- obtained via ICMP,
1605 icmp(4), -- e.g., Redirect
1606 -- the remaining values are
1607 -- all gateway routing
1608 -- protocols
1609 egp(5),
1610 ggp(6),
1611 hello(7),
1612 rip(8),
1613 is-is(9),
1614 es-is(10),
1615 ciscoIgrp(11),
1616 bbnSpfIgp(12),
1617 ospf(13),
1618 bgp(14)
1619
1620 ("ipRouteProto")
1621
1622 $info->ipr_age()
1623 Seconds since route was last updated or validated.
1624
1625 ("ipRouteAge")
1626
1627 $info->ipr_mask()
1628 Subnet Mask of route. 0.0.0.0 for default gateway.
1629
1630 ("ipRouteMask")
1631
1632 $info->ipr_info()
1633 Reference to MIB definition specific to routing protocol.
1634
1635 ("ipRouteInfo")
1636
1637 Topology Information
1638 Based upon the manufacturer and software version devices may support
1639 some combination of Layer 2 topology protocol information. SNMP::Info
1640 supports querying Link Layer Discovery Protocol (LLDP), Cisco Discovery
1641 Protocol (CDP), SynOptics/Bay/Nortel/Avaya Network Management Protocol
1642 (SONMP), Foundry/Brocade Discovery Protocol (FDP), Extreme Discovery
1643 Protocol (EDP), and Alcatel Mapping Adjacency Protocol (AMAP).
1644
1645 For protocol specific information and implementation:
1646
1647 AMAP: See SNMP::Info::AMAP for details.
1648 CDP: See SNMP::Info::CDP for details.
1649 EDP: See SNMP::Info::EDP for details.
1650 FDP: See SNMP::Info::FDP for details.
1651 LLDP: See SNMP::Info::LLDP for details.
1652 SONMP: See SNMP::Info::SONMP for details.
1653
1654 Topology Capabilities
1655
1656 $info->has_topo()
1657 Reports Layer 2 topology protocols which are supported and running
1658 on a device.
1659
1660 Returns either a reference to an array of protocols, possible
1661 values being: "lldp", "cdp", "sonmp", "fdp", "edp", "amap" or
1662 "undef" if no protocols are supported or running.
1663
1664 Common Topology Table Information
1665
1666 The common topology table methods below will query the device for
1667 information from the specified topology protocols and return a single
1668 hash combining all information. As a result, there may be identical
1669 topology information returned from the two protocols causing duplicate
1670 entries. It is the calling program's responsibility to identify any
1671 duplicate entries and remove duplicates if necessary. If it is
1672 necessary to understand which protocol provided the information,
1673 utilize the protocol specific methods directly rather than the generic
1674 methods.
1675
1676 The methods support partial table fetches by providing a partial as the
1677 first argument.
1678
1679 If a reference to an array is provided as the second argument, those
1680 protocols will be queried for information. The supported array values
1681 are: "lldp", "cdp", "sonmp", "fdp", "edp", "amap".
1682
1683 If nothing is passed in as the second argument, the methods will call
1684 has_topo() to determine supported and running topology protocols on the
1685 device.
1686
1687 $info->c_ip(partial, topology_protocol_arrayref)
1688 Returns reference to hash. Key: iid, Value: remote IPv4 address
1689
1690 If multiple entries exist with the same local port, c_if(), with
1691 the same IPv4 address, c_ip(), it may be a duplicate entry.
1692
1693 If multiple entries exist with the same local port, c_if(), with
1694 different IPv4 addresses, c_ip(), there is either a device in
1695 between two or more devices utilizing a different topology protocol
1696 or multiple devices which are not directly connected.
1697
1698 Use the protocol specific methods to dig deeper.
1699
1700 $info->c_if(partial, topology_protocol_arrayref)
1701 Returns reference to hash. Key: iid, Value: local device port
1702 (interfaces)
1703
1704 $info->c_port(partial, topology_protocol_arrayref)
1705 Returns reference to hash. Key: iid, Value: remote port
1706 (interfaces)
1707
1708 $info->c_id(partial, topology_protocol_arrayref)
1709 Returns reference to hash. Key: iid, Value: string value used to
1710 identify the chassis component associated with the remote system.
1711
1712 Note: SONMP does not return this information.
1713
1714 $info->c_platform(partial, topology_protocol_arrayref)
1715 Returns reference to hash. Key: iid, Value: Remote Device Type
1716
1717 Note: EDP does not provide this information. LLDP uses
1718 ("lldpRemSysDesc") or "lldp_rem_sysname" as the closest match.
1719
1720 $info->c_cap(partial, topology_protocol_arrayref)
1721 Returns reference to hash of arrays. Key: iid, Value: Array of
1722 capabilities supported by the device. See the specific protocol
1723 class for string values which could be elements within the array.
1724
1725 Note: Only CDP and LLDP support this method.
1726
1728 This section explains how to use SNMP::Info to do SNMP Set operations.
1729
1730 $info->set_METHOD($value)
1731 Sets the global METHOD to value. Assumes that iid is .0
1732
1733 Returns if failed, or the return value from SNMP::Session::set()
1734 (snmp_errno)
1735
1736 $info->set_location("Here!");
1737
1738 $info->set_METHOD($value,$iid)
1739 Table Methods. Set iid of method to value.
1740
1741 Returns if failed, or the return value from SNMP::Session::set()
1742 (snmp_errno)
1743
1744 # Disable a port administratively
1745 my %if_map = reverse %{$info->interfaces()}
1746 $info->set_i_up_admin('down', $if_map{'FastEthernet0/0'})
1747 or die "Couldn't disable the port. ",$info->error(1);
1748
1749 NOTE: You must be connected to your device with a "ReadWrite" community
1750 string in order for set operations to work.
1751
1752 NOTE: This will only set data listed in %FUNCS and %GLOBALS. For data
1753 acquired from overridden methods (subroutines) specific set_METHOD()
1754 subroutines will need to be added if they haven't been already.
1755
1757 SNMP::Info will not chirp anything to STDOUT unless there is a serious
1758 error (in which case it will probably die).
1759
1760 To get lots of debug info, set the Debug flag when calling new() or
1761 call $info->debug(1);
1762
1763 When calling a method check the return value. If the return value is
1764 undef then check $info->error()
1765
1766 Beware, calling $info->error() clears the error.
1767
1768 my $name = $info->name() or die "Couldn't get sysName!" . $name->error();
1769
1771 To support a new class (vendor or platform) of device, add a Perl
1772 package with the data structures and methods listed below.
1773
1774 If this seems a little scary, then the SNMP::Info developers are
1775 usually happy to accept the SNMP data from your device and make an
1776 attempt at the class themselves. Usually a "beta" release will go to
1777 CPAN for you to verify the implementation.
1778
1779 Gathering MIB data for SNMP::Info Developers
1780 The preference is to open a pull request in the github project. This
1781 allows all developers to have visibility into the request. Please
1782 include pointers to the applicable platform MIBs. For development we
1783 will need an "snmpwalk" of the device. There is a tool now included in
1784 the SNMP::Info distribution to help with this task, although you'll
1785 most likely need to download the distribution from CPAN as it's
1786 included in the ""contrib/util"" directory.
1787
1788 The utility is named "make_snmpdata.pl". Run it with a command line
1789 like:
1790
1791 ./make_snmpdata.pl -c community -i -d device_ip \
1792 -m /home/netdisco-mibs/rfc:/home/netdisco-mibs/net-snmp:/home/netdisco-mibs/dir3 \
1793 SNMPv2-MIB IF-MIB EtherLike-MIB BRIDGE-MIB Q-BRIDGE-MIB ENTITY-MIB \
1794 POWER-ETHERNET-MIB IPV6-MIB LLDP-MIB DEVICE-SPECIFIC-MIB-NAME(s) > output.txt
1795
1796 This will print to the file every MIB entry with data in a format that
1797 the developers can use to emulate read operations without needing
1798 access to the device. Preference would be to mask any sensitive data
1799 in the output, zip the file, and attach it to the github pull request.
1800 However, if you do not feel comfortable uploading the output to the
1801 tracker you could e-mail it to the developer that has claimed the
1802 ticket.
1803
1804 Data Structures required in new Subclass
1805 A class inheriting this class must implement these data structures :
1806
1807 $INIT
1808 Used to flag if the MIBs have been loaded yet.
1809
1810 %GLOBALS
1811 Contains a hash in the form ( method_name => SNMP MIB leaf name )
1812 These are scalar values such as name, uptime, etc.
1813
1814 To resolve MIB leaf name conflicts between private MIBs, you may
1815 prefix the leaf name with the MIB replacing each - (dash) and :
1816 (colon) with an _ (underscore). For example,
1817 ALTEON_TIGON_SWITCH_MIB__agSoftwareVersion would be used as the
1818 hash value instead of the net-snmp notation
1819 ALTEON-TIGON-SWITCH-MIB::agSoftwareVersion.
1820
1821 When choosing the name for the methods, be aware that other new Sub
1822 Modules might inherit this one to get it's features. Try to choose
1823 a prefix for methods that will give it's own name space inside the
1824 SNMP::Info methods.
1825
1826 %FUNCS
1827 Contains a hash in the form ( method_name => SNMP MIB leaf name)
1828 These are table entries, such as the "ifIndex"
1829
1830 To resolve MIB leaf name conflicts between private MIBs, you may
1831 prefix the leaf name with the MIB replacing each - (dash) and :
1832 (colon) with an _ (underscore). For example,
1833 ALTEON_TS_PHYSICAL_MIB__agPortCurCfgPortName would be used as the
1834 hash value instead of the net-snmp notation
1835 ALTEON-TS-PHYSICAL-MIB::agPortCurCfgPortName.
1836
1837 %MIBS
1838 A list of each mib needed.
1839
1840 ('MIB-NAME' => 'itemToTestForPresence')
1841
1842 The value for each entry should be a MIB object to check for to
1843 make sure that the MIB is present and has loaded correctly.
1844
1845 $info->init() will throw an exception if a MIB does not load.
1846
1847 %MUNGE
1848 A map between method calls (from %FUNCS or %GLOBALS) and subroutine
1849 methods. The subroutine called will be passed the data as it gets
1850 it from SNMP and it should return that same data in a more human
1851 friendly format.
1852
1853 Sample %MUNGE:
1854
1855 (my_ip => \&munge_ip,
1856 my_mac => \&munge_mac,
1857 my_layers => \&munge_dec2bin
1858 )
1859
1860 Sample Subclass
1861 Let's make a sample Layer 2 Device subclass. This class will inherit
1862 the Cisco Vlan module as an example.
1863
1864 ----------------------- snip --------------------------------
1865
1866 # SNMP::Info::Layer2::Sample
1867
1868 package SNMP::Info::Layer2::Sample;
1869
1870 $VERSION = 0.1;
1871
1872 use strict;
1873 use warnings;
1874
1875 use Exporter;
1876 use SNMP::Info::Layer2;
1877 use SNMP::Info::CiscoVTP;
1878
1879 @SNMP::Info::Layer2::Sample::ISA = qw/SNMP::Info::Layer2
1880 SNMP::Info::CiscoVTP Exporter/;
1881 @SNMP::Info::Layer2::Sample::EXPORT_OK = qw//;
1882
1883 our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE, $AUTOLOAD, $INIT, $DEBUG);
1884
1885 %MIBS = (%SNMP::Info::Layer2::MIBS,
1886 %SNMP::Info::CiscoVTP::MIBS,
1887 'SUPER-DOOPER-MIB' => 'supermibobject',
1888 );
1889
1890 %GLOBALS = (%SNMP::Info::Layer2::GLOBALS,
1891 %SNMP::Info::CiscoVTP::GLOBALS,
1892 'name' => 'supermib_supername',
1893 'favorite_color' => 'supermib_fav_color_object',
1894 'favorite_movie' => 'supermib_fav_movie_val',
1895 );
1896
1897 %FUNCS = (%SNMP::Info::Layer2::FUNCS,
1898 %SNMP::Info::CiscoVTP::FUNCS,
1899 # Super Dooper MIB - Super Hero Table
1900 'super_hero_index' => 'SuperHeroIfIndex',
1901 'super_hero_name' => 'SuperHeroIfName',
1902 'super_hero_powers' => 'SuperHeroIfPowers',
1903 );
1904
1905
1906 %MUNGE = (%SNMP::Info::Layer2::MUNGE,
1907 %SNMP::Info::CiscoVTP::MUNGE,
1908 'super_hero_powers' => \&munge_powers,
1909 );
1910
1911 # Override uptime() method from %SNMP::Info::GLOBALS
1912 sub uptime {
1913 my $sample = shift;
1914
1915 my $name = $sample->name();
1916
1917 # this is silly but you get the idea
1918 return '600' if defined $name ;
1919 }
1920
1921 # Create our own munge function
1922 sub munge_powers {
1923 my $power = shift;
1924
1925 # Take the returned obscure value and return something useful.
1926 return 'Fire' if $power =~ /reallyhot/i;
1927 return 'Ice' if $power =~ /reallycold/i;
1928
1929 # Else
1930 return $power;
1931 }
1932
1933 # Copious Documentation here!!!
1934 =head1 NAME
1935 =head1 AUTHOR
1936 =head1 SYNOPSIS
1937 =head1 DESCRIPTION
1938 =head2 Inherited Classes
1939 =head2 Required MIBs
1940 =head1 GLOBALS
1941 =head2 Overrides
1942 =head1 TABLE METHODS
1943 =head2 Overrides
1944 =cut
1945
1946 1; # don't forget this line
1947 ----------------------- snip --------------------------------
1948
1950 Object Namespace
1951 Internal data is stored with bareword keys. For example $info->{debug}
1952
1953 SNMP Data is stored or marked cached with keys starting with an
1954 underscore. For example $info->{_name} is the cache for $info->name().
1955
1956 Cached Table data is stored in $info->store() and marked cached per
1957 above.
1958
1959 Package Globals
1960 These set the default value for an object upon creation.
1961
1962 $DEBUG
1963 Default 0. Sends copious debug info to stdout. This global sets
1964 the object's debug status in new() unless 'Debug' argument passed
1965 in new(). Change objects' debug status with $info->debug().
1966
1967 $BIGINT
1968 Default 0. Set to true to have 64 bit counters return
1969 Math::BigInt objects instead of scalar string values. See note
1970 under Interface Statistics about 64 bit values.
1971
1972 $NOSUCH
1973 Default 1. Set to false to disable RetryNoSuch option for
1974 SNMP::Session. Or see method in new() to do it on an object scope.
1975
1976 $REPEATERS
1977 Default 20. MaxRepeaters for BULKWALK operations. See "perldoc
1978 SNMP" for more info. Can change by passing "BulkRepeaters" option
1979 in new()
1980
1981 Data Munging Callback Subroutines
1982 munge_speed()
1983 Makes human friendly speed ratings using %SPEED_MAP.
1984
1985 %SPEED_MAP = (
1986 '56000' => '56 kbps',
1987 '64000' => '64 kbps',
1988 '115000' => '115 kbps',
1989 '1500000' => '1.5 Mbps',
1990 '1536000' => 'T1',
1991 '1544000' => 'T1',
1992 '2000000' => '2.0 Mbps',
1993 '2048000' => '2.048 Mbps',
1994 '3072000' => 'Dual T1',
1995 '3088000' => 'Dual T1',
1996 '4000000' => '4.0 Mbps',
1997 '10000000' => '10 Mbps',
1998 '11000000' => '11 Mbps',
1999 '16000000' => '16 Mbps',
2000 '16777216' => '16 Mbps',
2001 '20000000' => '20 Mbps',
2002 '44210000' => 'T3',
2003 '44736000' => 'T3',
2004 '45000000' => '45 Mbps',
2005 '45045000' => 'DS3',
2006 '46359642' => 'DS3',
2007 '51850000' => 'OC-1',
2008 '54000000' => '54 Mbps',
2009 '64000000' => '64 Mbps',
2010 '100000000' => '100 Mbps',
2011 '149760000' => 'ATM on OC-3',
2012 '155000000' => 'OC-3',
2013 '155519000' => 'OC-3',
2014 '155520000' => 'OC-3',
2015 '200000000' => '200 Mbps',
2016 '400000000' => '400 Mbps',
2017 '599040000' => 'ATM on OC-12',
2018 '622000000' => 'OC-12',
2019 '622080000' => 'OC-12',
2020 '1000000000' => '1.0 Gbps',
2021 '2000000000' => '2.0 Gbps',
2022 '2488000000' => 'OC-48',
2023 )
2024
2025 Note: high speed interfaces (usually 1 Gbps or faster) have their
2026 link speed in "ifHighSpeed". i_speed() automatically determines
2027 whether to use "ifSpeed" or "ifHighSpeed"; if the latter is used,
2028 the value is munged by munge_highspeed(). SNMP::Info can return
2029 speeds up to terabit levels this way.
2030
2031 munge_highspeed()
2032 Makes human friendly speed ratings for "ifHighSpeed".
2033
2034 munge_ip()
2035 Takes a binary IP and makes it dotted ASCII.
2036
2037 munge_inetaddress
2038 Takes a binary IP address as defined by the SNMP InetAddress type
2039 and returns it as human readable string;
2040
2041 munge_mac()
2042 Takes an octet stream (HEX-STRING) and returns a colon separated
2043 ASCII hex string.
2044
2045 munge_prio_mac()
2046 Takes an 8-byte octet stream (HEX-STRING) and returns a colon
2047 separated ASCII hex string.
2048
2049 munge_prio_port()
2050 Takes an 2-byte octet stream (HEX-STRING) and returns a colon
2051 separated ASCII hex string.
2052
2053 munge_octet2hex()
2054 Takes a binary octet stream and returns an ASCII hex string.
2055
2056 munge_dec2bin()
2057 Takes a binary char and returns its ASCII binary representation.
2058
2059 munge_bits()
2060 Takes a SNMP2 'BITS' field and returns the ASCII bit string.
2061
2062 munge_counter64()
2063 If $BIGINT is set to true, then a Math::BigInt object is returned.
2064 See Math::BigInt for details.
2065
2066 munge_i_up()
2067 Net-SNMP tends to load "RFC1213-MIB" first, and so ignores the
2068 updated enumeration for "ifOperStatus" in "IF-MIB". This munge
2069 handles the "newer" definitions for the enumeration in IF-MIB.
2070
2071 TODO: Get the precedence of MIBs and overriding of MIB data in Net-
2072 SNMP figured out. Hierarchy/precedence of MIBS in SNMP::Info.
2073
2074 munge_port_list()
2075 Takes an octet string representing a set of ports and returns a
2076 reference to an array of binary values each array element
2077 representing a port.
2078
2079 If the element has a value of '1', then that port is included in
2080 the set of ports; the port is not included if it has a value of
2081 '0'.
2082
2083 munge_null()
2084 Removes control characters from a string.
2085
2086 munge_e_type()
2087 Takes an OID and return the object name if the right MIB is loaded.
2088
2089 Internally Used Functions
2090 resolve_desthost()
2091 Takes the SNMP::Session "DestHost" argument and determines if it is
2092 an 'IPv4' or 'IPv6' host. 'IPv6' hosts are prefixed with the
2093 "udp6:" "transport-specifier" as required by the underlying
2094 "Net-SNMP" library. If unable to determine the type of address or
2095 resolve a DNS name, dies with "croak".
2096
2097 $info->init()
2098 Used internally. Loads all entries in %MIBS.
2099
2100 $info->args()
2101 Returns a reference to the argument hash supplied to SNMP::Session
2102
2103 $info->class()
2104 Returns the class name of the object.
2105
2106 $info->error_throw(error message)
2107 Stores the error message for use by $info->error()
2108
2109 If $info->debug() is true, then the error message is carped too.
2110
2111 $info->funcs()
2112 Returns a reference to the %FUNCS hash.
2113
2114 $info->globals()
2115 Returns a reference to the %GLOBALS hash.
2116
2117 $info->mibs()
2118 Returns a reference to the %MIBS hash.
2119
2120 $info->munge()
2121 Returns a reference of the %MUNGE hash.
2122
2123 $info->nosuch()
2124 Returns NoSuch value set or not in new()
2125
2126 $info->session()
2127 Gets or Sets the SNMP::Session object.
2128
2129 $info->store(new_store)
2130 Returns or sets hash store for Table functions.
2131
2132 Store is a hash reference in this format :
2133
2134 $info->store = { attribute => { iid => value , iid2 => value2, ...
2135 } };
2136
2137 $info->_global()
2138 Used internally by AUTOLOAD to create dynamic methods from %GLOBALS
2139 or a single instance MIB Leaf node name from a loaded MIB.
2140
2141 Example: $info->name() on the first call dispatches to AUTOLOAD()
2142 which calls $info->_global('name') creating the method name().
2143
2144 These methods return data as a scalar.
2145
2146 $info->_set(attr,val,iid,type)
2147 Used internally by set_multi() to run an SNMP set command. When
2148 run clears attr cache.
2149
2150 Attr can be passed as either a scalar or a reference to an array or
2151 array of arrays when used with set_multi().
2152
2153 Example: $info->set_name('dog',3) uses autoload to resolve to
2154 $info->_set('name','dog',3);
2155
2156 $info->_make_setter(val,iid)
2157 Used internally by AUTOLOAD to create dynamic methods from either
2158 %GLOBALS, %FUNCS, or a valid mib leaf from a loaded MIB which runs
2159 an SNMP set command. When run clears the attribute cache.
2160
2161 Example: $info->set_name('dog',3) dispatches to autoload to
2162 resolve to $info->_set('name','dog',3) and _make_setter creates the
2163 set_name() method.
2164
2165 $info->set_multi(arrayref)
2166 Used to run an SNMP set command on several new values in the one
2167 request. Returns the result of $info->_set(method).
2168
2169 Pass either a reference to a 4 element array [<obj>, <iid>, <val>,
2170 <type>] or a reference to an array of 4 element arrays to specify
2171 multiple values.
2172
2173 <obj> - One of the following forms:
2174 1) leaf identifier (e.g., C<'sysContact'>)
2175 2) An entry in either %FUNCS, %GLOBALS (e.g., 'contact')
2176 <iid> - The dotted-decimal, instance identifier. For scalar MIB objects
2177 use '0'
2178 <val> - The SNMP data value being set (e.g., 'netdisco')
2179 <type> - Optional as the MIB should be loaded.
2180
2181 If one of the set assignments is invalid, then the request will be
2182 rejected without applying any of the new values - regardless of the
2183 order they appear in the list.
2184
2185 Example:
2186 my $vlan_set = [
2187 ['qb_v_untagged',"$old_vlan_id","$old_untagged_portlist"],
2188 ['qb_v_egress',"$new_vlan_id","$new_egress_portlist"],
2189 ['qb_v_egress',"$old_vlan_id","$old_egress_portlist"],
2190 ['qb_v_untagged',"$new_vlan_id","$new_untagged_portlist"],
2191 ['qb_i_vlan',"$port","$new_vlan_id"],
2192 ];
2193
2194 $info->set_multi($vlan_set);
2195
2196 $info->load_all()
2197 Debugging routine. This does not include any overridden method or
2198 method implemented by subroutine.
2199
2200 Runs $info->load_METHOD() for each entry in $info->funcs();
2201
2202 Returns $info->store() -- See store() entry.
2203
2204 Note return value has changed since version 0.3
2205
2206 $info->all()
2207 Runs $info->load_all() once then returns $info->store();
2208
2209 Use $info->load_all() to reload the data.
2210
2211 Note return value has changed since version 0.3
2212
2213 $info->_load_attr()
2214 Used internally by AUTOLOAD to create dynamic methods from %FUNCS
2215 or a MIB Leaf node name contained within a table of a loaded MIB.
2216
2217 Supports partial table fetches and single instance table fetches.
2218 See "Partial Table Fetches" in SNMP::Info.
2219
2220 These methods return data as a reference to a hash.
2221
2222 $info->_show_attr()
2223 Used internally by AUTOLOAD to return data called by methods listed
2224 in %FUNCS.
2225
2226 $info->snmp_connect_ip(ip)
2227 Returns true or false based upon snmp connectivity to an IP.
2228
2229 modify_port_list(portlist,offset,replacement)
2230 Replaces the specified bit in a port_list array and returns the
2231 packed bitmask
2232
2233 $info->_cache(attr, data)
2234 Cache retrieved data so that if it's asked for again, we use the
2235 cache instead of going back to Net-SNMP. Data is cached inside the
2236 blessed hashref $self.
2237
2238 Accepts the leaf and value (scalar, or hashref for a table). Does
2239 not return anything useful.
2240
2241 $info->_munge(attr, data)
2242 Raw data returned from Net-SNMP might not be formatted correctly or
2243 might have platform-specific bugs or mistakes. The MUNGE feature of
2244 SNMP::Info allows for fixups to take place.
2245
2246 Accepts the leaf and value (scalar, or hashref for a table) and
2247 returns the raw or the munged data, as appropriate. That is, you do
2248 not need to know whether MUNGE is installed, and it's safe to call
2249 this method regardless.
2250
2251 _validate_autoload_method(method)
2252 Used internally by AUTOLOAD to validate that a dynamic method
2253 should be created. Returns the OID of the MIB leaf node the method
2254 will get or set.
2255
2256 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is MIB
2257 Leaf node name in a loaded MIB for given class.
2258 2. Translates the MIB Leaf node name to an OID.
2259 3. Checks to see if the method access type is allowed for the
2260 resolved OID. Write access for set_ methods, read access for
2261 others.
2262 $info->can()
2263 Overrides UNIVERSAL::can() so that objects will correctly report
2264 their capabilities to include dynamic methods generated at run time
2265 via AUTOLOAD.
2266
2267 Calls parent can() first to see if method exists, if not validates
2268 that a method should be created then dispatches to the appropriate
2269 internal method for creation.
2270
2271 Returns undef if the method does not exist and can not be created.
2272
2273 AUTOLOAD
2274 Each entry in either %FUNCS, %GLOBALS, or MIB Leaf node names present
2275 in loaded MIBs are used by AUTOLOAD() to create dynamic methods.
2276
2277 1. Returns unless method is listed in %FUNCS, %GLOBALS, or is a MIB
2278 Leaf node name in a loaded MIB for given class.
2279 2. If the method exists in %GLOBALS or is a single instance MIB Leaf
2280 node name from a loaded MIB, _global() generates the method.
2281 3. If a set_ prefix is present _make_setter() generates the method.
2282 4. If the method exists in %FUNCS or is a MIB Leaf node name contained
2283 within a table from a loaded MIB, _load_attr() generates the method.
2284 5. A load_ prefix forces reloading of data and does not use cached
2285 data.
2286 6. A _raw suffix returns data ignoring any munge routines.
2287
2288 Override any dynamic method listed in %GLOBALS, %FUNCS, or MIB Leaf
2289 node name a by creating a subroutine with the same name.
2290
2291 For example to override $info->name() create `` sub name {...}'' in
2292 your subclass.
2293
2295 Changes from SNMP::Info Version 0.7 and on are: Copyright (c) 2003-2010
2296 Max Baker and SNMP::Info Developers All rights reserved.
2297
2298 Original Code is: Copyright (c) 2002-2003, Regents of the University of
2299 California All rights reserved.
2300
2301 Redistribution and use in source and binary forms, with or without
2302 modification, are permitted provided that the following conditions are
2303 met:
2304
2305 * Redistributions of source code must retain the above copyright notice,
2306 this list of conditions and the following disclaimer.
2307 * Redistributions in binary form must reproduce the above copyright
2308 notice, this list of conditions and the following disclaimer in the
2309 documentation and/or other materials provided with the distribution.
2310 * Neither the name of the University of California, Santa Cruz nor the
2311 names of its contributors may be used to endorse or promote products
2312 derived from this software without specific prior written permission.
2313
2314 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
2315 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2316 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
2317 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2318 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2319 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2320 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2321 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2322 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2323 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2324 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2325
2326
2327
2328perl v5.36.0 2022-07-22 SNMP::Info(3)