documentation

This commit is contained in:
Eric Miller
2006-01-24 20:47:58 +00:00
parent 558c80aa84
commit 8846bb2f0f

86
Info.pm
View File

@@ -208,6 +208,11 @@ For more info run C<perldoc> on any of the following module names.
=over =over
=item SNMP::Info::Airespace
AIRESPACE-WIRELESS-MIB and AIRESPACE-SWITCHING-MIB. Inherited by devices based
on the Airespace wireless platform.
=item SNMP::Info::Bridge =item SNMP::Info::Bridge
BRIDGE-MIB (RFC1286). QBRIDGE-MIB. Inherited by devices with Layer2 support. BRIDGE-MIB (RFC1286). QBRIDGE-MIB. Inherited by devices with Layer2 support.
@@ -285,23 +290,17 @@ Subclass for Allied Telesys Repeaters / Hubs.
Requires ATI-MIB Requires ATI-MIB
See SNMP::Info::Layer1::Allied for where to get MIBs required.
=item SNMP::Info::Layer1::Asante =item SNMP::Info::Layer1::Asante
Subclass for Asante 1012 Hubs. Subclass for Asante 1012 Hubs.
Requires ASANTE-HUB1012-MIB Requires ASANTE-HUB1012-MIB
See SNMP::Info::Layer1::Asante for where to get MIBs required.
=item SNMP::Info::Layer1::Bayhub =item SNMP::Info::Layer1::Bayhub
Subclass for Nortel/Bay hubs. This includes System 5000, 100 series, Subclass for Nortel/Bay hubs. This includes System 5000, 100 series,
200 series, and probably more. 200 series, and probably more.
See SNMP::Info::Layer1::Bayhub for where to get MIBs required.
=back =back
=item SNMP::Info::Layer2 =item SNMP::Info::Layer2
@@ -333,8 +332,6 @@ Subclass for Nortel/Bay Baystack switches. This includes 303, 304, 350, 380,
410, 420, 425, 450, 460, 470, 5510, 5520, Business Policy Switch (BPS) and 410, 420, 425, 450, 460, 470, 5510, 5520, Business Policy Switch (BPS) and
probably others. probably others.
See SNMP::Info::Layer2::Baystack for where to get MIBs required.
=item SNMP::Info::Layer2::C1900 =item SNMP::Info::Layer2::C1900
Subclass for Cisco Catalyst 1900 and 1900c Devices running CatOS. Subclass for Cisco Catalyst 1900 and 1900c Devices running CatOS.
@@ -353,14 +350,10 @@ does not support everything that has the name Catalyst.
Subclass for Nortel/Bay Centillion and 5000BH ATM switches. Subclass for Nortel/Bay Centillion and 5000BH ATM switches.
See SNMP::Info::Layer2::Centillion for where to get MIBs required.
=item SNMP::Info::Layer2::Foundry =item SNMP::Info::Layer2::Foundry
Subclass for Foundry Switches. Tested on EdgeIron 24G. Subclass for Foundry Switches. Tested on EdgeIron 24G.
See SNMP::Info::Layer2::Foundry for where to get MIBs required.
=item SNMP::Info::Layer2::HP =item SNMP::Info::Layer2::HP
Subclass for HP Procurve Switches Subclass for HP Procurve Switches
@@ -369,11 +362,13 @@ Requires HP-ICF-OID and ENTITY-MIB downloaded from HP.
See SNMP::Info::Layer2::HP for more info. See SNMP::Info::Layer2::HP for more info.
=item SNMP::Info::Layer2::N2270
Subclass for Nortel 2270 wireless switches.
=item SNMP::Info::Layer2::NAP222x =item SNMP::Info::Layer2::NAP222x
Subclass for Nortel Networks' 222x series wireless access points. Subclass for Nortel 222x series wireless access points.
See SNMP::Info::Layer2::NAP222x for where to get MIBs required.
=item SNMP::Info::Layer2::Orinoco =item SNMP::Info::Layer2::Orinoco
@@ -404,15 +399,11 @@ Note Layer2::Aironet
Subclass for Nortel Networks' Alteon Ace Director series L2-7 switches. Subclass for Nortel Networks' Alteon Ace Director series L2-7 switches.
See SNMP::Info::Layer3::AlteonAD for where to get MIBs required.
=item SNMP::Info::Layer3::BayRS =item SNMP::Info::Layer3::BayRS
Subclass for Nortel Networks' BayRS routers. This includes BCN, BLN, ASN, ARN, Subclass for Nortel Networks' BayRS routers. This includes BCN, BLN, ASN, ARN,
and AN routers. and AN routers.
See SNMP::Info::Layer3::BayRS for where to get MIBs required.
=item SNMP::Info::Layer3::C3550 =item SNMP::Info::Layer3::C3550
Subclass for Cisco Catalyst 3550,3540,3560 2/3 switches running IOS. Subclass for Cisco Catalyst 3550,3540,3560 2/3 switches running IOS.
@@ -430,8 +421,6 @@ This is a simple wrapper around Layer3 for IOS devices. It adds on CiscoVTP.
Subclass for Nortel Networks' Contivity VPN concentrators. Subclass for Nortel Networks' Contivity VPN concentrators.
See SNMP::Info::Layer3::Contivity for where to get MIBs required.
=item SNMP::Info::Layer3::Extreme =item SNMP::Info::Layer3::Extreme
Subclass for Extreme Networks switches. Subclass for Extreme Networks switches.
@@ -450,14 +439,10 @@ See SNMP::Info::Layer3::Foundry for more info.
Subclass for Nortel Passport 8000 series and Accelar series switches. Subclass for Nortel Passport 8000 series and Accelar series switches.
See SNMP::Info::Layer3::Passport for where to get MIBs required.
=item SNMP::Info::Layer3::N1600 =item SNMP::Info::Layer3::N1600
Subclass for Nortel 1600 series switches. Subclass for Nortel 1600 series switches.
See SNMP::Info::Layer3::N1600 for where to get MIBs required.
=back =back
=back =back
@@ -580,6 +565,7 @@ When trying to get info from a new device, you may have to try version 2 and the
version 1. version 1.
=cut =cut
sub new { sub new {
my $proto = shift; my $proto = shift;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
@@ -707,6 +693,7 @@ from SNMP.
Clears the cached data. This includes GLOBALS data and TABLE METHOD data. Clears the cached data. This includes GLOBALS data and TABLE METHOD data.
=cut =cut
sub clear_cache { sub clear_cache {
my $self = shift; my $self = shift;
@@ -728,6 +715,7 @@ sub clear_cache {
Returns current debug status, and optionally toggles debugging info for this object. Returns current debug status, and optionally toggles debugging info for this object.
=cut =cut
sub debug { sub debug {
my $self = shift; my $self = shift;
my $debug = shift; my $debug = shift;
@@ -746,6 +734,7 @@ Returns if bulkwalk is currently turned on for this object.
Optionally sets the bulkwalk parameter. Optionally sets the bulkwalk parameter.
=cut =cut
sub bulkwalk { sub bulkwalk {
my $self = shift; my $self = shift;
my $bw = shift; my $bw = shift;
@@ -810,6 +799,7 @@ Algorithm for Subclass Detection:
Aruba wireless -> SNMP::Info::Layer2::Aruba Aruba wireless -> SNMP::Info::Layer2::Aruba
=cut =cut
sub device_type { sub device_type {
my $info = shift; my $info = shift;
@@ -950,6 +940,7 @@ 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. Reading the error will clear the error unless you set the no_clear flag.
=cut =cut
sub error { sub error {
my $self = shift; my $self = shift;
my $no_clear = shift; my $no_clear = shift;
@@ -966,6 +957,7 @@ Returns non-zero if the device has the supplied layer in the OSI Model
Returns C<undef> if the device doesn't support the layers() call. Returns C<undef> if the device doesn't support the layers() call.
=cut =cut
sub has_layer { sub has_layer {
my $self = shift; my $self = shift;
my $check_for = shift; my $check_for = shift;
@@ -981,6 +973,7 @@ sub has_layer {
Returns SNMP Community string used in connection. Returns SNMP Community string used in connection.
=cut =cut
sub snmp_comm { sub snmp_comm {
my $self = shift; my $self = shift;
return $self->{snmp_comm}; return $self->{snmp_comm};
@@ -991,6 +984,7 @@ sub snmp_comm {
Returns SNMP Version used for this connection Returns SNMP Version used for this connection
=cut =cut
sub snmp_ver { sub snmp_ver {
my $self = shift; my $self = shift;
return $self->{snmp_ver}; return $self->{snmp_ver};
@@ -1010,6 +1004,7 @@ See device_type() entry for how a subclass is chosen.
=cut =cut
sub specify { sub specify {
my $self = shift; my $self = shift;
@@ -1048,6 +1043,7 @@ snmp calls on certain Cisco devices.
See L<ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html> See L<ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html>
=cut =cut
sub cisco_comm_indexing{ sub cisco_comm_indexing{
0; 0;
} }
@@ -1152,6 +1148,7 @@ Ignored interfaces are ones that are usually not physical ports or Virtual Lans
or the CPU interface. or the CPU interface.
=cut =cut
sub if_ignore { sub if_ignore {
my %nothing; my %nothing;
return \%nothing; return \%nothing;
@@ -1523,6 +1520,7 @@ structures :
Used to flag if the MIBs have been loaded yet. Used to flag if the MIBs have been loaded yet.
=cut =cut
$INIT = 0; $INIT = 0;
=item %GLOBALS =item %GLOBALS
@@ -1536,6 +1534,7 @@ choose a prefix for methods that will give it's own name space inside
the SNMP::Info methods. the SNMP::Info methods.
=cut =cut
%GLOBALS = ( %GLOBALS = (
# from SNMPv2-MIB # from SNMPv2-MIB
'id' => 'sysObjectID', 'id' => 'sysObjectID',
@@ -1554,6 +1553,7 @@ Contains a hash in the form ( method_name => SNMP iid)
These are table entries, such as the IfIndex These are table entries, such as the IfIndex
=cut =cut
%FUNCS = ( %FUNCS = (
'interfaces' => 'ifIndex', 'interfaces' => 'ifIndex',
# from SNMPv2-MIB # from SNMPv2-MIB
@@ -1622,6 +1622,7 @@ that the MIB is present and has loaded correctly.
$info->init() will throw an exception if a MIB does not load. $info->init() will throw an exception if a MIB does not load.
=cut =cut
%MIBS = ( %MIBS = (
# The "main" MIBs are automagically loaded in Net-SNMP now. # The "main" MIBs are automagically loaded in Net-SNMP now.
); );
@@ -1640,6 +1641,7 @@ Sample %MUNGE:
) )
=cut =cut
%MUNGE = ('ip' => \&munge_ip, %MUNGE = ('ip' => \&munge_ip,
'mac' => \&munge_mac, 'mac' => \&munge_mac,
'i_mac' => \&munge_mac, 'i_mac' => \&munge_mac,
@@ -1774,6 +1776,7 @@ in new() unless 'Debug' argument passed in new(). Change objects' debug status
$info->debug(). $info->debug().
=cut =cut
$DEBUG = 0; $DEBUG = 0;
=item $BIGINT =item $BIGINT
@@ -1782,6 +1785,7 @@ Default 0. Set to true to have 64 bit counters return Math::BigInt objects ins
string values. See note under Interface Statistics about 64 bit values. string values. See note under Interface Statistics about 64 bit values.
=cut =cut
$BIGINT = 0; $BIGINT = 0;
=item $NOSUCH =item $NOSUCH
@@ -1790,6 +1794,7 @@ Default 1. Set to false to disable RetryNoSuch option for SNMP::Session. Or se
to do it on an object scope. to do it on an object scope.
=cut =cut
$NOSUCH = 1; $NOSUCH = 1;
=item $REPEATERS =item $REPEATERS
@@ -1798,6 +1803,7 @@ Default 20. MaxRepeaters for BULKWALK operations. See C<perldoc SNMP> for more
by passing L<BulkRepeaters> option in new() by passing L<BulkRepeaters> option in new()
=cut =cut
$REPEATERS = 20; $REPEATERS = 20;
=back =back
@@ -1845,6 +1851,7 @@ Makes human friendly speed ratings using %SPEED_MAP
) )
=cut =cut
%SPEED_MAP = ( %SPEED_MAP = (
'56000' => '56 kbps', '56000' => '56 kbps',
'64000' => '64 kbps', '64000' => '64 kbps',
@@ -1894,6 +1901,7 @@ sub munge_speed {
Takes a binary IP and makes it dotted ASCII Takes a binary IP and makes it dotted ASCII
=cut =cut
sub munge_ip { sub munge_ip {
my $ip = shift; my $ip = shift;
return join('.',unpack('C4',$ip)); return join('.',unpack('C4',$ip));
@@ -1904,6 +1912,7 @@ sub munge_ip {
Takes an octet stream (HEX-STRING) and returns a colon separated ASCII hex string. Takes an octet stream (HEX-STRING) and returns a colon separated ASCII hex string.
=cut =cut
sub munge_mac { sub munge_mac {
my $mac = shift; my $mac = shift;
return undef unless defined $mac; return undef unless defined $mac;
@@ -1916,6 +1925,7 @@ sub munge_mac {
Takes a binary octet stream and returns an ASCII hex string Takes a binary octet stream and returns an ASCII hex string
=cut =cut
sub munge_octet2hex { sub munge_octet2hex {
my $oct = shift; my $oct = shift;
return join('',map {sprintf "%x",$_} unpack('C*',$oct)); return join('',map {sprintf "%x",$_} unpack('C*',$oct));
@@ -1926,6 +1936,7 @@ sub munge_octet2hex {
Takes a binary char and returns its ASCII binary representation Takes a binary char and returns its ASCII binary representation
=cut =cut
sub munge_dec2bin { sub munge_dec2bin {
my $num = shift; my $num = shift;
return undef unless defined $num; return undef unless defined $num;
@@ -1942,6 +1953,7 @@ sub munge_dec2bin {
Takes a SNMP2 'BITS' field and returns the ASCII bit string Takes a SNMP2 'BITS' field and returns the ASCII bit string
=cut =cut
sub munge_bits { sub munge_bits {
my $bits = shift; my $bits = shift;
return undef unless defined $bits; return undef unless defined $bits;
@@ -1949,13 +1961,13 @@ sub munge_bits {
return unpack("b*",$bits); return unpack("b*",$bits);
} }
=item munge_counter64 =item munge_counter64
If $BIGINT is set to true, then a Math::BigInt object is returned. If $BIGINT is set to true, then a Math::BigInt object is returned.
See Math::BigInt for details. See Math::BigInt for details.
=cut =cut
sub munge_counter64 { sub munge_counter64 {
my $counter = shift; my $counter = shift;
return unless defined $counter; return unless defined $counter;
@@ -1975,6 +1987,7 @@ TODO: Get the precidence of MIBs and overriding of MIB data in Net-SNMP
figured out. Heirarchy/precendence of MIBS in SNMP::Info. figured out. Heirarchy/precendence of MIBS in SNMP::Info.
=cut =cut
sub munge_i_up { sub munge_i_up {
my $i_up = shift; my $i_up = shift;
return unless defined $i_up; return unless defined $i_up;
@@ -1995,6 +2008,7 @@ sub munge_i_up {
Used internally. Loads all entries in %MIBS. Used internally. Loads all entries in %MIBS.
=cut =cut
sub init { sub init {
my $self = shift; my $self = shift;
@@ -2038,6 +2052,7 @@ sub init {
Returns a reference to the argument hash supplied to SNMP::Session Returns a reference to the argument hash supplied to SNMP::Session
=cut =cut
sub args { sub args {
my $self = shift; my $self = shift;
return $self->{args}; return $self->{args};
@@ -2048,12 +2063,12 @@ sub args {
Returns the class name of the object. Returns the class name of the object.
=cut =cut
sub class { sub class {
my $self=shift; my $self=shift;
return $self->{class}; return $self->{class};
} }
=item $info->error_throw(error message) =item $info->error_throw(error message)
Stores the error message for use by $info->error() Stores the error message for use by $info->error()
@@ -2061,6 +2076,7 @@ Stores the error message for use by $info->error()
If $info->debug() is true, then the error message is carped too. If $info->debug() is true, then the error message is carped too.
=cut =cut
sub error_throw { sub error_throw {
my $self = shift; my $self = shift;
my $error = shift; my $error = shift;
@@ -2079,6 +2095,7 @@ sub error_throw {
Returns a reference to the %FUNCS hash. Returns a reference to the %FUNCS hash.
=cut =cut
sub funcs { sub funcs {
my $self=shift; my $self=shift;
return $self->{funcs}; return $self->{funcs};
@@ -2089,6 +2106,7 @@ sub funcs {
Returns a reference to the %GLOBALS hash. Returns a reference to the %GLOBALS hash.
=cut =cut
sub globals { sub globals {
my $self=shift; my $self=shift;
return $self->{globals}; return $self->{globals};
@@ -2099,6 +2117,7 @@ sub globals {
Returns a reference to the %MIBS hash. Returns a reference to the %MIBS hash.
=cut =cut
sub mibs { sub mibs {
my $self=shift; my $self=shift;
return $self->{mibs}; return $self->{mibs};
@@ -2109,6 +2128,7 @@ sub mibs {
Returns a reference ot the %MUNGE hash. Returns a reference ot the %MUNGE hash.
=cut =cut
sub munge { sub munge {
my $self=shift; my $self=shift;
return $self->{munge}; return $self->{munge};
@@ -2119,6 +2139,7 @@ sub munge {
Returns NoSuch value set or not in new() Returns NoSuch value set or not in new()
=cut =cut
sub nosuch { sub nosuch {
my $self = shift; my $self = shift;
return $self->{nosuch}; return $self->{nosuch};
@@ -2129,6 +2150,7 @@ sub nosuch {
Gets or Sets the SNMP::Session object. Gets or Sets the SNMP::Session object.
=cut =cut
sub session { sub session {
my $self = shift; my $self = shift;
$self->{sess} = $_[0] if @_; $self->{sess} = $_[0] if @_;
@@ -2144,13 +2166,13 @@ Store is a hash reference in this format :
$info->store = { attribute => { iid => value , iid2 => value2, ... } }; $info->store = { attribute => { iid => value , iid2 => value2, ... } };
=cut =cut
sub store { sub store {
my $self = shift; my $self = shift;
$self->{store} = $_[0] if @_; $self->{store} = $_[0] if @_;
return $self->{store}; return $self->{store};
} }
=item $info->_global() =item $info->_global()
Used internally by AUTOLOAD to load dynamic methods from %GLOBALS. Used internally by AUTOLOAD to load dynamic methods from %GLOBALS.
@@ -2158,6 +2180,7 @@ Used internally by AUTOLOAD to load dynamic methods from %GLOBALS.
Example: $info->name() calls autoload which calls $info->_global('name'). Example: $info->name() calls autoload which calls $info->_global('name').
=cut =cut
sub _global{ sub _global{
my $self = shift; my $self = shift;
my $attr = shift; my $attr = shift;
@@ -2216,6 +2239,7 @@ either %GLOBALS or %FUNCS.
Example: $info->set_name('dog',3) uses autoload to resolve to $info->_set('name','dog',3); Example: $info->set_name('dog',3) uses autoload to resolve to $info->_set('name','dog',3);
=cut =cut
sub _set { sub _set {
my ($self,$attr,$val,$iid) = @_; my ($self,$attr,$val,$iid) = @_;
@@ -2273,6 +2297,7 @@ Returns $info->store() -- See store() entry.
Note return value has changed since version 0.3 Note return value has changed since version 0.3
=cut =cut
sub load_all { sub load_all {
my $self = shift; my $self = shift;
my $sess = $self->session(); my $sess = $self->session();
@@ -2299,6 +2324,7 @@ Use $info->load_all() to reload the data.
Note return value has changed since version 0.3 Note return value has changed since version 0.3
=cut =cut
sub all { sub all {
my $self = shift; my $self = shift;
my $sess = $self->session(); my $sess = $self->session();
@@ -2309,7 +2335,6 @@ sub all {
return $self->store(); return $self->store();
} }
=item $info->_load_attr() =item $info->_load_attr()
Used internally by AUTOLOAD to fetch data called from methods listed in %FUNCS. Used internally by AUTOLOAD to fetch data called from methods listed in %FUNCS.
@@ -2317,6 +2342,7 @@ Used internally by AUTOLOAD to fetch data called from methods listed in %FUNCS.
Called from $info->load_METHOD(); Called from $info->load_METHOD();
=cut =cut
sub _load_attr { sub _load_attr {
my $self = shift; my $self = shift;
my ($attr,$leaf,$partial) = @_; my ($attr,$leaf,$partial) = @_;
@@ -2451,6 +2477,7 @@ The first time ran, it will call $info->load_METHOD().
Every time after it will return cached data. Every time after it will return cached data.
=cut =cut
sub _show_attr { sub _show_attr {
my $self = shift; my $self = shift;
my $attr = shift; my $attr = shift;
@@ -2490,6 +2517,7 @@ the same name.
For example to override $info->name() create `` sub name {...}'' in your subclass. For example to override $info->name() create `` sub name {...}'' in your subclass.
=cut =cut
sub AUTOLOAD { sub AUTOLOAD {
my $self = shift; my $self = shift;
my $sub_name = $AUTOLOAD; my $sub_name = $AUTOLOAD;