SNMP::Info

SNMP::Info is a Perl5 Module that provides an object-oriented interface to Network Devices and data stored in SNMP MIBs.

Links

Download Device Compatibility Matrix Support Synopsis Documentation

Source Forge Project Page Netdisco Source Code CPAN

Credits

Fiat Slug
SNMP::Info was created at UCSC for the netdisco project (www.netdisco.org) and was originally written by Max Baker (maxbaker)

Currently being maintained by team of Open Source authors headed by:
Eric Miller, Bill Fenner, Max Baker, Jeroen van Ingen, Carlos Vicente, Brian de Wolf and Oliver Gorwits.

Support

Please direct all support, help, and bug requests to the SNMP::Info Mailling List

Documentation and SubClasses

Please see the CPAN Documentation for details.

Synopsis

 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};

    print "$port: ";
    print "$duplex duplex" if defined $duplex;

    # 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};
    unless (defined $c_key) {
         print "\n\n";
         next;
     }
    my $neighbor_ip   = $c_ip->{$c_key};
    my $neighbor_port = $c_port->{$c_key};

    print " connected to $neighbor_ip / $neighbor_port\n" if defined $neighbor_ip;
    print "\n";

 }
Hosted by SourceForge.net Logo