Elsewhere:
SNMP::Info was created at UCSC for [Netdisco].
use SNMP::Info;
my $info = new SNMP::Info(
# Auto Discover more specific Device Class
AutoSpecify => 1,
Debug => 1,
# The rest is passed to SNMP::Session
DestHost => 'router',
Community => 'public',
Version => 2
) or die "Can't connect to device.\n"
my $err = $info->error();
die "SNMP Community or Version probably wrong connecting to device. $err\n" if defined $err;
$name = $info->name();
$class = $info->class()
print "SNMP::Info is using this device class : $class\n";
# Find out the Duplex status for the ports
my $interfaces = $info->interfaces();
my $i_duplex = $info->i_duplex();
# Get CDP Neighbor info
my $c_if = $info->c_if();
my $c_ip = $info->c_ip();
my $c_port = $info->c_port();
# Print out data per port
foreach my $iid (keys %$interfaces){
my $duplex = $i_duplex->{$iid};
# Print out physical port name, not snmp iid
my $port = $interfaces->{$iid};
# The CDP Table has table entries different than the interface tables.
# So we use c_if to get the map from cdp table to interface table.
my %c_map = reverse %$c_if;
my $c_key = $c_map{$iid};
my $neighbor_ip = $c_ip->{$c_key};
my $neighbor_port = $c_port->{$c_key};
print "$port: $duplex duplex";
print " connected to $neighbor_ip / $neighbor_port\n" if defined $remote_ip;
print "\n";
}
SNMP::Info gives an object oriented interface to information obtained through SNMP.
This module lives at http://snmp-info.sourceforge.net Check for newest version and documentation.
This module is geared towards network devices. Subclasses exist for a number of network devices and common MIBs.
The idea behind this module is to give a common interface to data from network devices, leaving the device-specific hacks behind the scenes in subclasses.
In the SYNOPSIS example we fetch the name of all the ports on the device and the duplex
setting for that port with two methods -- interfaces() and i_duplex().
The information may be coming from any number of MIB files and is very vendor specific. SNMP::Info provides you a common method for all supported devices.
Adding support for your own device is easy, and takes little much SNMP knowledge.
The module is not limited to network devices. Any MIB or device can be given an objected oriented front-end by making a module that consists of a couple hashes. See EXTENDING SNMP::INFO.
DO NOT INSTALL SNMP:: or Net::SNMP from CPAN!
The SNMP module is matched to an install of net-snmp, and must be installed from the net-snmp source tree.
The Perl module SNMP is found inside the net-snmp distribution. Go to the perl/ directory
of the distribution to install it, or run ./configure --with-perl-modules from the top directory
of the net-snmp distribution.
Net-SNMP can be found at http://net-snmp.sourceforge.net
Version 5.0.2 or greater is recommended. Various version 4's will work, and 5.0.1 is kinda flaky on the Perl side.
Note: Net-SNMP was previously called ucd-snmp.
Make sure that your snmp.conf is updated to point to your MIB directory and that the MIBs are world-readable.
Then run snmpconf and setup that directory as default. Move snmp.conf
into /usr/local/share/snmp when you are done.
ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
To install them :
mkdir -p /usr/local/share/snmp/mibs && cd /usr/local/share/snmp/mibs && tar xvfz /path/to/v2.tar.gz
ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
Extract
by running
mkdir -p /usr/local/share/snmp/mibs cd /usr/local/share/snmp/mibs tar xvfz /path/to/v1.tar.gz BRIDGE-MIB.my SNMP-REPEATER-MIB.my ESSWITCH-MIB.my
Check below under each subclass for requirements.
23
SNMP::Info will ask for RFC1213-MIB::ifType and will get back ppp.
Or you can override any existing methods from a parent class by making a short subroutine.
See the section EXTENDING SNMP::INFO for more details.
When you make a new subclass for a device, please be sure to send it back to the developers at snmp@warped.org for inclusion in the next version.
| Bridge | SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB |
| CDP | SNMP::Info::CDP - Perl5 Interface to Cisco Discovery Protocol using SNMP |
| CiscoStack | SNMP::Info::CiscoStack - Intefaces to data from CISCO-STACK-MIB and CISCO-PORT-SECURITY-MIB |
| CiscoStats | SNMP::Info::CiscoStats - Perl5 Interface to CPU and Memory stats for Cisco Devices |
| CiscoVTP | SNMP::Info::CiscoVTP - Perl5 Interface to Cisco's VLAN Management MIBs |
| Entity | SNMP::Info::Entity - Perl5 Interface to SNMP data stored in ENTITY-MIB. |
| EtherLike | SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB |
| FDP | SNMP::Info::FDP - Perl5 Interface to Foundry Discovery Protocol using SNMP |
| Layer1 | SNMP::Info::Layer1 - Perl5 Interface to network devices serving Layer1 only. |
| Layer2 | SNMP::Info::Layer2 - Perl5 Interface to network devices serving Layer2 only. |
| Layer3 | SNMP::Info::Layer3 - Perl5 Interface to network devices serving Layer3 or Layers 2 & 3 |
| MAU | SNMP::Info::MAU - Perl5 Interface to Medium Access Unit via SNMP |
| NortelStack | SNMP::Info::NortelStack - Perl5 Interface to Nortel Stack information using SNMP |
| RapidCity | SNMP::Info::Layer2::RapidCity - SNMP Interface to Nortel Networks' RapidCity MIB |
| SONMP | SNMP::Info::SONMP - Perl5 Interface to SynOptics Network Management Protocol using SNMP |
| Aironet | SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices running Aironet software, not IOS |
| AlteonAD | |
| BayRS | SNMP::Info::Layer3::BayRS - Perl5 Interface to Nortel Networks' routers running BayRS. |
| C3550 | SNMP::Info::Layer3::C3550 - Perl5 Interface to Cisco Catalyst 3550 Layer 2/3 Switches running IOS |
| C6500 | SNMP::Info::Layer3::C6500 - Perl5 Interface to Cisco Catalyst 6500 Layer 2/3 Switches running IOS and/or CatOS |
| Cisco | |
| Contivity | |
| Foundry | SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry FastIron Network Devices |
| Passport |
| Aironet | SNMP::Info::Layer2::Aironet - SNMP Interface to Cisco Aironet devices running IOS. |
| Allied | SNMP::Info::Layer2::Allied - SNMP Interface to Allied Telesyn switches |
| Bay | SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network BayStack Switches |
| Baystack | SNMP::Info::Layer2::Baystack - SNMP Interface to Nortel Networks' Baystack Switches |
| C1900 | SNMP::Info::Layer2::C1900 - Perl5 Interface to SNMP data from Cisco Catlyst 1900 Network Switches running CatOS |
| C2900 | SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Switches running IOS |
| Catalyst | SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco Catalyst 5000 series devices. |
| Centillion | SNMP::Info::Layer2::Centillion - SNMP Interface to Nortel Centillion based ATM Switches |
| HP | SNMP::Info::Layer2::HP - SNMP Interface to HP Procurve Switches |
| NAP222x | SNMP::Info::Layer2::nap222x - SNMP Interface to Nortel 2220 Series Access Points |
| Orinoco | SNMP::Info::Layer2::Orinoco - SNMP Interface to Orinoco Series Access Points |
| ZyXEL_DSLAM | SNMP::Info::Layer2::ZyXEL_DSLAM - SNMP Interface to ZyXEL DSLAM |
| Allied | SNMP::Info::Layer1::Allied - SNMP Interface to old Allied Hubs |
| Asante | SNMP::Info::Layer1::Asante - SNMP Interface to old Asante 1012 Hubs |
| Bayhub | SNMP::Info::Layer1::Bayhub - SNMP Interface to Bay / Nortel Hubs |