Skip to Main Content
Essential SNMP, 2nd Edition
book

Essential SNMP, 2nd Edition

by Douglas Mauro, Kevin Schmidt
September 2005
Beginner content levelBeginner
462 pages
12h 56m
English
O'Reilly Media, Inc.
Content preview from Essential SNMP, 2nd Edition

SNMP: The Object-Oriented Way

The SNMP::Info Perl package was developed at the University of California, Santa Cruz. The official web site for this package is http://snmp-info.sourceforge.net.

SNMP::Info is based on the Net-SNMP Perl module. It allows you to obtain various information from a device without having to know any OIDs, MIBs, etc., and it does so with object orientation (OO). How does it do this? It supports a well-developed list of MIBs, and it can discover the type of device you are trying to query. If it knows about the device, you can use predefined methods to get interface information and other things. Here's an example script that gathers information about interfaces on a switch:

 #!/usr/bin/perl use SNMP::Info; my $info = new SNMP::Info( # Auto Discover more specific Device Class AutoSpecify => 1, Debug => 0, # The rest is passed to SNMP::Session DestHost => '192.168.0.148', 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}; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Essential SNMP

Essential SNMP

Douglas Mauro, Kevin Schmidt
UNIX and Linux System Administration Handbook, 5th Edition

UNIX and Linux System Administration Handbook, 5th Edition

Trent R. Hein, Evi Nemeth, Garth Snyder, Ben Whaley, Dan Mackin

Publisher Resources

ISBN: 0596008406Supplemental ContentErrata Page