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