Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e52756a41 | ||
|
|
55fc398ddf | ||
|
|
a5e8e6c7cd | ||
|
|
bb8762835f | ||
|
|
7c8b1a8853 | ||
|
|
be8140a142 | ||
|
|
f7c57860b7 | ||
|
|
c44fc3ddbe | ||
|
|
c2fd3bd3a4 | ||
|
|
dfff2624ac | ||
|
|
91c40fddb6 | ||
|
|
cafeb36418 | ||
|
|
fa56c7b332 | ||
|
|
a52f1f3d37 | ||
|
|
476053c539 | ||
|
|
0530c5d9e9 | ||
|
|
b982e95c42 | ||
|
|
de286cbfa0 | ||
|
|
a94c685c6d | ||
|
|
58feb21dec | ||
|
|
81f0b821e3 | ||
|
|
ea8275677b | ||
|
|
c0891ec8c0 | ||
|
|
9dd38845a6 | ||
|
|
0d8aa25e63 | ||
|
|
f57c9333da | ||
|
|
f060b67b4a | ||
|
|
c59e13ac35 | ||
|
|
a49d1522b0 | ||
|
|
39e618f761 | ||
|
|
3d812e0eae | ||
|
|
4f1ac32865 | ||
|
|
d176570b1d | ||
|
|
393fb71b1a | ||
|
|
bd1be7e258 | ||
|
|
e296e93b23 |
16
ChangeLog
16
ChangeLog
@@ -1,6 +1,22 @@
|
||||
SNMP::Info - Perl5 OO Interface to Network Devices and SNMP MIBs
|
||||
ChangeLog $Id$
|
||||
|
||||
version 0.7 ()
|
||||
* Added Class for Catalyst 6500 Series - Layer3::C6500
|
||||
* Added CiscoVTP support to 3550,2900, and Catalyst classes
|
||||
* Extracted VLAN stuff from Layer2::Catalyst to SNMP::Info::CiscoVTP
|
||||
* Extracted CISCO-STACK-MIB from Layer2::Catalyst to SNMP::Info::CiscoStack
|
||||
* Added 2950's to the Layer2::C2900 class
|
||||
* Added 3548's and 350x's to the Layer3::C3550 class
|
||||
* Broke out 3550's into separate device types (3550-24, 3550-48)
|
||||
* Added T1,dual T1, and T3 , ATM over OC-12 ... to the SPEED_MAP
|
||||
* Fixed speed map -- OC-1 -> OC-3
|
||||
* Fixed Bug where Catalyst Switch running IOS would report CatOS as os()
|
||||
|
||||
version 0.6 (06/18/03)
|
||||
* Minor Bug Fix. SNMP::Info::Layer2::Bay and SNMP::Info::Layer2::C1900
|
||||
didn't return 1 and failed to load on some versions of Perl.
|
||||
|
||||
version 0.5 (06/10/03)
|
||||
* Added ability to get paritial tables. For example to get the
|
||||
IP routing table for 128.114.* you can do
|
||||
|
||||
320
DeviceMatrix.txt
Normal file
320
DeviceMatrix.txt
Normal file
@@ -0,0 +1,320 @@
|
||||
# SNMP Device Compatibility Matrix
|
||||
# SNMP::Info - Max Baker
|
||||
|
||||
# This file is meant to detail the cababilities
|
||||
# of network devices to supply data via SNMP.
|
||||
|
||||
# $Id$
|
||||
|
||||
# Allied
|
||||
device-vendor: Allied Telesyn
|
||||
|
||||
device-family: Hubs
|
||||
class: Layer1::Allied
|
||||
ver: 1
|
||||
arpnip: no
|
||||
macsuck: no
|
||||
duplex: no
|
||||
|
||||
device: AT-3624T
|
||||
|
||||
# Asante
|
||||
device-vendor: Asante
|
||||
|
||||
device-family: Hubs
|
||||
class: Layer1::Asante
|
||||
ver: 1
|
||||
arpnip: no
|
||||
macsuck: no
|
||||
duplex: no
|
||||
|
||||
device: 1012
|
||||
|
||||
# Bay
|
||||
device-vendor: Bay Networks
|
||||
class: Layer2::Bay
|
||||
ver: 1
|
||||
|
||||
device-family: BayStack
|
||||
macsuck: yes
|
||||
cdp: proprietary
|
||||
note: SNMP interface does not respond after 2+ months of uptime. Reboot to fix.
|
||||
|
||||
device: 303
|
||||
device: 304
|
||||
device: 450
|
||||
note: Labels full duplex as 20Mbit connection.
|
||||
|
||||
# CISCO
|
||||
device-vendor: Cisco
|
||||
cdp: yes
|
||||
ver: 2
|
||||
note: Error in CISCO-TC-MIB. See README for how to patch.
|
||||
|
||||
device-family: Aironet
|
||||
note: IOS and Aironet OS versions
|
||||
class: Layer3::Aironet
|
||||
|
||||
device: AIRAP1100
|
||||
note: IOS based device
|
||||
class: Layer2::Aironet
|
||||
|
||||
device: AP1200
|
||||
note: Aironet based device
|
||||
|
||||
device: AP350, AP340
|
||||
note: Aironet based device
|
||||
|
||||
device-family: 1000
|
||||
duplex: no
|
||||
ver: 1
|
||||
class: Layer3
|
||||
|
||||
device: 1003
|
||||
|
||||
device-family: 1700
|
||||
class: Layer3
|
||||
|
||||
device: 1710
|
||||
duplex: link
|
||||
|
||||
device-family: 2500
|
||||
duplex: no
|
||||
macsuck: yes
|
||||
arpnip: yes
|
||||
ver: 1
|
||||
class: Layer3
|
||||
|
||||
device: 2501
|
||||
|
||||
device: 2503
|
||||
|
||||
device: AS2509RJ
|
||||
|
||||
device: AS2511RJ
|
||||
|
||||
device: 2511
|
||||
|
||||
device: 2514
|
||||
|
||||
device-family: 2600
|
||||
duplex: link
|
||||
arpnip: yes
|
||||
macsuck: yes
|
||||
class: Layer3
|
||||
|
||||
device:2610
|
||||
|
||||
device:2611
|
||||
|
||||
device:2620
|
||||
|
||||
device:2620XM
|
||||
|
||||
device:2621
|
||||
|
||||
device:2621XM
|
||||
|
||||
device:2651XM
|
||||
|
||||
device-family: 3600
|
||||
class: Layer3
|
||||
|
||||
device: 3620
|
||||
|
||||
device: 3640
|
||||
duplex: no
|
||||
|
||||
device-family: 7500
|
||||
class: Layer3
|
||||
|
||||
device: 7507
|
||||
duplex: no
|
||||
note: !Duplex settings are falsely reported in older IOS versions
|
||||
|
||||
device-family: AS5000
|
||||
duplex: no
|
||||
class: Layer3
|
||||
|
||||
device: AS5300
|
||||
|
||||
#
|
||||
# Cisco - Catalyst
|
||||
#
|
||||
device-family: Catalyst 1900
|
||||
note: !Upgrade older (pre 9.0) versions of CatOS
|
||||
ver: 1
|
||||
class: Layer2::C1900
|
||||
|
||||
device: wsc1900c
|
||||
device-family: Catalyst 1900
|
||||
|
||||
device: wsc1900
|
||||
device-family: Catalyst 1900
|
||||
|
||||
device-family: Catalyst 2900
|
||||
note: IOS
|
||||
macsuck: vlan
|
||||
class: Layer3::C2900
|
||||
portmac: yes
|
||||
note: !Pre IOS 11.2 (8) SA3 - PortMAC shows up in CAM table.
|
||||
|
||||
device: 2908xl
|
||||
note: !Pre IOS 11.2 (8.6) some features (duplex...) aren't present.
|
||||
|
||||
device: 2912MfXL
|
||||
|
||||
device: 2924MXL
|
||||
ver: 1
|
||||
portmac: yes
|
||||
|
||||
device: 2924CXL
|
||||
|
||||
device: 2924CXLv
|
||||
|
||||
device-family: Catalyst 3500 XL
|
||||
portmac: yes
|
||||
note: L2 only IOS devices
|
||||
class: Layer2
|
||||
|
||||
device: 3508GXL
|
||||
|
||||
device: 3524XL
|
||||
|
||||
device: 3548XL
|
||||
macsuck: no
|
||||
|
||||
device-family: Catalyst 3550
|
||||
macsuck: vlan
|
||||
duplex: both
|
||||
class: Layer3::C3550
|
||||
note: Run IOS
|
||||
note: Has VLANs that don't accept SNMP connections. Don't know if they are standard (by name or number).
|
||||
note: Uses CISCO-STACK-MIB like Catalyst 5000 series for serial,duplex,type but not name
|
||||
note: Comes in flavors that support L2, L3 or combo.
|
||||
|
||||
device: 3550-12T
|
||||
|
||||
device: 3550
|
||||
note: L2/L3 Switch
|
||||
arpnip: yes
|
||||
|
||||
device: 3550-24, 3550-48
|
||||
note: L2 only switch
|
||||
macsuck: no
|
||||
note: !BRIDGE-MIB not implemented.
|
||||
|
||||
device-family: Catalyst 4000
|
||||
duplex: both
|
||||
macsuck: vlan
|
||||
class: Layer2::Catalyst
|
||||
note: Comes in IOS and CatOS versions like the 6k series.
|
||||
note: CatOS versions like L2::Catalyst just fine.
|
||||
note: !Reported problems with SNMP taking up all the CPU. Requests take significantly longer.
|
||||
|
||||
device: wsc4006
|
||||
|
||||
device: 4507
|
||||
note: !IOS device -- Test against C3550 and C6000 classes
|
||||
class: Layer3
|
||||
|
||||
device: wsc4912g
|
||||
note: Dedicated 12 port gig-e switch
|
||||
|
||||
device-family: Catalyst 5000
|
||||
duplex: both
|
||||
class: Layer2::Catalyst
|
||||
note: Port info in CISCO-STACK-MIB
|
||||
|
||||
device: wsc2926
|
||||
note: !Can give false information over SNMP at times.
|
||||
|
||||
device: wsc2948g
|
||||
|
||||
device: wsc2980g
|
||||
note: !Macsuck not working?
|
||||
|
||||
device: wsc5000
|
||||
note: !Has nasty tendency to not give you all SNMP data ,flaky for some older Catalyst versions.
|
||||
|
||||
device: wsc5505
|
||||
|
||||
device: wsc5509
|
||||
|
||||
device: wsc5500
|
||||
|
||||
device: wsx5302
|
||||
arpnip: yes
|
||||
class: Layer3
|
||||
note: Router blade that runs IOS
|
||||
|
||||
device-family: Catalyst 6500
|
||||
macsuck:vlan
|
||||
class: Layer3::C6500
|
||||
note: Runs in two possible modes, native (IOS) and hybrid (IOS with CatOS on top).
|
||||
note: Switch running Hybrid has WS-C in description field and loves L2::Catalyst class
|
||||
note: Native Mode (IOS) versions seem to have SNMP problems with L2 data.
|
||||
|
||||
device: 6503
|
||||
macsuck:no
|
||||
note: !Macsuck failing even under vlan mode
|
||||
note: Native mode (IOS) reports L2+L3
|
||||
|
||||
device: 6509
|
||||
duplex: link
|
||||
macsuck:no
|
||||
note: Native mode (IOS) reports L2+L3
|
||||
note: !Macsuck failing even under vlan mode
|
||||
|
||||
device: wsc6509
|
||||
duplex: both
|
||||
class: Layer2::Catalyst
|
||||
note: Hybrid Mode (Catalyst) reports L2 only
|
||||
|
||||
device: 6kMsfc
|
||||
class: Layer3
|
||||
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
|
||||
|
||||
device: 6kMsfc2
|
||||
class: Layer3
|
||||
note: IOS portion of Hybrid mode. VLAN and other L3 Services.
|
||||
|
||||
device-family: Voice Gateway
|
||||
class: Layer3
|
||||
duplex: no
|
||||
|
||||
device: VG200
|
||||
|
||||
# Foundry
|
||||
device-vendor: Foundry Networks
|
||||
class: Layer3::Foundry
|
||||
|
||||
device-family: FastIron
|
||||
ver: 1
|
||||
|
||||
# HP
|
||||
device-vendor: HP
|
||||
class: Layer2::HP
|
||||
ver: 2
|
||||
|
||||
device-family: ProCurve
|
||||
duplex: both
|
||||
macsuck: yes
|
||||
arpnip: no
|
||||
cdp: yes
|
||||
note: CDP only available with newer ROM versions.
|
||||
|
||||
device: 2512
|
||||
ver: 1
|
||||
|
||||
device: 2524
|
||||
ver: 1
|
||||
|
||||
device: 4000
|
||||
|
||||
device: 4104GL
|
||||
duplex: link
|
||||
|
||||
device: 4108GL
|
||||
|
||||
device: 8000
|
||||
116
Info.pm
116
Info.pm
@@ -7,7 +7,7 @@
|
||||
# See COPYRIGHT at bottom
|
||||
|
||||
package SNMP::Info;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.7;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
@@ -27,7 +27,7 @@ SNMP::Info - Object Oriented Perl5 Interface to Network devices and MIBs through
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
SNMP::Info - Version 0.5
|
||||
SNMP::Info - Version 0.6
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -371,6 +371,11 @@ Subclass for Cisco Catalyst 3550 2/3 switches running IOS.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Thanks
|
||||
|
||||
Thanks for testing and coding help (in no particular order) to :
|
||||
Andy Ford, Brian Wilson, Jean-Philippe Luiggi, D<>na Watanabe
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
=head2 Constructor
|
||||
@@ -491,8 +496,8 @@ sub new {
|
||||
$new_obj->{store} = $store;
|
||||
$new_obj->{sess} = $sess;
|
||||
$new_obj->{args} = \%args;
|
||||
$new_obj->{snmp_ver} = $args{Version};
|
||||
$new_obj->{snmp_comm} = $args{Community};
|
||||
$new_obj->{snmp_ver} = $args{Version} || 2;
|
||||
$new_obj->{snmp_comm} = $args{Community} || 'public';
|
||||
|
||||
return $auto_specific ?
|
||||
$new_obj->specify() : $new_obj;
|
||||
@@ -574,13 +579,15 @@ 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 (IOS) -> SNMP::Info::Layer2::C2900
|
||||
Catalyst WS-C (2926,5xxx,6xxx) -> SNMP::Info::Layer2::Catalyst
|
||||
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
|
||||
@@ -610,7 +617,9 @@ sub device_type {
|
||||
|
||||
$objtype = 'SNMP::Info::Layer3::C3550' if $desc =~ /C3550/ ;
|
||||
$objtype = 'SNMP::Info::Layer3::Foundry' if $desc =~ /foundry/i ;
|
||||
$objtype = 'SNMP::Info::Layer3::Aironet' if ($desc =~ /cisco/i and $desc =~ /\D3[45]0\D/) ;
|
||||
# Aironet - older non-IOS
|
||||
$objtype = 'SNMP::Info::Layer3::Aironet' if ($desc =~ /Cisco/ and $desc =~ /\D(CAP340|AP340|CAP350|350|1200)\D/) ;
|
||||
$objtype = 'SNMP::Info::Layer3::C6500' if $desc =~ /c6sup2/;
|
||||
|
||||
# Layer 2 Supported
|
||||
} elsif ($info->has_layer(2)) {
|
||||
@@ -624,18 +633,21 @@ sub device_type {
|
||||
$objtype = 'SNMP::Info::Layer2::C1900' if ($desc =~ /catalyst/i and $desc =~ /\D19\d{2}/);
|
||||
|
||||
# Catalyst 2900 (IOS) series override
|
||||
$objtype = 'SNMP::Info::Layer2::C2900' if ($desc =~ /C2900XL/i );
|
||||
$objtype = 'SNMP::Info::Layer2::C2900' if ($desc =~ /(C2900XL|C2950)/ );
|
||||
|
||||
# Catalyst WS-C series override (2926,5xxx,6xxx)
|
||||
# Catalyst WS-C series override 2926,4k,5k,6k in Hybrid
|
||||
$objtype = 'SNMP::Info::Layer2::Catalyst' if ($desc =~ /WS-C\d{4}/);
|
||||
|
||||
# Catalyst 3550 / 3548 Layer2 only switches
|
||||
$objtype = 'SNMP::Info::Layer3::C3550' if ($desc =~ /C3550/);
|
||||
|
||||
# HP
|
||||
$objtype = 'SNMP::Info::Layer2::HP' if ($desc =~ /hp/i);
|
||||
$objtype = 'SNMP::Info::Layer2::HP' if ($desc =~ /HP.*ProCurve/);
|
||||
|
||||
# Bay Switch
|
||||
$objtype = 'SNMP::Info::Layer2::Bay' if ($desc =~ /bay/i);
|
||||
$objtype = 'SNMP::Info::Layer2::Bay' if ($desc =~ /BayStack/);
|
||||
|
||||
# Aironet
|
||||
# Aironet - IOS
|
||||
$objtype = 'SNMP::Info::Layer2::Aironet' if ($desc =~ /C1100/);
|
||||
|
||||
} elsif ($info->has_layer(1)) {
|
||||
@@ -1420,6 +1432,7 @@ Let's make a sample Layer 2 Device subclass :
|
||||
=head2 Overrides
|
||||
=cut
|
||||
|
||||
1; # don't forget this line
|
||||
----------------------- snip --------------------------------
|
||||
|
||||
Be sure and send the debugged version to snmp@warped.org to be
|
||||
@@ -1478,55 +1491,76 @@ $NOSUCH = 1;
|
||||
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',
|
||||
'45000000' => 'DS3',
|
||||
'45045000' => 'DS3',
|
||||
'64000000' => '64 Mbps',
|
||||
'100000000' => '100 Mbps',
|
||||
'149760000' => 'OC-1'
|
||||
'155000000' => 'OC-1'
|
||||
'400000000' => '400 Mbps',
|
||||
'622000000' => 'OC-12',
|
||||
'599040000' => 'OC-12',
|
||||
'1000000000' => '1.0 Gbps',
|
||||
);
|
||||
|
||||
=cut
|
||||
%SPEED_MAP = (
|
||||
'64000' => '64 kbps',
|
||||
'1500000' => '1.5 Mbps',
|
||||
'1544000' => 'T1',
|
||||
'2000000' => '2.0 Mbps',
|
||||
'2048000' => '2.048 Mbps',
|
||||
'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' => 'OC-1',
|
||||
'155000000' => 'OC-1',
|
||||
'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',
|
||||
'599040000' => 'OC-12',
|
||||
'622080000' => 'OC-12',
|
||||
'1000000000' => '1.0 Gbps',
|
||||
)
|
||||
|
||||
=cut
|
||||
%SPEED_MAP = (
|
||||
'56000' => '56 kbps',
|
||||
'64000' => '64 kbps',
|
||||
'115000' => '115 kpbs',
|
||||
'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',
|
||||
'51850000' => 'OC-1',
|
||||
'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',
|
||||
);
|
||||
|
||||
sub munge_speed {
|
||||
my $speed = shift;
|
||||
return defined $SPEED_MAP{$speed} ? $SPEED_MAP{$speed} : $speed;
|
||||
my $map = $SPEED_MAP{$speed};
|
||||
|
||||
#print " $speed -> $map " if (defined $map);
|
||||
return $map || $speed;
|
||||
}
|
||||
|
||||
=item munge_ip()
|
||||
@@ -1679,7 +1713,7 @@ sub error_throw {
|
||||
$self->{error} = $error;
|
||||
|
||||
if ($self->debug()){
|
||||
$error .= "\n" unless $error =~ /\n$/;
|
||||
$error =~ s/\n+$//;
|
||||
carp($error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Bridge;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::CDP;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
484
Info/CiscoStack.pm
Normal file
484
Info/CiscoStack.pm
Normal file
@@ -0,0 +1,484 @@
|
||||
# SNMP::Info::CiscoStack
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2003 Max Baker
|
||||
# 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 author 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.
|
||||
|
||||
package SNMP::Info::CiscoStack;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE %PORTSTAT $INIT/;
|
||||
@SNMP::Info::CiscoStack::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::CiscoStack::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
$INIT = 0;
|
||||
%MIBS = (
|
||||
'CISCO-STACK-MIB' => 'ciscoStackMIB',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'sysip' => 'sysIpAddr',
|
||||
'netmask' => 'sysNetMask',
|
||||
'broadcast' => 'sysBroadcast',
|
||||
'serial1' => 'chassisSerialNumber',
|
||||
'serial2' => 'chassisSerialNumberString',
|
||||
'model1' => 'chassisModel',
|
||||
'ps1_type' => 'chassisPs1Type',
|
||||
'ps1_status' => 'chassisPs1Status',
|
||||
'ps2_type' => 'chassisPs2Type',
|
||||
'ps2_status' => 'chassisPs2Status',
|
||||
'slots' => 'chassisNumSlots',
|
||||
'fan' => 'chassisFanStatus',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
'i_type2' => 'ifType',
|
||||
# CISCO-STACK-MIB::moduleEntry
|
||||
# These are blades in a catalyst device
|
||||
'm_type' => 'moduleType',
|
||||
'm_model' => 'moduleModel',
|
||||
'm_serial' => 'moduleSerialNumber',
|
||||
'm_status' => 'moduleStatus',
|
||||
'm_name' => 'moduleName',
|
||||
'm_ports' => 'moduleNumPorts',
|
||||
'm_ports_status' => 'modulePortStatus',
|
||||
'm_hwver' => 'moduleHwVersion',
|
||||
'm_fwver' => 'moduleFwVersion',
|
||||
'm_swver' => 'moduleSwVersion',
|
||||
# Router Blades :
|
||||
'm_ip' => 'moduleIPAddress',
|
||||
'm_sub1' => 'moduleSubType',
|
||||
'm_sub2' => 'moduleSubType2',
|
||||
# CISCO-STACK-MIB::portEntry
|
||||
'p_name' => 'portName',
|
||||
'p_type' => 'portType',
|
||||
'p_status' => 'portOperStatus',
|
||||
'p_status2' => 'portAdditionalStatus',
|
||||
'p_speed' => 'portAdminSpeed',
|
||||
'p_duplex' => 'portDuplex',
|
||||
'p_port' => 'portIfIndex',
|
||||
# CISCO-STACK-MIB::PortCpbEntry
|
||||
'p_speed_admin' => 'portCpbSpeed',
|
||||
'p_duplex_admin' => 'portCpbDuplex',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
);
|
||||
|
||||
%PORTSTAT = (1 => 'other',
|
||||
2 => 'ok',
|
||||
3 => 'minorFault',
|
||||
4 => 'majorFault');
|
||||
|
||||
# Changes binary byte describing each port into ascii, and returns
|
||||
# an ascii list separated by spaces.
|
||||
sub munge_port_status {
|
||||
my $status = shift;
|
||||
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
|
||||
return join(' ',@vals);
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $stack = shift;
|
||||
my $serial1 = $stack->serial1();
|
||||
my $serial2 = $stack->serial2();
|
||||
|
||||
return $serial1 if defined $serial1;
|
||||
return $serial2 if defined $serial2;
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub i_type {
|
||||
my $stack = shift;
|
||||
|
||||
my $p_port = $stack->p_port();
|
||||
my $p_type = $stack->p_type();
|
||||
|
||||
# Get more generic port types from IF-MIB
|
||||
my $i_type = $stack->i_type2();
|
||||
|
||||
# Now Override w/ port entries
|
||||
foreach my $port (keys %$p_type) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_type->{$iid} = $p_type->{$port};
|
||||
}
|
||||
|
||||
return $i_type;
|
||||
}
|
||||
|
||||
# p_* functions are indexed to physical port. let's index these
|
||||
# to snmp iid
|
||||
sub i_name {
|
||||
my $stack = shift;
|
||||
|
||||
my $p_port = $stack->p_port();
|
||||
my $p_name = $stack->p_name();
|
||||
|
||||
my %i_name;
|
||||
foreach my $port (keys %$p_name) {
|
||||
my $iid = $p_port->{$port};
|
||||
next unless defined $iid;
|
||||
$i_name{$iid} = $p_name->{$port};
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $stack = shift;
|
||||
|
||||
#my $i_duplex = $stack->SUPER::i_duplex();
|
||||
my $p_port = $stack->p_port();
|
||||
my $p_duplex = $stack->p_duplex();
|
||||
|
||||
my $i_duplex = {};
|
||||
foreach my $port (keys %$p_duplex) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_duplex->{$iid} = $p_duplex->{$port};
|
||||
}
|
||||
return $i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $stack = shift;
|
||||
|
||||
my $p_port = $stack->p_port();
|
||||
my $p_duplex_admin = $stack->p_duplex_admin();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $port (keys %$p_duplex_admin) {
|
||||
my $iid = $p_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $duplex = $p_duplex_admin->{$port};
|
||||
next unless defined $duplex;
|
||||
|
||||
my $string = 'other';
|
||||
# see CISCO-STACK-MIB for a description of the bits
|
||||
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
|
||||
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
|
||||
# we'll call it auto if both full and half are turned on, or if the
|
||||
# specifically 'auto' flag bit is set.
|
||||
$string = 'auto'
|
||||
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
|
||||
|
||||
$i_duplex_admin{$iid} = $string;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
# $stack->interfaces() - Maps the ifIndex table to a physical port
|
||||
sub interfaces {
|
||||
my $self = shift;
|
||||
my $i_index = $self->i_index();
|
||||
my $portnames = $self->p_port();
|
||||
my %portmap = reverse %$portnames;
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$i_index) {
|
||||
my $if = $i_index->{$iid};
|
||||
my $port = $portmap{$iid};
|
||||
$interfaces{$iid} = $port || $if;
|
||||
}
|
||||
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::CiscoStack - Perl5 Interface to CPU and Memory stats for Cisco Devices
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $ciscostats = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $ciscostats->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::CiscoStack is a subclass of SNMP::Info that provides
|
||||
an interface to the C<CISCO-STACK-MIB>. This MIB is used across
|
||||
the Catalyst family under CatOS and IOS.
|
||||
|
||||
Use or create in a subclass of SNMP::Info. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
none.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-STACK-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->broadcast()
|
||||
|
||||
(B<sysBroadcast>)
|
||||
|
||||
=item $stack->fan()
|
||||
|
||||
(B<chassisFanStatus>)
|
||||
|
||||
=item $stack->model()
|
||||
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $stack->netmask()
|
||||
|
||||
(B<sysNetMask>)
|
||||
|
||||
=item $stack->ps1_type()
|
||||
|
||||
(B<chassisPs1Type>)
|
||||
|
||||
=item $stack->ps2_type()
|
||||
|
||||
(B<chassisPs2Type>)
|
||||
|
||||
=item $stack->ps1_status()
|
||||
|
||||
(B<chassisPs1Status>)
|
||||
|
||||
=item $stack->ps2_status()
|
||||
|
||||
(B<chassisPs2Status>)
|
||||
|
||||
=item $stack->serial()
|
||||
|
||||
(B<chassisSerialNumberString>) or (B<chassisSerialNumber>)
|
||||
|
||||
=item $stack->slots()
|
||||
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
=head2 Interface Tables
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->interfaces()
|
||||
|
||||
Crosses p_port() with i_index() to get physical names.
|
||||
|
||||
=item $stack->i_physical()
|
||||
|
||||
Returns a map to IID for ports that are physical ports, not vlans, etc.
|
||||
|
||||
=item $stack->i_type()
|
||||
|
||||
Crosses p_port() with p_type() and returns the results.
|
||||
|
||||
Overrides with ifType if p_type() isn't available.
|
||||
|
||||
=item $stack->i_name()
|
||||
|
||||
Crosses p_name with p_port and returns results.
|
||||
|
||||
=item $stack->i_duplex()
|
||||
|
||||
Crosses p_duplex with p_port and returns results.
|
||||
|
||||
=item $stack->i_duplex_admin()
|
||||
|
||||
Crosses p_duplex_admin with p_port.
|
||||
|
||||
Munges bit_string returned from p_duplex_admin to get duplex settings.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Module table
|
||||
|
||||
This table holds configuration information for each of the blades installed in
|
||||
the Catalyst device.
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->m_type()
|
||||
|
||||
(B<moduleType>)
|
||||
|
||||
=item $stack->m_model()
|
||||
|
||||
(B<moduleModel>)
|
||||
|
||||
=item $stack->m_serial()
|
||||
|
||||
(B<moduleSerialNumber>)
|
||||
|
||||
=item $stack->m_status()
|
||||
|
||||
(B<moduleStatus>)
|
||||
|
||||
=item $stack->m_name()
|
||||
|
||||
(B<moduleName>)
|
||||
|
||||
=item $stack->m_ports()
|
||||
|
||||
(B<moduleNumPorts>)
|
||||
|
||||
=item $stack->m_ports_status()
|
||||
|
||||
Returns a list of space separated status strings for the ports.
|
||||
|
||||
To see the status of port 4 :
|
||||
|
||||
@ports_status = split(' ', $stack->m_ports_status() );
|
||||
$port4 = $ports_status[3];
|
||||
|
||||
(B<modulePortStatus>)
|
||||
|
||||
=item $stack->m_ports_hwver()
|
||||
|
||||
(B<moduleHwVersion>)
|
||||
|
||||
=item $stack->m_ports_fwver()
|
||||
|
||||
(B<moduleFwVersion>)
|
||||
|
||||
=item $stack->m_ports_swver()
|
||||
|
||||
(B<moduleSwVersion>)
|
||||
|
||||
=item $stack->m_ports_ip()
|
||||
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $stack->m_ports_sub1()
|
||||
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $stack->m_ports_sub2()
|
||||
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Modules - Router Blades
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->m_ip()
|
||||
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $stack->m_sub1()
|
||||
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $stack->m_sub2()
|
||||
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->p_name()
|
||||
|
||||
(B<portName>)
|
||||
|
||||
=item $stack->p_type()
|
||||
|
||||
(B<portType>)
|
||||
|
||||
=item $stack->p_status()
|
||||
|
||||
(B<portOperStatus>)
|
||||
|
||||
=item $stack->p_status2()
|
||||
|
||||
(B<portAdditionalStatus>)
|
||||
|
||||
=item $stack->p_speed()
|
||||
|
||||
(B<portAdminSpeed>)
|
||||
|
||||
=item $stack->p_duplex()
|
||||
|
||||
(B<portDuplex>)
|
||||
|
||||
=item $stack->p_port()
|
||||
|
||||
(B<portIfIndex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->p_speed_admin()
|
||||
|
||||
(B<portCpbSpeed>)
|
||||
|
||||
=item $stack->p_duplex_admin()
|
||||
|
||||
(B<portCpbDuplex>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::CiscoStats;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -77,8 +77,9 @@ sub os {
|
||||
my $l2 = shift;
|
||||
my $descr = $l2->description();
|
||||
|
||||
return 'catalyst' if ($descr =~ /catalyst/i);
|
||||
# order here matters - there are Catalysts that run IOS and have catalyst in their description field.
|
||||
return 'ios' if ($descr =~ /IOS/);
|
||||
return 'catalyst' if ($descr =~ /catalyst/i);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
310
Info/CiscoVTP.pm
Normal file
310
Info/CiscoVTP.pm
Normal file
@@ -0,0 +1,310 @@
|
||||
# SNMP::Info::CiscoVTP
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2003 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.
|
||||
|
||||
package SNMP::Info::CiscoVTP;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
|
||||
@SNMP::Info::CiscoVTP::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::CiscoVTP::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
$INIT = 0;
|
||||
%MIBS = (
|
||||
'CISCO-VTP-MIB' => 'vtpVlanName',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'vtp_version' => 'vtpVersion',
|
||||
'vtp_maxstore' => 'vtpMaxVlanStorage',
|
||||
'vtp_notify' => 'vtpNotificationsEnabled',
|
||||
'vtp_notify_create' => 'vtpVlanCreatedNotifEnabled',
|
||||
'vtp_notify_delete' => 'vtpVlanDeletedNotifEnabled',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
# Management Domain Table
|
||||
'vtp_d_index' => 'managementDomainIndex',
|
||||
'vtp_d_name' => 'managementDomainName',
|
||||
'vtp_d_mode' => 'managementDomainLocalMode',
|
||||
'vtp_d_rev' => 'managementDomainConfigRevNumber',
|
||||
'vtp_d_updater' => 'managementDomainLastUpdater',
|
||||
'vtp_d_last' => 'managementDomainLastChange',
|
||||
'vtp_d_status' => 'managementDomainRowStatus',
|
||||
'vtp_d_tftp' => 'managementDomainTftpServer',
|
||||
'vtp_d_tftp_path' => 'managementDomainTftpPathname',
|
||||
'vtp_d_pruning' => 'managementDomainPruningState',
|
||||
'vtp_d_ver' => 'managementDomainVersionInUse',
|
||||
# VLAN Table
|
||||
'v_index' => 'vtpVlanIndex',
|
||||
'v_state' => 'vtpVlanState',
|
||||
'v_type' => 'vtpVlanType',
|
||||
'v_name' => 'vtpVlanName',
|
||||
'v_mtu' => 'vtpVlanMtu',
|
||||
'v_said' => 'vtpVlanDot10Said',
|
||||
'v_ring' => 'vtpVlanRingNumber',
|
||||
'v_bridge' => 'vtpVlanBridgeNumber',
|
||||
'v_stp' => 'vtpVlanStpType',
|
||||
'v_parent' => 'vtpVlanParentVlan',
|
||||
'v_trans1' => 'vtpVlanTranslationalVlan1',
|
||||
'v_trans2' => 'vtpVlanTranslationalVlan2',
|
||||
'v_btype' => 'vtpVlanBridgeType',
|
||||
'v_hop_are' => 'vtpVlanAreHopCount',
|
||||
'v_hop_ste' => 'vtpVlanSteHopCount',
|
||||
'v_crf' => 'vtpVlanIsCRFBackup',
|
||||
'v_type_ext' => 'vtpVlanTypeExt',
|
||||
'v_if' => 'vtpVlanIfIndex',
|
||||
# TODO Add these tables if someone wants them..
|
||||
# vtpEditControlTable
|
||||
# vtpVlanEditTable
|
||||
# vtpStatsTable
|
||||
# vlanTrunkPortTable
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
);
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::CiscoVTP - Perl5 Interface to Cisco's VLAN Management MIB - CISCO-VTP-MIB
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $vtp = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $vtp->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::CiscoVTP is a subclass of SNMP::Info that provides
|
||||
information about a switch's VLANs.
|
||||
|
||||
Use or create in a subclass of SNMP::Info. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
none.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-VTP-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $vtp->vtp_version()
|
||||
|
||||
C<vtpVersion>
|
||||
|
||||
=item $vtp->vtp_maxstore()
|
||||
|
||||
C<vtpMaxVlanStorage>
|
||||
|
||||
=item $vtp->vtp_notify()
|
||||
|
||||
C<vtpNotificationsEnabled>
|
||||
|
||||
=item $vtp->vtp_notify_create()
|
||||
|
||||
C<vtpVlanCreatedNotifEnabled>
|
||||
|
||||
=item $vtp->vtp_notify_delete()
|
||||
|
||||
C<vtpVlanDeletedNotifEnabled>
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
You device will only implement a subset of these methods.
|
||||
|
||||
=head2 VLAN Table
|
||||
|
||||
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
|
||||
for a good treaty of how to connect to the VLANs
|
||||
|
||||
=over
|
||||
|
||||
=item $vtp->v_index()
|
||||
|
||||
C<vtpVlanIndex>
|
||||
|
||||
=item $vtp->v_state()
|
||||
|
||||
C<vtpVlanState>
|
||||
|
||||
=item $vtp->v_type()
|
||||
|
||||
C<vtpVlanType>
|
||||
|
||||
=item $vtp->v_name()
|
||||
|
||||
C<vtpVlanName>
|
||||
|
||||
=item $vtp->v_mtu()
|
||||
|
||||
C<vtpVlanMtu>
|
||||
|
||||
=item $vtp->v_said()
|
||||
|
||||
C<vtpVlanDot10Said>
|
||||
|
||||
=item $vtp->v_ring()
|
||||
|
||||
C<vtpVlanRingNumber>
|
||||
|
||||
=item $vtp->v_bridge()
|
||||
|
||||
C<vtpVlanBridgeNumber>
|
||||
|
||||
=item $vtp->v_stp()
|
||||
|
||||
C<vtpVlanStpType>
|
||||
|
||||
=item $vtp->v_parent()
|
||||
|
||||
C<vtpVlanParentVlan>
|
||||
|
||||
=item $vtp->v_trans1()
|
||||
|
||||
C<vtpVlanTranslationalVlan1>
|
||||
|
||||
=item $vtp->v_trans2()
|
||||
|
||||
C<vtpVlanTranslationalVlan2>
|
||||
|
||||
=item $vtp->v_btype()
|
||||
|
||||
C<vtpVlanBridgeType>
|
||||
|
||||
=item $vtp->v_hop_are()
|
||||
|
||||
C<vtpVlanAreHopCount>
|
||||
|
||||
=item $vtp->v_hop_ste()
|
||||
|
||||
C<vtpVlanSteHopCount>
|
||||
|
||||
=item $vtp->v_crf()
|
||||
|
||||
C<vtpVlanIsCRFBackup>
|
||||
|
||||
=item $vtp->v_type_ext()
|
||||
|
||||
C<vtpVlanTypeExt>
|
||||
|
||||
=item $vtp->v_if()
|
||||
|
||||
C<vtpVlanIfIndex>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Managment Domain Table
|
||||
|
||||
=over
|
||||
|
||||
=item $vtp->vtp_d_index()
|
||||
|
||||
C<managementDomainIndex>
|
||||
|
||||
=item $vtp->vtp_d_name()
|
||||
|
||||
C<managementDomainName>
|
||||
|
||||
=item $vtp->vtp_d_mode()
|
||||
|
||||
C<managementDomainLocalMode>
|
||||
|
||||
=item $vtp->vtp_d_rev()
|
||||
|
||||
C<managementDomainConfigRevNumber>
|
||||
|
||||
=item $vtp->vtp_d_updater()
|
||||
|
||||
C<managementDomainLastUpdater>
|
||||
|
||||
=item $vtp->vtp_d_last()
|
||||
|
||||
C<managementDomainLastChange>
|
||||
|
||||
=item $vtp->vtp_d_status()
|
||||
|
||||
C<managementDomainRowStatus>
|
||||
|
||||
=item $vtp->vtp_d_tftp()
|
||||
|
||||
C<managementDomainTftpServer>
|
||||
|
||||
=item $vtp->vtp_d_tftp_path()
|
||||
|
||||
C<managementDomainTftpPathname>
|
||||
|
||||
=item $vtp->vtp_d_pruning()
|
||||
|
||||
C<managementDomainPruningState>
|
||||
|
||||
=item $vtp->vtp_d_ver()
|
||||
|
||||
C<managementDomainVersionInUse>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Entity;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::EtherLike;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1::Allied;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1::Asante;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -55,8 +55,8 @@ $INIT = 0;
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
%SNMP::Info::CiscoStats::MIBS,
|
||||
'CISCO-PRODUCTS-MIB' => 'sysName',
|
||||
'CISCO-STACK-MIB' => 'wsc1900sysID',
|
||||
'CISCO-PRODUCTS-MIB' => 'sysName', # for model()
|
||||
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
@@ -89,7 +89,7 @@ sub model {
|
||||
my $l2 = shift;
|
||||
my $id = $l2->id();
|
||||
my $model = &SNMP::translateObj($id);
|
||||
|
||||
|
||||
# HP
|
||||
$model =~ s/^hpswitch//i;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::Aironet;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
|
||||
@@ -28,38 +28,42 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::C2900;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
|
||||
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer2::C2900::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
# Set for No CDP
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS
|
||||
%SNMP::Info::Layer2::GLOBALS,
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
# C2900PortEntry
|
||||
'c2900_p_index' => 'c2900PortIfIndex',
|
||||
'c2900_p_duplex' => 'c2900PortDuplexStatus',
|
||||
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
|
||||
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
|
||||
);
|
||||
'c2900_p_index' => 'c2900PortIfIndex',
|
||||
'c2900_p_duplex' => 'c2900PortDuplexStatus',
|
||||
'c2900_p_duplex_admin' => 'c2900PortDuplexState',
|
||||
'c2900_p_speed_admin' => 'c2900PortAdminSpeed',
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
'CISCO-C2900-MIB' => 'ciscoC2900MIB'
|
||||
);
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
'CISCO-C2900-MIB' => 'ciscoC2900MIB',
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
);
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
@@ -134,6 +138,7 @@ sub interfaces {
|
||||
return \%if
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
@@ -176,6 +181,8 @@ a more specific class using the method above.
|
||||
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
@@ -186,6 +193,12 @@ a more specific class using the method above.
|
||||
|
||||
Part of the v2 MIBs from Cisco.
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info::Layer2 for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
@@ -206,6 +219,10 @@ These are methods that return scalar value from SNMP
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
@@ -277,4 +294,8 @@ to a hash.
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# Copyright (c) 2003 Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,16 +29,19 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::Catalyst;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
use SNMP::Info::CiscoStack;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer2::Catalyst::ISA = qw/SNMP::Info::CiscoStack SNMP::Info::Layer2
|
||||
SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
@@ -47,82 +51,28 @@ $DEBUG=0;
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
'CISCO-STACK-MIB' => 'moduleType',
|
||||
'CISCO-VTP-MIB' => 'vtpVlanIndex'
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
%SNMP::Info::CiscoStack::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS,
|
||||
# these are in CISCO-STACK-MIB
|
||||
'sysip' => 'sysIpAddr',
|
||||
'netmask' => 'sysNetMask',
|
||||
'broadcast' => 'sysBroadcast',
|
||||
'serial' => 'chassisSerialNumber',
|
||||
'model' => 'chassisModel',
|
||||
'ps1_type' => 'chassisPs1Type',
|
||||
'ps1_status' => 'chassisPs1Status',
|
||||
'ps2_type' => 'chassisPs2Type',
|
||||
'ps2_status' => 'chassisPs2Status',
|
||||
'slots' => 'chassisNumSlots',
|
||||
'fan' => 'chassisFanStatus',
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
%SNMP::Info::CiscoStack::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer2::FUNCS,
|
||||
'i_type2' => 'ifType',
|
||||
# CISCO-STACK-MIB::moduleEntry
|
||||
# These are blades in a catalyst device
|
||||
'm_type' => 'moduleType',
|
||||
'm_model' => 'moduleModel',
|
||||
'm_serial' => 'moduleSerialNumber',
|
||||
'm_status' => 'moduleStatus',
|
||||
'm_name' => 'moduleName',
|
||||
'm_ports' => 'moduleNumPorts',
|
||||
'm_ports_status' => 'modulePortStatus',
|
||||
'm_hwver' => 'moduleHwVersion',
|
||||
'm_fwver' => 'moduleFwVersion',
|
||||
'm_swver' => 'moduleSwVersion',
|
||||
# Router Blades :
|
||||
'm_ip' => 'moduleIPAddress',
|
||||
'm_sub1' => 'moduleSubType',
|
||||
'm_sub2' => 'moduleSubType2',
|
||||
# CISCO-STACK-MIB::portEntry
|
||||
'p_name' => 'portName',
|
||||
'p_type' => 'portType',
|
||||
'p_status' => 'portOperStatus',
|
||||
'p_status2' => 'portAdditionalStatus',
|
||||
'p_speed' => 'portAdminSpeed',
|
||||
'p_duplex' => 'portDuplex',
|
||||
'p_port' => 'portIfIndex',
|
||||
# CISCO-STACK-MIB::PortCpbEntry
|
||||
'p_speed_admin' => 'portCpbSpeed',
|
||||
'p_duplex_admin' => 'portCpbDuplex',
|
||||
# CISCO-VTP-MIB::VtpVlanEntry
|
||||
'v_state' => 'vtpVlanState',
|
||||
'v_type' => 'vtpVlanType',
|
||||
'v_name' => 'vtpVlanName',
|
||||
'v_mtu' => 'vtpVlanMtu',
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
%SNMP::Info::CiscoStack::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::Layer2::MUNGE,
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
%SNMP::Info::CiscoStack::MUNGE,
|
||||
);
|
||||
|
||||
%PORTSTAT = (1 => 'other',
|
||||
2 => 'ok',
|
||||
3 => 'minorFault',
|
||||
4 => 'majorFault');
|
||||
|
||||
# Changes binary byte describing each port into ascii, and returns
|
||||
# an ascii list separated by spaces.
|
||||
sub munge_port_status {
|
||||
my $status = shift;
|
||||
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
|
||||
return join(' ',@vals);
|
||||
}
|
||||
|
||||
# Overidden Methods
|
||||
|
||||
# i_physical sets a hash entry as true if the iid is a physical port
|
||||
@@ -139,98 +89,6 @@ sub i_physical {
|
||||
return \%i_physical;
|
||||
}
|
||||
|
||||
sub i_type {
|
||||
my $cat = shift;
|
||||
|
||||
my $p_port = $cat->p_port();
|
||||
my $p_type = $cat->p_type();
|
||||
|
||||
# Get more generic port types from IF-MIB
|
||||
my $i_type = $cat->i_type2();
|
||||
|
||||
# Now Override w/ port entries
|
||||
foreach my $port (keys %$p_type) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_type->{$iid} = $p_type->{$port};
|
||||
}
|
||||
|
||||
return $i_type;
|
||||
}
|
||||
|
||||
# p_* functions are indexed to physical port. let's index these
|
||||
# to snmp iid
|
||||
sub i_name {
|
||||
my $cat = shift;
|
||||
|
||||
my $p_port = $cat->p_port();
|
||||
my $p_name = $cat->p_name();
|
||||
|
||||
my %i_name;
|
||||
foreach my $port (keys %$p_name) {
|
||||
my $iid = $p_port->{$port};
|
||||
next unless defined $iid;
|
||||
$i_name{$iid} = $p_name->{$port};
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $cat = shift;
|
||||
|
||||
my $p_port = $cat->p_port();
|
||||
my $p_duplex = $cat->p_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $port (keys %$p_duplex) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_duplex{$iid} = $p_duplex->{$port};
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $cat = shift;
|
||||
|
||||
my $p_port = $cat->p_port();
|
||||
my $p_duplex_admin = $cat->p_duplex_admin();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $port (keys %$p_duplex_admin) {
|
||||
my $iid = $p_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $duplex = $p_duplex_admin->{$port};
|
||||
next unless defined $duplex;
|
||||
|
||||
my $string = 'other';
|
||||
# see CISCO-STACK-MIB for a description of the bits
|
||||
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
|
||||
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
|
||||
# we'll call it auto if both full and half are turned on, or if the
|
||||
# specifically 'auto' flag bit is set.
|
||||
$string = 'auto'
|
||||
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
|
||||
|
||||
$i_duplex_admin{$iid} = $string;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
# $cat->interfaces() - Maps the ifIndex table to a physical port
|
||||
sub interfaces {
|
||||
my $self = shift;
|
||||
my $interfaces = $self->i_index();
|
||||
my $portnames = $self->p_port();
|
||||
my %portmap = reverse %$portnames;
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$interfaces) {
|
||||
my $if = $interfaces->{$iid};
|
||||
$interfaces{$if} = $portmap{$iid};
|
||||
}
|
||||
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
}
|
||||
@@ -257,7 +115,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco devices running Catalyst OS
|
||||
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco Catalyst 5000 series devices.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -281,13 +139,16 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info subclass to provide information for Cisco Catalyst switches running CatOS.
|
||||
SNMP::Info subclass to provide information for Cisco Catalyst 5000 series switches running CatOS.
|
||||
|
||||
This subclass is not for all devices that have the name Catalyst. Note that some Catalyst
|
||||
switches run IOS, like the 2900 and 3550 families. Cisco Catalyst 1900 switches use their
|
||||
own MIB and have a separate subclass. Use the method above to have SNMP::Info determine the
|
||||
appropriate subclass before using this class directly.
|
||||
|
||||
This class includes the Catalyst 2950 series devices, which fall under the
|
||||
Catalyst 5000 family.
|
||||
|
||||
Note: Some older Catalyst switches will only talk SNMP version 1. Some newer ones will not
|
||||
return all their data if connected via Version 1.
|
||||
|
||||
@@ -302,20 +163,24 @@ a more specific class using the method above.
|
||||
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=item SNMP::Info::CiscoStack
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-STACK-MIB
|
||||
|
||||
=item CISCO-VTP-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info::Layer2 for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoStack for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
These MIBs are found in the standard v2 MIBs from Cisco.
|
||||
@@ -326,22 +191,6 @@ These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->broadcast()
|
||||
|
||||
(B<sysBroadcast>)
|
||||
|
||||
=item $cat->fan()
|
||||
|
||||
(B<chassisFanStatus>)
|
||||
|
||||
=item $cat->model()
|
||||
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $cat->netmask()
|
||||
|
||||
(B<sysNetMask>)
|
||||
|
||||
=item $cat->os()
|
||||
|
||||
Returns 'catalyst'
|
||||
@@ -351,30 +200,6 @@ Returns 'catalyst'
|
||||
Tries to use the value from SNMP::Info::CiscoStats->os_ver() and if it fails
|
||||
it grabs $cat->m_swver()->{1} and uses that.
|
||||
|
||||
=item $cat->ps1_type()
|
||||
|
||||
(B<chassisPs1Type>)
|
||||
|
||||
=item $cat->ps2_type()
|
||||
|
||||
(B<chassisPs2Type>)
|
||||
|
||||
=item $cat->ps1_status()
|
||||
|
||||
(B<chassisPs1Status>)
|
||||
|
||||
=item $cat->ps2_status()
|
||||
|
||||
(B<chassisPs2Status>)
|
||||
|
||||
=item $cat->serial()
|
||||
|
||||
(B<chassisSerialNumberString>)
|
||||
|
||||
=item $cat->slots()
|
||||
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=item $cat->vendor()
|
||||
|
||||
Returns 'cisco'
|
||||
@@ -385,206 +210,29 @@ Returns 'cisco'
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->interfaces()
|
||||
|
||||
Crosses p_port() with i_index() to get physical names.
|
||||
|
||||
=item $cat->i_physical()
|
||||
|
||||
Returns a map to IID for ports that are physical ports, not vlans, etc.
|
||||
|
||||
=item $cat->i_type()
|
||||
|
||||
Crosses p_port() with p_type() and returns the results.
|
||||
|
||||
Overrides with ifType if p_type() isn't available.
|
||||
|
||||
=item $cat->i_name()
|
||||
|
||||
Crosses p_name with p_port and returns results.
|
||||
|
||||
=item $cat->i_duplex()
|
||||
|
||||
Crosses p_duplex with p_port and returns results.
|
||||
|
||||
=item $cat->i_duplex_admin()
|
||||
|
||||
Crosses p_duplex_admin with p_port.
|
||||
|
||||
Munges bit_string returned from p_duplex_admin to get duplex settings.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Module table
|
||||
|
||||
This table holds configuration information for each of the blades installed in
|
||||
the Catalyst device.
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->m_type()
|
||||
|
||||
(B<moduleType>)
|
||||
|
||||
=item $cat->m_model()
|
||||
|
||||
(B<moduleModel>)
|
||||
|
||||
=item $cat->m_serial()
|
||||
|
||||
(B<moduleSerialNumber>)
|
||||
|
||||
=item $cat->m_status()
|
||||
|
||||
(B<moduleStatus>)
|
||||
|
||||
=item $cat->m_name()
|
||||
|
||||
(B<moduleName>)
|
||||
|
||||
=item $cat->m_ports()
|
||||
|
||||
(B<moduleNumPorts>)
|
||||
|
||||
=item $cat->m_ports_status()
|
||||
|
||||
Returns a list of space separated status strings for the ports.
|
||||
|
||||
To see the status of port 4 :
|
||||
|
||||
@ports_status = split(' ', $cat->m_ports_status() );
|
||||
$port4 = $ports_status[3];
|
||||
|
||||
(B<modulePortStatus>)
|
||||
|
||||
=item $cat->m_ports_hwver()
|
||||
|
||||
(B<moduleHwVersion>)
|
||||
|
||||
=item $cat->m_ports_fwver()
|
||||
|
||||
(B<moduleFwVersion>)
|
||||
|
||||
=item $cat->m_ports_swver()
|
||||
|
||||
(B<moduleSwVersion>)
|
||||
|
||||
=item $cat->m_ports_ip()
|
||||
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $cat->m_ports_sub1()
|
||||
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $cat->m_ports_sub2()
|
||||
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Modules - Router Blades
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->m_ip()
|
||||
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $cat->m_sub1()
|
||||
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $cat->m_sub2()
|
||||
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->p_name()
|
||||
|
||||
(B<portName>)
|
||||
|
||||
=item $cat->p_type()
|
||||
|
||||
(B<portType>)
|
||||
|
||||
=item $cat->p_status()
|
||||
|
||||
(B<portOperStatus>)
|
||||
|
||||
=item $cat->p_status2()
|
||||
|
||||
(B<portAdditionalStatus>)
|
||||
|
||||
=item $cat->p_speed()
|
||||
|
||||
(B<portAdminSpeed>)
|
||||
|
||||
=item $cat->p_duplex()
|
||||
|
||||
(B<portDuplex>)
|
||||
|
||||
=item $cat->p_port()
|
||||
|
||||
(B<portIfIndex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->p_speed_admin()
|
||||
|
||||
(B<portCpbSpeed>)
|
||||
|
||||
=item $cat->p_duplex_admin()
|
||||
|
||||
(B<portCpbDuplex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 VLAN Entry Table
|
||||
|
||||
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
|
||||
for a good treaty of how to connect to the VLANs
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->v_state()
|
||||
|
||||
(B<vtpVlanState>)
|
||||
|
||||
=item $cat->v_type()
|
||||
|
||||
(B<vtpVlanType>)
|
||||
|
||||
=item $cat->v_name()
|
||||
|
||||
(B<vtpVlanName>)
|
||||
|
||||
=item $cat->v_mtu()
|
||||
|
||||
(B<vtpVlanMtu>)
|
||||
|
||||
=back
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2::CiscoSTack
|
||||
|
||||
See documentation in SNMP::Info::Layer2::CiscoStack for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::HP;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::Aironet;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -135,7 +135,9 @@ sub fw_mac {
|
||||
}
|
||||
|
||||
foreach my $bs (keys %$bs_mac){
|
||||
$fw_mac->{$bs} = $bs_mac->{$bs};
|
||||
my $entry = $bs;
|
||||
$entry =~ s/\.0$//;
|
||||
$fw_mac->{$entry} = $bs_mac->{$bs};
|
||||
}
|
||||
|
||||
return $fw_mac;
|
||||
@@ -149,7 +151,9 @@ sub fw_port {
|
||||
|
||||
|
||||
foreach my $bs (keys %$bs_port){
|
||||
$fw_port->{$bs} = $bs_port->{$bs};
|
||||
my $entry = $bs;
|
||||
$entry =~ s/\.0$//;
|
||||
$fw_port->{$entry} = $bs_port->{$bs};
|
||||
}
|
||||
|
||||
return $fw_port;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2003, Regents of the University of California
|
||||
# Copyright (c) 2003 Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,16 +29,18 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::C3550;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer3;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
use SNMP::Info::CiscoStack;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer3::C3550::ISA = qw/SNMP::Info::Layer3 Exporter/;
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer3::C3550::ISA = qw/ SNMP::Info::Layer3 SNMP::Info::CiscoStack SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer3::C3550::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
@@ -48,123 +51,38 @@ $INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer3::MIBS,
|
||||
'CISCO-STACK-MIB' => 'moduleType',
|
||||
'CISCO-VTP-MIB' => 'vtpVlanIndex'
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
%SNMP::Info::CiscoStack::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer3::GLOBALS,
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
%SNMP::Info::CiscoStack::GLOBALS,
|
||||
'ports2' => 'ifNumber',
|
||||
# these are in CISCO-STACK-MIB
|
||||
'serial' => 'chassisSerialNumberString',
|
||||
'ps1_type' => 'chassisPs1Type',
|
||||
'ps1_status' => 'chassisPs1Status',
|
||||
'ps2_type' => 'chassisPs2Type',
|
||||
'ps2_status' => 'chassisPs2Status',
|
||||
'fan' => 'chassisFanStatus'
|
||||
);
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer3::FUNCS,
|
||||
'i_type2' => 'ifType',
|
||||
# CISCO-STACK-MIB::portEntry
|
||||
'p_name' => 'portName',
|
||||
'p_type' => 'portType',
|
||||
'p_status' => 'portOperStatus',
|
||||
'p_status2' => 'portAdditionalStatus',
|
||||
'p_speed' => 'portAdminSpeed',
|
||||
'p_duplex' => 'portDuplex',
|
||||
'p_port' => 'portIfIndex',
|
||||
# CISCO-STACK-MIB::PortCpbEntry
|
||||
'p_speed_admin' => 'portCpbSpeed',
|
||||
'p_duplex_admin' => 'portCpbDuplex',
|
||||
# CISCO-VTP-MIB::VtpVlanEntry
|
||||
'v_state' => 'vtpVlanState',
|
||||
'v_type' => 'vtpVlanType',
|
||||
'v_name' => 'vtpVlanName',
|
||||
'v_mtu' => 'vtpVlanMtu',
|
||||
);
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
%SNMP::Info::CiscoStack::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
%SNMP::Info::CiscoStack::MUNGE,
|
||||
);
|
||||
|
||||
%PORTSTAT = (1 => 'other',
|
||||
2 => 'ok',
|
||||
3 => 'minorFault',
|
||||
4 => 'majorFault');
|
||||
# Pick and choose
|
||||
|
||||
# Changes binary byte describing each port into ascii, and returns
|
||||
# an ascii list separated by spaces.
|
||||
sub munge_port_status {
|
||||
my $status = shift;
|
||||
my @vals = map($PORTSTAT{$_},unpack('C*',$status));
|
||||
return join(' ',@vals);
|
||||
}
|
||||
|
||||
# Overidden Methods
|
||||
|
||||
sub i_type {
|
||||
my $c3550 = shift;
|
||||
|
||||
my $p_port = $c3550->p_port();
|
||||
my $p_type = $c3550->p_type();
|
||||
|
||||
# Get more generic port types from IF-MIB
|
||||
my $i_type = $c3550->i_type2();
|
||||
|
||||
# Now Override w/ port entries
|
||||
foreach my $port (keys %$p_type) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_type->{$iid} = $p_type->{$port};
|
||||
}
|
||||
|
||||
return $i_type;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $c3550 = shift;
|
||||
|
||||
my $p_port = $c3550->p_port();
|
||||
my $p_duplex = $c3550->p_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $port (keys %$p_duplex) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_duplex{$iid} = $p_duplex->{$port};
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $c3550 = shift;
|
||||
|
||||
my $p_port = $c3550->p_port();
|
||||
my $p_duplex_admin = $c3550->p_duplex_admin();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $port (keys %$p_duplex_admin) {
|
||||
my $iid = $p_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $duplex = $p_duplex_admin->{$port};
|
||||
next unless defined $duplex;
|
||||
|
||||
my $string = 'other';
|
||||
# see CISCO-STACK-MIB for a description of the bits
|
||||
$string = 'half' if ($duplex =~ /001$/ or $duplex =~ /0100.$/);
|
||||
$string = 'full' if ($duplex =~ /010$/ or $duplex =~ /100.0$/);
|
||||
# we'll call it auto if both full and half are turned on, or if the
|
||||
# specifically 'auto' flag bit is set.
|
||||
$string = 'auto'
|
||||
if ($duplex =~ /1..$/ or $duplex =~ /110..$/ or $duplex =~ /..011$/);
|
||||
|
||||
$i_duplex_admin{$iid} = $string;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
*SNMP::Info::Layer3::C3550::serial = \&SNMP::Info::CiscoStack::serial;
|
||||
*SNMP::Info::Layer3::C3550::interfaces = \&SNMP::Info::Layer3::interfaces;
|
||||
*SNMP::Info::Layer3::C3550::i_duplex = \&SNMP::Info::CiscoStack::i_duplex;
|
||||
*SNMP::Info::Layer3::C3550::i_duplex_admin = \&SNMP::Info::CiscoStack::i_duplex_admin;
|
||||
*SNMP::Info::Layer3::C3550::i_name = \&SNMP::Info::Layer3::i_name;
|
||||
*SNMP::Info::Layer3::C3550::i_type = \&SNMP::Info::CiscoStack::i_type;
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
@@ -173,10 +91,13 @@ sub vendor {
|
||||
sub model {
|
||||
my $c3550 = shift;
|
||||
my $id = $c3550->id();
|
||||
my $model = &SNMP::translateObj($id);
|
||||
my $model = &SNMP::translateObj($id) || $id;
|
||||
$model =~ s/^catalyst//;
|
||||
$model =~ s/(24|48)$//;
|
||||
|
||||
# turn 355048 into 3550-48
|
||||
if ($model =~ /^(35\d\d)(\d\d[T]?)$/) {
|
||||
$model = "$1-$2";
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -188,12 +109,13 @@ sub ports {
|
||||
|
||||
my $id = $c3550->id();
|
||||
my $model = &SNMP::translateObj($id);
|
||||
if ($model =~ /(24|48)$/) {
|
||||
if ($model =~ /(12|24|48)[T]?$/) {
|
||||
return $1;
|
||||
}
|
||||
return $ports2;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
@@ -240,15 +162,23 @@ a more specific class using the method above.
|
||||
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=item SNMP::Info::CiscoStack
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-STACK-MIB
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
=item CISCO-VTP-MIB
|
||||
See SNMP::Info::Layer3 for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoStack for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
@@ -258,30 +188,6 @@ These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
|
||||
=item $c3550->model()
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $c3550->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
|
||||
=item $c3550->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
|
||||
=item $c3550->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
|
||||
=item $c3550->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
|
||||
=item $c3550->slots()
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=item $c3550->fan()
|
||||
(B<chassisFanStatus>)
|
||||
|
||||
=item $c3550->vendor()
|
||||
|
||||
Returns 'cisco'
|
||||
@@ -292,112 +198,29 @@ These are methods that return scalar value from SNMP
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->i_type()
|
||||
|
||||
Crosses p_port() with p_type() and returns the results.
|
||||
|
||||
Overrides with ifType if p_type() isn't available.
|
||||
|
||||
=item $c3550->i_name()
|
||||
|
||||
Crosses p_name with p_port and returns results.
|
||||
|
||||
=item $c3550->i_duplex()
|
||||
|
||||
Crosses p_duplex with p_port and returns results.
|
||||
|
||||
=item $c3550->i_duplex_admin()
|
||||
|
||||
Crosses p_duplex_admin with p_port.
|
||||
|
||||
Munges bit_string returned from p_duplex_admin to get duplex settings.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->p_name()
|
||||
|
||||
(B<portName>)
|
||||
|
||||
=item $c3550->p_type()
|
||||
|
||||
(B<portType>)
|
||||
|
||||
=item $c3550->p_status()
|
||||
|
||||
(B<portOperStatus>)
|
||||
|
||||
=item $c3550->p_status2()
|
||||
|
||||
(B<portAdditionalStatus>)
|
||||
|
||||
=item $c3550->p_speed()
|
||||
|
||||
(B<portAdminSpeed>)
|
||||
|
||||
=item $c3550->p_duplex()
|
||||
|
||||
(B<portDuplex>)
|
||||
|
||||
=item $c3550->p_port()
|
||||
|
||||
(B<portIfIndex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->p_speed_admin()
|
||||
|
||||
(B<portCpbSpeed>)
|
||||
|
||||
=item $c3550->p_duplex_admin()
|
||||
|
||||
(B<portCpbDuplex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 VLAN Entry Table
|
||||
|
||||
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
|
||||
for a good treaty of how to connect to the VLANs
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->v_state()
|
||||
|
||||
(B<vtpVlanState>)
|
||||
|
||||
=item $c3550->v_type()
|
||||
|
||||
(B<vtpVlanType>)
|
||||
|
||||
=item $c3550->v_name()
|
||||
|
||||
(B<vtpVlanName>)
|
||||
|
||||
=item $c3550->v_mtu()
|
||||
|
||||
(B<vtpVlanMtu>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer3
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=cut
|
||||
|
||||
204
Info/Layer3/C6500.pm
Normal file
204
Info/Layer3/C6500.pm
Normal file
@@ -0,0 +1,204 @@
|
||||
# SNMP::Info::Layer3::C6500
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2003 Max Baker
|
||||
# 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 Author, nor
|
||||
# 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.
|
||||
|
||||
package SNMP::Info::Layer3::C6500;
|
||||
$VERSION = 0.7;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer3;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
use SNMP::Info::CiscoStack;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer3::C6500::ISA = qw/ SNMP::Info::Layer3 SNMP::Info::CiscoStack SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer3::C6500::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer3::MIBS,
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
%SNMP::Info::CiscoStack::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer3::GLOBALS,
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
%SNMP::Info::CiscoStack::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer3::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
%SNMP::Info::CiscoStack::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
%SNMP::Info::CiscoStack::MUNGE,
|
||||
);
|
||||
|
||||
# Pick and choose
|
||||
|
||||
*SNMP::Info::Layer3::C6500::serial = \&SNMP::Info::CiscoStack::serial;
|
||||
*SNMP::Info::Layer3::C6500::interfaces = \&SNMP::Info::Layer3::interfaces;
|
||||
*SNMP::Info::Layer3::C6500::i_duplex = \&SNMP::Info::CiscoStack::i_duplex;
|
||||
#*SNMP::Info::Layer3::C6500::i_duplex_admin = \&SNMP::Info::Layer3::i_duplex_admin;
|
||||
*SNMP::Info::Layer3::C6500::i_name = \&SNMP::Info::Layer3::i_name;
|
||||
*SNMP::Info::Layer3::C6500::i_type = \&SNMP::Info::CiscoStack::i_type;
|
||||
|
||||
sub model {
|
||||
my $c6500 = shift;
|
||||
my $model1 = $c6500->model1();
|
||||
return $model1 if defined $model1;
|
||||
return $c6500->SUPER::model();
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::C6500 - Perl5 Interface to Cisco Catalyst 6500 Layer 2/3 Switches running IOS and/or CatOS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $c6500 = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $c6500->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Cisco Catalyst 6500 Layer 2/3 Switches.
|
||||
|
||||
These devices run IOS but have some of the same charactersitics as the Catalyst WS-C family (5xxx).
|
||||
For example, forwarding tables are held in VLANs, and extened interface information
|
||||
is gleened from CISCO-SWITCH-MIB.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $c6500 = new SNMP::Info::Layer3::C6500(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=item SNMP::Info::CiscoStack
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info::Layer3 for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::CiscoStack for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $c6500->vendor()
|
||||
|
||||
Returns 'cisco'
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer3
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer3
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::Foundry;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::MAU;
|
||||
$VERSION = 0.5;
|
||||
$VERSION = 0.6;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
3
README
3
README
@@ -5,7 +5,7 @@ NAME
|
||||
|
||||
VERSION
|
||||
|
||||
SNMP::Info - Version 0.5
|
||||
SNMP::Info - Version 0.6
|
||||
|
||||
AUTHOR
|
||||
|
||||
@@ -946,6 +946,7 @@ EXTENDING SNMP::INFO
|
||||
=head2 Overrides
|
||||
=cut
|
||||
|
||||
1; # don't forget this line
|
||||
----------------------- snip --------------------------------
|
||||
|
||||
Be sure and send the debugged version to snmp@warped.org to be included
|
||||
|
||||
294
t/make_dev_matrix.pl
Executable file
294
t/make_dev_matrix.pl
Executable file
@@ -0,0 +1,294 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# $Id$
|
||||
|
||||
$DevMatrix = '../DeviceMatrix.txt';
|
||||
$DevHTML = 'DeviceMatrix.html';
|
||||
$DevPNG = 'DeviceMatrix.png';
|
||||
$Attributes= {};
|
||||
|
||||
# Parse Data File
|
||||
$matrix = parse_data($DevMatrix);
|
||||
|
||||
# Graph it for fun
|
||||
eval "use GraphViz::Data::Structure;";
|
||||
if ($@ or 1) {
|
||||
print "GraphViz::Data::Structure not installed.\n";
|
||||
} else {
|
||||
my $gvds = GraphViz::Data::Structure->new($matrix);
|
||||
$gvds->graph()->as_png($DevPNG);
|
||||
}
|
||||
|
||||
open (HTML, "> $DevHTML") or die "Can't open $DevHTML. $!\n";
|
||||
$old_fh = select(HTML);
|
||||
&html_head;
|
||||
print_vendors($matrix);
|
||||
foreach my $vendor (sort sort_nocase keys %$matrix){
|
||||
print "<A NAME=\"$vendor\"><SPAN CLASS=\"vendor\"><B>$vendor</B></SPAN></A>\n";
|
||||
print "<DL>\n";
|
||||
|
||||
my $vendor_defaults = $matrix->{$vendor}->{defaults};
|
||||
print_notes($vendor_defaults,1);
|
||||
|
||||
my $families = $matrix->{$vendor}->{families};
|
||||
foreach my $family (sort sort_nocase keys %$families ) {
|
||||
print "<DT>$family Family\n";
|
||||
|
||||
my $family_defaults = $families->{$family}->{defaults};
|
||||
print_notes($family_defaults,2);
|
||||
|
||||
my $models = $families->{$family}->{models};
|
||||
foreach my $model (sort sort_nocase keys %$models ){
|
||||
my $model_defaults = $models->{$model}->{defaults};
|
||||
print "<DD>$model\n";
|
||||
print "<DL>\n";
|
||||
print_notes($model_defaults,3);
|
||||
|
||||
print "<DT><DD><TABLE BORDER=1>\n";
|
||||
print_headers();
|
||||
print "<TR>\n";
|
||||
foreach my $a (sort sort_nocase keys %$Attributes) {
|
||||
my $val;
|
||||
next if $a eq 'note';
|
||||
$val = ['-'];
|
||||
$class = 'none';
|
||||
if (defined $model_defaults->{$a}) {
|
||||
$val = $model_defaults->{$a};
|
||||
$class = 'model';
|
||||
} elsif (defined $family_defaults->{$a}){
|
||||
$val = $family_defaults->{$a};
|
||||
$class = 'family';
|
||||
} elsif (defined $vendor_defaults->{$a}){
|
||||
$val = $vendor_defaults->{$a};
|
||||
$class = 'vendor';
|
||||
}
|
||||
print " <TD CLASS='$class'>",join("<BR>\n",@$val),"</TD>\n";
|
||||
}
|
||||
print "</TR></TABLE>\n";
|
||||
print "</DL>\n";
|
||||
}
|
||||
}
|
||||
print "</DL>\n";
|
||||
}
|
||||
|
||||
|
||||
&html_tail;
|
||||
|
||||
select ($old_fh);
|
||||
close (HTML) or die "Can't write $DevHTML. $!\n";
|
||||
|
||||
# Data Structures
|
||||
|
||||
# Matrix =
|
||||
# ( vendor => { families => { family => family_hash },
|
||||
# defaults => { cmd => [values] },
|
||||
# }
|
||||
# )
|
||||
|
||||
# Family Hash
|
||||
# ( models => { model => model_hash },
|
||||
# defaults => { cmd => [values] }
|
||||
# )
|
||||
|
||||
# Model Hash
|
||||
# ( defaults => { cmd => [values] } )
|
||||
sub parse_data {
|
||||
my $file = shift;
|
||||
my $Matrix;
|
||||
|
||||
my @Lines;
|
||||
open (DM, "< $file") or die "Can't open $file. $!\n";
|
||||
{
|
||||
@Lines = <DM>;
|
||||
}
|
||||
close (DM);
|
||||
|
||||
my ($device,$family,$vendor,$class);
|
||||
foreach my $line (@Lines){
|
||||
chomp($line);
|
||||
# Comments
|
||||
$line =~ s/#.*//;
|
||||
|
||||
# Blank Lines
|
||||
next if $line =~ /^\s*$/;
|
||||
|
||||
# Trim whitespace
|
||||
$line =~ s/^\s+//;
|
||||
$line =~ s/\s+$//;
|
||||
|
||||
my ($cmd,$value);
|
||||
if ($line =~ /^([a-z-_]+)\s*:\s*(.*)$/) {
|
||||
$cmd = $1; $value = $2;
|
||||
} else {
|
||||
print "What do i do with this line : $line \n";
|
||||
next;
|
||||
}
|
||||
|
||||
# Set Class {vendor,family,device}
|
||||
if ($cmd eq 'device-vendor'){
|
||||
$vendor = $value;
|
||||
$family = $model = undef;
|
||||
$Matrix->{$vendor} = {} unless defined $Matrix->{$vendor};
|
||||
$class = $Matrix->{$vendor};
|
||||
$class->{defaults}->{type}='vendor';
|
||||
next;
|
||||
}
|
||||
|
||||
if ($cmd eq 'device-family'){
|
||||
$family = $value;
|
||||
$model = undef;
|
||||
print "$family has no vendor.\n" unless defined $vendor;
|
||||
$Matrix->{$vendor}->{families}->{$family} = {}
|
||||
unless defined $Matrix->{$vendor}->{families}->{$family};
|
||||
$class = $Matrix->{$vendor}->{families}->{$family};
|
||||
$class->{defaults}->{type}='family';
|
||||
next;
|
||||
}
|
||||
|
||||
if ($cmd eq 'device') {
|
||||
$model = $value;
|
||||
print "$model has no family.\n" unless defined $family;
|
||||
print "$model has no vendor.\n" unless defined $vendor;
|
||||
$Matrix->{$vendor}->{families}->{$family}->{models}->{$model} = {}
|
||||
unless defined $Matrix->{$vendor}->{families}->{$family}->{models}->{$model};
|
||||
$class = $Matrix->{$vendor}->{families}->{$family}->{models}->{$model};
|
||||
$class->{defaults}->{type}='device';
|
||||
next;
|
||||
}
|
||||
|
||||
# Store attribute
|
||||
push (@{$class->{defaults}->{$cmd}} , $value);
|
||||
$Attributes->{$cmd}++;
|
||||
}
|
||||
|
||||
return $Matrix;
|
||||
}
|
||||
|
||||
sub sort_nocase {
|
||||
return lc($a) cmp lc($b);
|
||||
}
|
||||
|
||||
sub print_notes {
|
||||
my $defaults = shift;
|
||||
my $level = shift;
|
||||
my $notes = $defaults->{note} || [];
|
||||
foreach my $note (@$notes){
|
||||
if ($note =~ s/^!//){
|
||||
$note = '<SPAN CLASS="note">' . $note . '</SPAN>';
|
||||
}
|
||||
}
|
||||
if (scalar @$notes){
|
||||
print "<DT>\n";
|
||||
my $print_note = join("\n<LI>",@$notes);
|
||||
print "<UL TYPE='square'><LI>$print_note</UL>\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub print_vendors {
|
||||
my $matrix=shift;
|
||||
print "<h1>Device Vendors</h1>\n";
|
||||
foreach my $vendor (sort sort_nocase keys %$matrix){
|
||||
print "[<A HREF=\"#$vendor\">$vendor</A>]\n";
|
||||
}
|
||||
print "<HR>\n";
|
||||
}
|
||||
|
||||
sub html_head {
|
||||
print <<"end_head";
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>SNMP::Info - Device Compatibility Matrix</TITLE>
|
||||
<STYLE TYPE="text/css" MEDIA="screen">
|
||||
<!--
|
||||
BODY { font-family:arial,helvetica,sans-serif; font-size:12pt; }
|
||||
TD { font-family:arial,helvetica,sans-serif; font-size:10pt; }
|
||||
TH { font-family:arial,helvetica,sans-serif; font-size:10pt; background:#F0F0F0; }
|
||||
H1 { font-family:arial,helvetica,sans-serif; font-size:14pt; }
|
||||
.vendor { font-size:12pt; color:#777777; }
|
||||
.family { font-size:12pt; color:blue; }
|
||||
.model { font-size:12pt; color:red; }
|
||||
.note { color:red; }
|
||||
//-->
|
||||
</STYLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<h1>SNMP::Info - Device Compatibility Matrix</h1>
|
||||
<P>
|
||||
end_head
|
||||
}
|
||||
|
||||
sub html_tail {
|
||||
print <<'end_tail';
|
||||
<HR>
|
||||
<h1>Color Key</h1>
|
||||
[<SPAN CLASS="model">Model Attribute</SPAN>]
|
||||
[<SPAN CLASS="family">Family Attribute</SPAN>]
|
||||
[<SPAN CLASS="vendor">Vendor Attribute</SPAN>]
|
||||
<h1>Attribute Key</h1>
|
||||
<TABLE BORDER=1>
|
||||
<TR>
|
||||
<TD>Arpnip</TD>
|
||||
<TD>Ability to collect ARP tables for MAC to IP translation.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>CDP</TD>
|
||||
<TD>Cisco Discovery Protocol usable.
|
||||
<UL>
|
||||
<LI><tt>Yes</tt> - Has CDP information through CISCO-CDP-MIB
|
||||
<LI><tt>Proprietary</tt> means the device has its own L2 Discovery Protocol.
|
||||
</UL>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Class</TD>
|
||||
<TD>SNMP::Info Class the the device currently uses. Devices using more generic
|
||||
interfaces like <tt>Layer2</tt> or <tt>Layer3</tt> may eventually get their
|
||||
own subclass.
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Duplex</TD>
|
||||
<TD>Ability to cull duplex settings from device.<BR>
|
||||
<UL>
|
||||
<LI><tt>no</tt> - Can't recover current or admin setting.
|
||||
<LI><tt>link</tt> - Can get current setting only.
|
||||
<LI><tt>both</tt> - Can get admin and link setting.
|
||||
</UL>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Macsuck</TD>
|
||||
<TD>Ability to get CAM tables for MAC to switch port mapping.<BR>
|
||||
<UL>
|
||||
<LI><TT>no</TT> - Have not found an SNMP method to get data yet.
|
||||
<LI><TT>yes</TT> - Can get through normal SWITCH-MIB method.
|
||||
<LI><TT>vlan</TT> - Have to re-connect to each VLAN and then fetch with normal
|
||||
method.
|
||||
</UL>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Portmac</TD>
|
||||
<TD>Whether the device will list the MAC address of the switch port on each
|
||||
switch port when doing a Macsuck.
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Ver</TD>
|
||||
<TD>SNMP Protocol Version the device has to use.</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
end_tail
|
||||
|
||||
}
|
||||
|
||||
sub print_headers {
|
||||
print "<TR>\n";
|
||||
foreach my $a (sort sort_nocase keys %$Attributes) {
|
||||
next if $a eq 'note';
|
||||
print " <TH>$a</TH>\n";
|
||||
}
|
||||
print "</TR>\n";
|
||||
}
|
||||
149
t/test_class.pl
Executable file
149
t/test_class.pl
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# test_class.pl
|
||||
#
|
||||
# Test a device class in SNMP::Info against a device.
|
||||
#
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
use lib '/usr/local/netdisco';
|
||||
use SNMP::Info;
|
||||
use Getopt::Long;
|
||||
use strict;
|
||||
use vars qw/$Class $Dev $Comm $Ver/;
|
||||
|
||||
# Default Values
|
||||
$Class = '';
|
||||
$Dev = '';
|
||||
$Comm = '';
|
||||
$Ver = 2;
|
||||
|
||||
GetOptions ('c|class=s' => \$Class,
|
||||
'd|dev=s' => \$Dev,
|
||||
's|comm=s' => \$Comm,
|
||||
'v|ver=i' => \$Ver,
|
||||
'h|help' => \&usage,
|
||||
);
|
||||
|
||||
|
||||
&usage unless ($Dev and $Comm);
|
||||
|
||||
$Class = $Class ? "SNMP::Info::$Class" : 'SNMP::Info';
|
||||
eval "require $Class;";
|
||||
if ($@) {
|
||||
die "Can't load Class specified : $Class.\n\n$@\n";
|
||||
}
|
||||
|
||||
print "Class $Class loaded.\n";
|
||||
|
||||
my $dev = new $Class( 'AutoSpecify' => 0,
|
||||
'AutoVerBack' => 0,
|
||||
'Version' => $Ver,
|
||||
'Debug' => 0,
|
||||
'DestHost' => $Dev,
|
||||
'Community' => $Comm
|
||||
) or die "\n";
|
||||
|
||||
print "Connected to $Dev.\n";
|
||||
|
||||
my $layers = $dev->layers();
|
||||
|
||||
unless (defined $layers){
|
||||
warn "Are you sure you got the right community string and version?\nCan't fetch layers.\n";
|
||||
}
|
||||
|
||||
print "Fetching global info...\n\n";
|
||||
|
||||
my @globals = qw/description uptime contact name location layers ports mac serial
|
||||
ps1_type ps2_type ps1_status ps2_status fan slots vendor os os_ver/;
|
||||
|
||||
foreach my $global (@globals){
|
||||
test_global($dev,$global);
|
||||
}
|
||||
|
||||
print "\nFetching interface info...\n\n";
|
||||
|
||||
my @fns = qw/interfaces i_type i_ignore i_description i_mtu i_speed i_mac i_up
|
||||
i_up_admin i_name i_duplex i_duplex_admin i_stp_state/;
|
||||
|
||||
foreach my $fn (@fns){
|
||||
test_fn($dev,$fn);
|
||||
}
|
||||
|
||||
print "\nTesting Misc...\n\n";
|
||||
my @misc = qw/v_name v_port/;
|
||||
foreach my $fn (@misc){
|
||||
test_fn($dev,$fn);
|
||||
}
|
||||
|
||||
#--------------------------------
|
||||
sub test_global {
|
||||
my $dev = shift;
|
||||
my $method = shift;
|
||||
|
||||
my $value;
|
||||
eval {
|
||||
$value = $dev->$method();
|
||||
};
|
||||
|
||||
if ($@){
|
||||
my $err = $@;
|
||||
$err =~ s/[[:cntrl:]]+/ /g;
|
||||
printf "%-20s Blew up. $err\n",$method;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unless (defined $value){
|
||||
printf "%-20s Does not exist.\n",$method;
|
||||
return 0;
|
||||
}
|
||||
$value =~ s/[[:cntrl:]]+/ /g;
|
||||
if (length $value > 60) {
|
||||
$value = substr($value,0,60);
|
||||
$value .= '...';
|
||||
}
|
||||
printf "%-20s %s \n",$method,$value;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub test_fn {
|
||||
my $dev = shift;
|
||||
my $method = shift;
|
||||
|
||||
my $results;
|
||||
|
||||
eval {
|
||||
$results = $dev->$method();
|
||||
};
|
||||
|
||||
if ($@){
|
||||
my $err = $@;
|
||||
$err =~ s/\n/ /g;
|
||||
printf "%-20s Blew up. $err\n",$method;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unless (defined $results and scalar keys %$results) {
|
||||
printf "%-20s Empty Results.\n",$method;
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf "%-20s %d rows.\n",$method, scalar(keys %$results);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub usage {
|
||||
print << "end_usage";
|
||||
|
||||
test_class - Test a device against an SNMP::Info class
|
||||
-c --class Layer2::Catalyst
|
||||
-d --dev myswitch
|
||||
-s --comm public
|
||||
-v --ver 2
|
||||
|
||||
end_usage
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user