added more serial() support for L2 and L3
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
|
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
|
||||||
# Max Baker <max@warped.org>
|
# Max Baker <max@warped.org>
|
||||||
#
|
#
|
||||||
|
# Copyright (c) 2004 Max Baker -- All changes from Version 0.7 on
|
||||||
|
#
|
||||||
# Copyright (c) 2002,2003 Regents of the University of California
|
# Copyright (c) 2002,2003 Regents of the University of California
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
@@ -28,7 +30,7 @@
|
|||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
package SNMP::Info::Layer2;
|
package SNMP::Info::Layer2;
|
||||||
$VERSION = 0.7;
|
$VERSION = 0.8;
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -57,6 +59,7 @@ $INIT = 0;
|
|||||||
%SNMP::Info::CiscoStats::MIBS,
|
%SNMP::Info::CiscoStats::MIBS,
|
||||||
'CISCO-PRODUCTS-MIB' => 'sysName', # for model()
|
'CISCO-PRODUCTS-MIB' => 'sysName', # for model()
|
||||||
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
|
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
|
||||||
|
'ENTITY-MIB' => 'entPhysicalName', # for serial stuff
|
||||||
);
|
);
|
||||||
|
|
||||||
%GLOBALS = (
|
%GLOBALS = (
|
||||||
@@ -64,6 +67,7 @@ $INIT = 0;
|
|||||||
%SNMP::Info::Bridge::GLOBALS,
|
%SNMP::Info::Bridge::GLOBALS,
|
||||||
%SNMP::Info::CDP::GLOBALS,
|
%SNMP::Info::CDP::GLOBALS,
|
||||||
%SNMP::Info::CiscoStats::GLOBALS,
|
%SNMP::Info::CiscoStats::GLOBALS,
|
||||||
|
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
|
||||||
);
|
);
|
||||||
|
|
||||||
%FUNCS = (
|
%FUNCS = (
|
||||||
@@ -71,6 +75,8 @@ $INIT = 0;
|
|||||||
%SNMP::Info::Bridge::FUNCS,
|
%SNMP::Info::Bridge::FUNCS,
|
||||||
%SNMP::Info::CDP::FUNCS,
|
%SNMP::Info::CDP::FUNCS,
|
||||||
%SNMP::Info::CiscoStats::FUNCS,
|
%SNMP::Info::CiscoStats::FUNCS,
|
||||||
|
'ent_serial' => 'entPhysicalSerialNum',
|
||||||
|
'ent_chassis'=> 'entPhysicalDescr',
|
||||||
);
|
);
|
||||||
|
|
||||||
%MUNGE = (
|
%MUNGE = (
|
||||||
@@ -116,6 +122,25 @@ sub vendor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub serial {
|
||||||
|
my $l2 = shift;
|
||||||
|
|
||||||
|
my $serial1 = $l2->serial1();
|
||||||
|
my $ent_chassis = $l2->ent_chassis() || {};
|
||||||
|
my $ent_serial = $l2->ent_serial() || {};
|
||||||
|
|
||||||
|
my $serial2 = $ent_serial->{1} || undef;
|
||||||
|
my $chassis = $ent_chassis->{1} || undef;
|
||||||
|
|
||||||
|
# precedence
|
||||||
|
# serial2,chassis parse,serial1
|
||||||
|
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
|
||||||
|
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
|
||||||
|
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
sub i_ignore {
|
sub i_ignore {
|
||||||
my $l2 = shift;
|
my $l2 = shift;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# SNMP::Info::Layer3 - SNMP Interface to Layer3 devices
|
# SNMP::Info::Layer3 - SNMP Interface to Layer3 devices
|
||||||
# Max Baker <max@warped.org>
|
# Max Baker <max@warped.org>
|
||||||
#
|
#
|
||||||
|
# Copyright (c) 2004 Max Baker -- All changes from Version 0.7 on
|
||||||
|
#
|
||||||
# Copyright (c) 2002,2003 Regents of the University of California
|
# Copyright (c) 2002,2003 Regents of the University of California
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
@@ -28,7 +30,7 @@
|
|||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
package SNMP::Info::Layer3;
|
package SNMP::Info::Layer3;
|
||||||
$VERSION = 0.7;
|
$VERSION = 0.8;
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -69,7 +71,7 @@ $INIT = 0;
|
|||||||
%SNMP::Info::Bridge::GLOBALS,
|
%SNMP::Info::Bridge::GLOBALS,
|
||||||
%SNMP::Info::EtherLike::GLOBALS,
|
%SNMP::Info::EtherLike::GLOBALS,
|
||||||
'mac' => 'ifPhysAddress.1',
|
'mac' => 'ifPhysAddress.1',
|
||||||
'chassis' => 'entPhysicalDescr.1',
|
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
|
||||||
'router_ip' => 'ospfRouterId.0',
|
'router_ip' => 'ospfRouterId.0',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -85,7 +87,9 @@ $INIT = 0;
|
|||||||
'at_index' => 'atIfIndex',
|
'at_index' => 'atIfIndex',
|
||||||
'at_paddr' => 'atPhysAddress',
|
'at_paddr' => 'atPhysAddress',
|
||||||
'at_netaddr' => 'atNetAddress',
|
'at_netaddr' => 'atNetAddress',
|
||||||
'ospf_ip' => 'ospfHostIpAddress'
|
'ospf_ip' => 'ospfHostIpAddress',
|
||||||
|
'ent_serial' => 'entPhysicalSerialNum',
|
||||||
|
'ent_chassis'=> 'entPhysicalDescr',
|
||||||
);
|
);
|
||||||
|
|
||||||
%MUNGE = (
|
%MUNGE = (
|
||||||
@@ -138,10 +142,20 @@ sub i_ignore {
|
|||||||
sub serial {
|
sub serial {
|
||||||
my $l3 = shift;
|
my $l3 = shift;
|
||||||
|
|
||||||
my $chassis = $l3->chassis();
|
my $serial1 = $l3->serial1();
|
||||||
|
my $ent_chassis = $l3->ent_chassis() || {};
|
||||||
|
my $ent_serial = $l3->ent_serial() || {};
|
||||||
|
|
||||||
|
my $serial2 = $ent_serial->{1} || undef;
|
||||||
|
my $chassis = $ent_chassis->{1} || undef;
|
||||||
|
|
||||||
|
# precedence
|
||||||
|
# serial2,chassis parse,serial1
|
||||||
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
|
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
|
||||||
|
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
|
||||||
|
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
|
||||||
|
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
# $l3->model() - the sysObjectID returns an IID to an entry in
|
# $l3->model() - the sysObjectID returns an IID to an entry in
|
||||||
|
|||||||
Reference in New Issue
Block a user