SNMP::Info - Object Oriented Perl5 Interface to Network devices and MIBs through SNMP.
SNMP::Info - Version 0.7
Max Baker
SNMP::Info was created at UCSC for the netdisco project (www.netdisco.org) and is now maintained by Max Baker.
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"; }
Please direct all support, help, and bug requests to the snmp-info-users Mailing List at http://lists.sourceforge.net/lists/listinfo/snmp-info-users
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.
To use this module, you must have Net-SNMP installed on your system. More specifically you need the Perl modules that come with it.
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.
SNMP
./configure --with-perl-modules
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.
SNMP::Info operates on textual descriptors found in MIBs. MIBs are text databases that are freely and easily obtainable on the Net.
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.
snmpconf
A minimum amount of MIBs to have are the Version 2 MIBs from Cisco, found at
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
You will also need to install some of the version one MIBs from Cisco :
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
There is a problem with the Cisco file CISCO-TC.my which is included from lots of other MIBs. Make the following changes if you run into errors about Unsigned32 in this file.
Unsigned32
Edit /usr/local/share/snmp/mibs/CISCO-TC.my
Comment out line 192 that says SMI Unsigned32 with two dashes.
SMI Unsigned32
-- SMI Unsigned32
Add Unsigned32 to the imports after line 19:
IMPORTS MODULE-IDENTITY, Gauge32, Integer32, Counter64, Unsigned32, FROM SNMPv2-SMI
Some non-cisco subclasses will need MIBs other than the basic one available from Cisco.
Check below under each subclass for requirements.
All values are retrieved via MIB Leaf node names
For example SNMP::Info has an entry in its %GLOBALS hash for ``sysName'' instead of 1.3.6.1.2.1.1.5.
Data returned is in the enumerated value form.
For Example instead of looking up 1.3.6.1.2.1.2.2.1.3 and getting back 23
23
SNMP::Info will ask for RFC1213-MIB::ifType and will get back ppp.
RFC1213-MIB::ifType
ppp
You can create a new subclass for a device by providing four hashes : %GLOBALS, %MIBS, %FUNCS, and %MUNGE.
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.
These are the subclasses that implement MIBs and support devices:
Required MIBs not included in the install instructions above are noted here.
These subclasses implement method to access one or more MIBs. These are not used directly, but rather inherited from device subclasses.
BRIDGE-MIB (RFC1286). Inherited by devices with Layer2 service.
CISCO-CDP-MIB. Cisco Discovery Protocol (CDP) Support. Inherited by devices serving Layer2 or Layer3.
Provides common interfaces for memory, cpu, and os statistics for Cisco devices. Provides methods for information in : OLD-CISCO-CPU-MIB, CISCO-PROCESS-MIB and CISCO-MEMORY-POOL-MIB
ENTITY-MIB. Used for device info in Cisco and other vendors.
ETHERLIKE-MIB (RFC1398) - Some Layer3 devices implement this MIB, as well as some Aironet Layer 2 devices (non Cisco).
MAU-MIB (RFC2668). Some Layer2 devices use this for extended Ethernet (Media Access Unit) interface information.
These subclasses inherit from one or more classes to provide a common interface to data obtainable from network devices.
Generic Layer1 Device subclass.
Subclass for Allied Telesys Repeaters / Hubs.
Requires ATI-MIB
See SNMP::Info::Layer1::Allied for where to get MIBs required.
Subclass for Asante 1012 Hubs.
Requires ASANTE-HUB1012-MIB
See SNMP::Info::Layer1::Asante for where to get MIBs required.
Generic Layer2 Device subclass.
Bay Networks BayStack switch Support. Provides translation from Bay Network Topology Table information to CDP.
Requires SYNOPTICS-ROOT-MIB and S5-ETH-MULTISEG-TOPOLOGY-MIB
See SNMP::Info::Bay for where to get MIBs required.
Subclass for Cisco Catalyst 1900 and 1900c Devices running CatOS.
Subclass for Cisco Catalyst 2900 devices running IOS.
Subclass for Cisco Catalyst switches running CatOS. These switches usually report a model number that starts with ''wsc''. Note that this class does not support everything that has the name Catalyst.
Subclass for HP Procurve Swithces
Requires HP-ICF-OID and ENTITY-MIB downloaded from HP.
See SNMP::Info::Layer2::HP for more info.
Generic Layer3 and Layer2+3 Device subclass.
Subclass for Cisco Aironet wireless access points (AP).
MIBs for these devices now included in v2.tar.gz available from ftp.cisco.com.
No longer supported.
Subclass for older Foundry Network devices.
Requires FOUNDRY-SN-ROOT-MIB.
See SNMP::Info::Layer3::Foundry for more info.
Subclass for Cisco Catalyst 3550 2/3 switches running IOS.
Thanks for testing and coding help (in no particular order) to : Andy Ford, Brian Wilson, Jean-Philippe Luiggi, Dána Watanabe
Creates a new object and connects via SNMP::Session.
my $info = new SNMP::Info( 'Debug' => 1, 'AutoSpecify' => 1, 'BigInt' => 1 'DestHost' => 'myrouter', 'Community' => 'public', 'Version' => 2 ) or die;
SNMP::Info Specific Arguments :
AutoSpecify = Returns an object of a more specific device class *See specify() entry* Debug = Prints Lots of debugging messages Session = SNMP::Session object to use instead of connecting on own. BigInt = Return Math::BigInt objects for 64 bit counters. Sets on a global scope, not object. RetryNoSuch = When using SNMP Version 1, try reading values even if they come back as "no such variable in this MIB". Defaults to true, set to false if so desired. This feature lets you read SNMPv2 data from an SNMP version 1 connection, and should probably be left on.
All other arguments are passed to SNMP::Session.
See SNMP::Session for a list of other possible arguments.
A Note about the wrong Community string or wrong SNMP Version :
If a connection is using the wrong community string or the wrong SNMP version, the creation of the object will not fail. The device still answers the call on the SNMP port, but will not return information. Check the error() method after you create the device object to see if there was a problem in connecting.
A note about SNMP Versions :
Some older devices don't support SNMP version 2, and will not return anything when a connection under Version 2 is attempted.
Some newer devices will support Version 1, but will not return all the data they might have if you had connected under Version 1
When trying to get info from a new device, you may have to try version 2 and then fallback to version 1.
Methods and subroutines requesting data from a device will only load the data once, and then return cached versions of that data.
Run $info->load_METHOD() where method is something like 'i_name' to reload data from a table method.
Run $info->clear_cache() to clear the cache to allow reload of both globals and table methods.
These are for package related data, not direcly supplied from SNMP.
Clears the cached data. This includes GLOBALS data and TABLE METHOD data.
Returns current debug status, and optionally toggles debugging info for this object.
Returns the Subclass name for this device. SNMP::Info is returned if no more specific class is available.
SNMP::Info
First the device is checked for Layer 3 support and a specific subclass, then Layer 2 support and subclasses are checked for.
This means that Layer 2 / 3 switches and routers will fall under the SNMP::Info::Layer3 subclasses.
If the device still can be connected to via SNMP::Info, then SNMP::Info is returned.
Algorithm for Subclass Detection:
Layer3 Support -> SNMP::Info::Layer3 Aironet (non IOS) -> SNMP::Info::Layer3::Aironet Catalyst 3550 -> SNMP::Info::Layer3::C3550 Catalyst 6500 -> SNMP::Info::Layer3::C6500 Foundry -> SNMP::Info::Layer3::Foundry Elsif Layer2 (no Layer3) -> SNMP::Info::Layer2 Aironet (Cisco) AP1100 -> SNMP::Info::Layer2::Aironet Bay Networks -> SNMP::Info::Layer2::Bay Catalyst 1900 -> SNMP::Info::Layer2::C1900 Catalyst 2900XL/2950(IOS) -> SNMP::Info::Layer2::C2900 Catalyst 3550/3548 -> SNMP::Info::Layer3::C3550 Catalyst WS-C 2926,5xxx -> SNMP::Info::Layer2::Catalyst HP Procurve -> SNMP::Info::Layer2::HP Elsif Layer1 Support -> SNMP::Info::Layer1 Allied -> SNMP::Info::Layer1::Allied Asante -> SNMP::Info::Layer1::Asante Else -> SNMP::Info
Returns Error message if there is an error, or undef if there is not.
Reading the error will clear the error unless you set the no_clear flag.
Returns non-zero if the device has the supplied layer in the OSI Model
Returns undef if the device doesn't support the layers() call.
undef
Returns SNMP Community string used in conncetion
Returns SNMP Version used for this connection
Returns an object of a more-specific subclass.
my $info = new SNMP::Info(...); # Returns more specific object type $info = $info->specific();
Usually this method is called internally from new(AutoSpecify => 1)
See device_type() entry for how a subclass is chosen.
These are methods to return scalar data from RFC1213.
Some subset of these is probably available for any network device that speaks SNMP.
Uptime in hundreths of seconds since device became available.
(sysUpTime)
(sysContact)
(sysName)
(sysLocation)
This returns a binary encoded string where each digit represents a layer of the OSI model served by the device.
eg: 01000010 means layers 2 (physical) and 7 (Application) are served.
Note: This string is 8 digits long.
See $info->has_layer()
(sysServices)
Number of interfaces available on this device.
Not too useful as the number of SNMP interfaces usually does not correspond with the number of physical ports
(ifNumber)
Each of these methods returns a hash_reference to a hash keyed on the interface index in SNMP.
Example : $info->interfaces() might return
{ '1.12' => 'FastEthernet/0', '2.15' => 'FastEthernet/1', '9.99' => 'FastEthernet/2' }
The key is what you would see if you were to do an snmpwalk, and in some cases changes between reboots of the network device.
If you want to get only a part of an SNMP table and you know the IID for the part of the table that you want, you can specify it in the call:
$local_routes = $info->ipr_route('192.168.0');
This will only fetch entries in the table that start with 192.168.0, which in this case are routes on the local network.
192.168.0
Remember that you must supply the partial IID (a numeric OID).
Partial table results are not cached.
This methods is overriden in each subclass to provide a mapping between the Interface Table Index (iid) and the physical port name.
Returns a reference to a hash where key values that exist are interfaces to ignore.
Ignored interfaces are ones that are usually not physical ports or Virtual Lans (VLANs) such as the Loopback interface, or the CPU interface.
Default SNMP IID to Interface index.
(ifIndex)
Description of the interface. Usually a little longer single word name that is both human and machine friendly. Not always.
(ifDescr)
Interface type, such as Vlan, 10baseT, Ethernet, Serial
(ifType)
INTEGER. Interface MTU value.
(ifMtu)
Speed of the link, human format. See munge_speed() later in document for details.
(ifSpeed)
MAC address of the interface. Note this is just the MAC of the port, not anything connected to it.
(ifPhysAddress)
Link Status of the interface. Typical values are 'up' and 'down'.
(ifOperStatus)
Administrative status of the port. Typical values are 'enabled' and 'disabled'.
(ifAdminStatus)
Interface Name field. Supported by a smaller subset of devices, this fields is often human set.
(ifName)
Interface Name field. For certain devices this is a more human friendly form of i_description(). For others it is a human set field like i_name().
(ifAlias)
Bandwidth.
Number of octets sent/received on the interface including framing characters.
64 bit version may not exist on all devices.
NOTE: To manipulate 64 bit counters you need to use Math::BigInt, since the values are too large for a normal Perl scalar. Set the global $SNMP::Info::BIGINT to 1 , or pass the BigInt value to new() if you want SNMP::Info to do it for you.
(ifInOctets) (ifOutOctets) (ifHCInOctets) (ifHCOutOctets)
Number of packets that contained an error prventing delivery. See IF-MIB for more info.
(ifInErrors) (ifOutErrors)
Number of packets not sent to a multicast or broadcast address.
(ifInUcastPkts) (ifOutUcastPkts) (ifHCInUcastPkts) (ifHCOutUcastPkts)
Number of packets sent to a multicast or broadcast address.
These methods are depricated by i_pkts_multi_in() and i_pkts_bcast_in() according to IF-MIB. Actual device usage may vary.
(ifInNUcastPkts) (ifOutNUcastPkts)
Number of packets sent to a multicast address.
(ifInMulticastPkts) (ifOutMulticastPkts) (ifHCInMulticastPkts) (ifHCOutMulticastPkts)
Number of packets sent to a broadcast address on an interface.
(ifInBroadcastPkts) (ifOutBroadcastPkts) (ifHCInBroadcastPkts) (ifHCOutBroadcastPkts)
Each entry in this table is an IP address in use on this device. Usually this is implemented in Layer3 Devices.
Maps the IP Table to the IID
(ipAdEntIfIndex)
Maps the Table to the IP address
(ipAdEntAddr)
Gives netmask setting for IP table entry.
(ipAdEntNetMask)
Gives broadcast address for IP table entry.
(ipAdEntBcastAddr)
The route in question. A value of 0.0.0.0 is the default gateway route.
(ipRouteDest)
ipRouteDest
The interface (IID) that the route is on. Use interfaces() to map.
(ipRouteIfIndex)
ipRouteIfIndex
Primary routing metric for this route.
(ipRouteMetric1)
ipRouteMetric1
If metrics are not used, they should be set to -1
(ipRouteMetric2)
ipRouteMetric2
(ipRouteMetric3)
ipRouteMetric3
(ipRouteMetric4)
ipRouteMetric4
(ipRouteMetric5)
ipRouteMetric5
From RFC1213:
"The IP address of the next hop of this route. (In the case of a route bound to an interface which is realized via a broadcast media, the value of this field is the agent's IP address on that interface.)"
(ipRouteNextHop)
ipRouteNextHop
other(1), -- none of the following invalid(2), -- an invalidated route -- route to directly direct(3), -- connected (sub-)network -- route to a non-local indirect(4) -- host/network/sub-network "The type of route. Note that the values direct(3) and indirect(4) refer to the notion of direct and indirect routing in the IP architecture. Setting this object to the value invalid(2) has the effect of invalidating the corresponding entry in the ipRouteTable object. That is, it effectively disassociates the destination identified with said entry from the route identified with said entry. It is an implementation-specific matter as to whether the agent removes an invalidated entry from the table. Accordingly, management stations must be prepared to receive tabular information from agents that corresponds to entries not currently in use. Proper interpretation of such entries requires examination of the relevant ipRouteType object."
(ipRouteType)
ipRouteType
other(1), -- none of the following -- non-protocol information, -- e.g., manually configured local(2), -- entries -- set via a network netmgmt(3), -- management protocol -- obtained via ICMP, icmp(4), -- e.g., Redirect -- the remaining values are -- all gateway routing -- protocols egp(5), ggp(6), hello(7), rip(8), is-is(9), es-is(10), ciscoIgrp(11), bbnSpfIgp(12), ospf(13), bgp(14)
(ipRouteProto)
ipRouteProto
Seconds since route was last updated or validated.
(ipRouteAge)
ipRouteAge
Subnet Mask of route. 0.0.0.0 for default gateway.
(ipRouteMask)
ipRouteMask
Reference to MIB definition specific to routing protocol.
(ipRouteInfo)
ipRouteInfo
This section explains how to use SNMP::Info to do SNMP Set operations.
Sets the global METHOD to value. Assumes that iid is .0
Returns undef if failed, or the return value from SNMP::Session::set() (snmp_errno)
$info->set_location("Here!");
Table Methods. Set iid of method to value.
# Disable a port administratvely my %if_map = reverse %{$info->interfaces()} $info->set_i_up_admin('down', $if_map{'FastEthernet0/0') or die "Couldn't disable the port. ",$info->error(1);
NOTE: You must be connected to your device with a ReadWrite community string in order for set operations to work.
NOTE: This will only set data listed in %FUNCS and %GLOBALS. For data aquired from overriden methods (subroutines) specific set_METHOD() subroutines will need to be added.
SNMP::Info will not chirp anything to STDOUT unless there is a serious error (in which case it will probably die).
To get lots of debug info, set the Debug flag when calling new() or call $info->debug(1);
When calling a method check the return value. If the return value is undef then check $info->error()
Beware, calling $info->error() clears the error.
my $name = $info->name() or die "Couldn't get sysName!" . $name->error();
A class inheriting this class must implement these data structures :
Used to flag if the MIBs have been loaded yet.
Contains a hash in the form ( method_name => SNMP iid name ) These are scalar values such as name,uptime, etc.
When choosing the name for the methods, be aware that other new Sub Modules might inherit this one to get it's features. Try to choose a prefix for methods that will give it's own name space inside the SNMP::Info methods.
Contains a hash in the form ( method_name => SNMP iid) These are table entries, such as the IfIndex
A list of each mib needed.
('MIB-NAME' => 'itemToTestForPresence')
The value for each entry should be a MIB object to check for to make sure that the MIB is present and has loaded correctly.
$info->init() will throw an exception if a MIB does not load.
A map between method calls (from %FUNCS or %GLOBALS) and subroutine methods. The subroutine called will be passed the data as it gets it from SNMP and it should return that same data in a more human friendly format.
Sample %MUNGE:
(my_ip => \&munge_ip, my_mac => \&munge_mac, my_layers => \&munge_dec2bin )
Let's make a sample Layer 2 Device subclass :
----------------------- snip --------------------------------
# SNMP::Info::Layer2::Sample package SNMP::Info::Layer2::Sample; $VERSION = 0.1; use strict; use Exporter; use SNMP::Info::Layer2; @SNMP::Info::Layer2::Sample::ISA = qw/SNMP::Info::Layer2 Exporter/; @SNMP::Info::Layer2::Sample::EXPORT_OK = qw//; use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/; %MIBS = (%SNMP::Info::Layer2::MIBS, 'SUPER-DOOPER-MIB' => 'supermibobject' ); %GLOBALS = (%SNMP::Info::Layer2::GLOBALS, 'name' => 'supermib_supername', 'favorite_color' => 'supermib_fav_color_object', 'favorite_movie' => 'supermib_fav_movie_val' ); %FUNCS = (%SNMP::Info::Layer2::FUNCS, # Super Dooper MIB - Super Hero Table 'super_hero_index' => 'SuperHeroIfIndex', 'super_hero_name' => 'SuperHeroIfName', 'super_hero_powers' => 'SuperHeroIfPowers' ); %MUNGE = (%SNMP::Info::Layer2::MUNGE, 'super_hero_powers' => \&munge_powers ); # OverRide uptime() method from %SNMP::Info::GLOBALS sub uptime { my $sample = shift; my $name = $sample->name(); # this is silly but you get the idea return '600' if defined $name ; } # Create our own munge function sub munge_powers { my $power = shift; # Take the returned obscure value and return something useful. return 'Fire' if $power =~ /reallyhot/i; return 'Ice' if $power =~ /reallycold/i; # Else return $power; } # Copious Documentation here!!! =head1 NAME =head1 AUTHOR =head1 SYNOPSIS =head1 DESCRIPTION =head2 Inherited Classes =head2 Required MIBs =head1 GLOBALS =head2 Overrides =head1 TABLE METHODS =head2 Overrides =cut 1; # don't forget this line ----------------------- snip --------------------------------
Be sure and send the debugged version to snmp@warped.org to be included in the next version of SNMP::Info.
Internal data is stored with bareword keys. For example $info->{debug}
SNMP Data is stored or marked cached with keys starting with an underscore. For example $info->{_name} is the cache for $info->name().
Cached Table data is stored in $info->store() and marked cached per above.
These set the default value for an object upon creation.
Default 0. Sends copious debug info to stdout. This global sets the object's debug status in new() unless 'Debug' argument passed in new(). Change objects' debug status with $info->debug().
Default 0. Set to true to have 64 bit counters return Math::BigInt objects instead of scalar string values. See note under Interface Statistics about 64 bit values.
Default 1. Set to false to disable RetryNoSuch option for SNMP::Session. Or see method in new() to do it on an object scope.
Makes human friendly speed ratings using %SPEED_MAP
%SPEED_MAP = ( '56000' => '56 kbps', '64000' => '64 kbps', '1500000' => '1.5 Mbps', '1536000' => 'T1', '1544000' => 'T1', '2000000' => '2.0 Mbps', '2048000' => '2.048 Mbps', '3072000' => 'Dual T1', '3088000' => 'Dual T1', '4000000' => '4.0 Mbps', '10000000' => '10 Mbps', '11000000' => '11 Mbps', '20000000' => '20 Mbps', '16000000' => '16 Mbps', '44736000' => 'T3', '45000000' => '45 Mbps', '45045000' => 'DS3', '64000000' => '64 Mbps', '100000000' => '100 Mbps', '149760000' => 'ATM on OC-3', '155000000' => 'OC-3', '155519000' => 'OC-3', '155520000' => 'OC-3', '400000000' => '400 Mbps', '599040000' => 'ATM on OC-12', '622000000' => 'OC-12', '622080000' => 'OC-12', '1000000000' => '1.0 Gbps', )
Takes a binary IP and makes it dotted ASCII
Takes an octet stream (HEX-STRING) and returns a colon separated ASCII hex string.
Takes a binary octet stream and returns an ASCII hex string
Takes a binary char and returns its ASCII binary representation
Takes a SNMP2 'BITS' field and returns the ASCII bit string
If $BIGINT is set to true, then a Math::BigInt object is returned. See Math::BigInt for details.
Used internally. Loads all entries in %MIBS.
Returns a reference to the argument hash supplied to SNMP::Session
Returns the class name of the object.
Stores the error message for use by $info->error()
If $info->debug() is true, then the error message is carped too.
Returns a reference to the %FUNCS hash.
Returns a reference to the %GLOBALS hash.
Returns a reference to the %MIBS hash.
Returns a reference ot the %MUNGE hash.
Returns NoSuch value set or not in new()
Gets or Sets the SNMP::Session object.
Returns or sets hash store for Table functions.
Store is a hash reference in this format :
$info->store = { attribute => { iid => value , iid2 => value2, ... } };
Used internally by AUTOLOAD to load dynmaic methods from %GLOBALS.
Example: $info->name() calls autoload which calls $info->_global('name').
Used internally by AUTOLOAD to run an SNMP set command for dynamic methods listed in either %GLOBALS or %FUNCS.
Example: $info->set_name('dog',3) uses autoload to resolve to $info->_set('name','dog',3);
Debugging routine. This does not include any overriden method or method implemented by subroutine.
Runs $info->load_METHOD() for each entry in $info->funcs();
Returns $info->store() -- See store() entry.
Note return value has changed since version 0.3
Runs $info->load_all() once then returns $info->store();
Use $info->load_all() to reload the data.
Used internally by AUTOLOAD to fetch data called from methods listed in %FUNCS.
Called from $info->load_METHOD();
Used internaly by AUTOLOAD to return data called by methods listed in %FUNCS.
Called like $info->METHOD().
The first time ran, it will call $info->load_METHOD(). Every time after it will return cached data.
Each entry in either %FUNCS or %GLOBALS is used by AUTOLOAD() to create dynamic methods.
Note that this AUTOLOAD is going to be run for all the classes listed in the @ISA array in a subclass, so will be called with a variety of package names. We check the %FUNCS and %GLOBALS of the package that is doing the calling at this given instant.
Override any dynamic method listed in one of these hashes by creating a subroutine with the same name.
For example to override $info->name() create `` sub name {...}'' in your subclass.
Portions Copyright (c) 2003 Max Baker - All rights reserved.
Original Code Copyright (c) 2002-3, Regents of the University of California All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Santa Cruz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Dána'. Assuming CP1252
To install SNMP::Info, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SNMP::Info
CPAN shell
perl -MCPAN -e shell install SNMP::Info
For more information on module installation, please visit the detailed CPAN module installation guide.