Compare commits
161 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0a8b77f7a | ||
|
|
de464b2e6a | ||
|
|
e0acc5ce90 | ||
|
|
a1f913d91e | ||
|
|
d19b71073d | ||
|
|
ed66350c27 | ||
|
|
51d57b39f5 | ||
|
|
68524eb337 | ||
|
|
58f8ed29c7 | ||
|
|
3b96232e13 | ||
|
|
19b5d34c10 | ||
|
|
5bb4252cf0 | ||
|
|
8191d5f957 | ||
|
|
1c458c9ca9 | ||
|
|
36f84e357e | ||
|
|
c1b7d7dfc0 | ||
|
|
bbd45f82ab | ||
|
|
02f3e91c5d | ||
|
|
d5afa9f592 | ||
|
|
dceec4f537 | ||
|
|
51b09605df | ||
|
|
dc00c7d907 | ||
|
|
c6df2928a1 | ||
|
|
86bf9fd360 | ||
|
|
505de8c6dc | ||
|
|
70744f3df2 | ||
|
|
96393d5781 | ||
|
|
598c075670 | ||
|
|
ac8eef8f73 | ||
|
|
f5eb4e8bb6 | ||
|
|
abb7fe7f3c | ||
|
|
440bb002b6 | ||
|
|
6dd3f4b21a | ||
|
|
1278117b05 | ||
|
|
5c6c75b42e | ||
|
|
d78e5d6656 | ||
|
|
094c2d548d | ||
|
|
4913ac6cdd | ||
|
|
ac9efcf8ba | ||
|
|
6b4444d97a | ||
|
|
607d5f04bd | ||
|
|
b46aa416a0 | ||
|
|
800aa0b4f0 | ||
|
|
a0e0be2d68 | ||
|
|
3fa47dc2e6 | ||
|
|
25141d3c8e | ||
|
|
1f02aeaec4 | ||
|
|
5d4aada8f5 | ||
|
|
3bd7f78277 | ||
|
|
3994706465 | ||
|
|
12bf18ac02 | ||
|
|
5c6a8f3c45 | ||
|
|
ddddb703aa | ||
|
|
5ef4c78f8a | ||
|
|
05a7f104a4 | ||
|
|
da1183b4fa | ||
|
|
a51ad7ee88 | ||
|
|
df3e0e3b3a | ||
|
|
c156584417 | ||
|
|
74e649a033 | ||
|
|
342a45a424 | ||
|
|
7076c236ea | ||
|
|
0d90383ea3 | ||
|
|
fe59f88dd3 | ||
|
|
2f4704b18d | ||
|
|
c8c94bbd8b | ||
|
|
054e27e827 | ||
|
|
766f14d2bf | ||
|
|
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 | ||
|
|
bd457307ff | ||
|
|
f988cecc4d | ||
|
|
d2f67b2db2 | ||
|
|
c4a4c3d5e6 | ||
|
|
fa38fdbc2b | ||
|
|
2e03e3faca | ||
|
|
e448915e0b | ||
|
|
37836bedac | ||
|
|
a60663b238 | ||
|
|
5e879b6822 | ||
|
|
c672b914db | ||
|
|
f703bdc910 | ||
|
|
0752a2403c | ||
|
|
f0dc4c4b31 | ||
|
|
7269476bad | ||
|
|
42d56e62e1 | ||
|
|
873fd257cd | ||
|
|
43d01c5060 | ||
|
|
1d45ab5522 | ||
|
|
2674536a55 | ||
|
|
cc13a0f850 | ||
|
|
f9a97d7a3b | ||
|
|
d5f1a1ae95 | ||
|
|
466c0daec0 | ||
|
|
e127beb2d7 | ||
|
|
ff9cab9fe7 | ||
|
|
6d9ce57032 | ||
|
|
77d854f58f | ||
|
|
9e2ac2d880 | ||
|
|
4a52fccc20 | ||
|
|
d7e524b4a3 | ||
|
|
6da7d340a9 | ||
|
|
e9fa153e45 | ||
|
|
fa99cb39ae | ||
|
|
622a35de01 | ||
|
|
74c85cae9e | ||
|
|
3eba4c6c79 | ||
|
|
3f179aa21a | ||
|
|
a6a8ed4c55 | ||
|
|
d7b6fa2179 | ||
|
|
69645321cd | ||
|
|
f2754b80bb | ||
|
|
1f1ba32c1b | ||
|
|
39ed601300 | ||
|
|
c2bbd03c2f | ||
|
|
3c3c040471 | ||
|
|
af51ee7ea4 | ||
|
|
e4e039e2e1 | ||
|
|
6dac5dffb3 | ||
|
|
ddeb705f13 | ||
|
|
b86cf86fa6 | ||
|
|
0cd3ba27c0 | ||
|
|
fe6157f900 | ||
|
|
b4c1bf0900 | ||
|
|
7f2e79c634 | ||
|
|
947c8679c8 | ||
|
|
919906516d |
@@ -1,3 +1,8 @@
|
||||
All code from version 0.7 on
|
||||
Copyright (c) 2003,2004 Max Baker
|
||||
All rights reserved.
|
||||
|
||||
Original Code
|
||||
Copyright (c) 2002,2003 Regents of the University of California
|
||||
All rights reserved.
|
||||
|
||||
|
||||
95
ChangeLog
95
ChangeLog
@@ -1,6 +1,99 @@
|
||||
SNMP::Info - Perl5 OO Interface to Network Devices and SNMP MIBs
|
||||
SNMP::Info - Friendly OO-style interface to Network devices using SNMP.
|
||||
ChangeLog $Id$
|
||||
|
||||
verison 0.9 (11/15/04)
|
||||
+ ** Added full Nortel/Bay/BayStack support
|
||||
by new developer Eric Miller.
|
||||
L2::Bay now depricated.
|
||||
+ Added Alteon Ace support (Eric Miller)
|
||||
+ Added Nortel Cotivity support (Eric Miller)
|
||||
+ Added Nortel BayRS support (Eric Miller)
|
||||
+ Added Nortel Centillion support (Eric Miller)
|
||||
+ Added Nortel AP 222x support (Eric Miller)
|
||||
+ Added Orinco AP support (Eric Miller)
|
||||
+ Added i_lastchange() per suggestion of Nicolai Petri
|
||||
+ Added BULKWALK patch by Bradley Baetz - This should
|
||||
greatly speed up requests on SNMPv2c devices.
|
||||
+ Added MibDirs option to new() to allow specifying non-system MIB directories.
|
||||
|
||||
* Added C3560s to the C3550 class. Thanks to Nicolai.
|
||||
* Fixed Bug where older Cisco's would append nulls to certain
|
||||
CDP information. Would come up a 'DBD::Pg parser' error in Netdisco
|
||||
* Changed so a failed _global() call is cached so it won't retry
|
||||
an error over and over again if the same global is used.
|
||||
* Added check in _set() to see if data came from sub or FUNCS/GLOBALS
|
||||
Fails if came from sub.
|
||||
|
||||
version 0.8 (03/21/04)
|
||||
+ Added Q-BRIDGE-MIB support to SNMP::Info::Bridge
|
||||
+ Added Aironet AP4800 to Layer3::Aironet class
|
||||
+ Added C3500XL devices to the Layer2::C2900 class
|
||||
+ Added Cisco 3750 (37xxstack) to Layer3::C6500 class
|
||||
+ Added Cisco Catalyst 4000 to Layer3::C6500 class
|
||||
+ Added Cisco Catalyst 2970 to Layer3::C6500 Class
|
||||
* Made Cisco Commuinty string indexing a boolean method for clarification
|
||||
* Added VLAN info for HP devices using Q-BRIDGE-MIB
|
||||
* Fixed warning about uninitialized value in CiscoStats line 92
|
||||
* Added for more serial# checking for L2 and L3
|
||||
* Fixed warning in Layer2::Bay about non numeric port line 199
|
||||
Contributions from Dmitry Sergienko:
|
||||
+ Added Cisco Aironet BR500 and AP1200 to L2::Aironet Class
|
||||
* Fixed the Port name alias for Catalyst 2900 devices
|
||||
+ Added Support For ZyXEL DSLAMs and Allied Telesys Switches
|
||||
|
||||
version 0.7 (08/14/03)
|
||||
* 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
|
||||
$ipr = $dev->ipr_dest('128.114');
|
||||
* Added IP Routing Table entries from RFC1213 to SNMP::Info
|
||||
* minor bug fixes
|
||||
|
||||
version 0.4 (04/29/03)
|
||||
* BIG CHANGE ! Internal Data structure has changed.
|
||||
* Added clear_cache() method
|
||||
* Added NO_SUCH support for snmpget (TABLE) calls to get SNMP MIB II data
|
||||
from SNMP Version 1 devices.
|
||||
* Methods load_all() and all() have changed their return value. Sorry but the API had to change.
|
||||
* New object methods snmp_comm(), snmp_ver(), store(), class(), nosuch() to make it more OO happy.
|
||||
* Globals are now cached
|
||||
* Added new argument 'AutoSpecify' to new() to auto-connect with subclass
|
||||
detected in device_type()
|
||||
* New method specify() returns a new subclass object
|
||||
* Subclasses are automatically loaded when specify or autospecify is used!
|
||||
* Added methods for Interface statistics (ifInOctets ...)
|
||||
* Added methods for Memory and CPU statistics
|
||||
* Added SNMP::Info::Entity, moved out of L2-HP
|
||||
* Added SNMP::Info::Layer2::Aironet
|
||||
|
||||
version 0.3 (03/06/03)
|
||||
* Fixed HP model() warning
|
||||
* Added error checking for responses of NOSUCHOBJECT and NOSUCHINSTANCE in _global
|
||||
and _load_attr
|
||||
* Added more debugging
|
||||
* Added info and munging for c_capabilities in SNMP::Info::CD
|
||||
Thanks to Martin Lorensen <martin /at- lorensen.dk>
|
||||
* Removed requirement for SNMP in the Makefile.PL and moved it to t/prereq.t
|
||||
so that the Module will install via CPAN without trying to install the old
|
||||
4.2.0 version of SNMP on CPAN. Will now fail in the test phase.
|
||||
Thanks again to Martin Lorensen <martin /at- lorensen.dk>
|
||||
* Moved tests from test.pl to t/*
|
||||
|
||||
version 0.2 (02/19/03)
|
||||
* Added put_() methods and support for SNMP put commands
|
||||
* Added SNMP::Info::Layer3::C3550 class for Cisco Catalyst 3550
|
||||
|
||||
494
DeviceMatrix.txt
Normal file
494
DeviceMatrix.txt
Normal file
@@ -0,0 +1,494 @@
|
||||
# SNMP Device Compatibility Matrix
|
||||
# SNMP::Info - (C) 2004 Max Baker
|
||||
|
||||
# This file is meant to detail the cababilities
|
||||
# of network devices to supply data via SNMP.
|
||||
|
||||
# $Id: DeviceMatrix.txt,Modified by Eric Miller 10/17/2004
|
||||
|
||||
# Allied
|
||||
device-vendor: Allied Telesyn
|
||||
cdp:no
|
||||
|
||||
device-family: Allied Hubs
|
||||
class: Layer1::Allied
|
||||
ver: 1
|
||||
arpnip: no
|
||||
macsuck: no
|
||||
duplex: no
|
||||
|
||||
device: AT-3624T
|
||||
|
||||
device-family: AT-8000 Switches
|
||||
class: Layer2::Allied
|
||||
ver: 2
|
||||
macsuck: yes
|
||||
|
||||
# Asante
|
||||
device-vendor: Asante
|
||||
|
||||
device-family: Asante Hubs
|
||||
class: Layer1::Asante
|
||||
ver: 1
|
||||
arpnip: no
|
||||
macsuck: no
|
||||
duplex: no
|
||||
|
||||
device: 1012
|
||||
|
||||
# Bay
|
||||
device-vendor: Bay
|
||||
note: See Nortel
|
||||
|
||||
# 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, AP1200, C1100
|
||||
note: IOS based device
|
||||
class: Layer2::Aironet
|
||||
|
||||
device: BR500
|
||||
note: Aironet based device
|
||||
|
||||
device: AP350, AP340, CAP350, CAP340, 1200, AP4800
|
||||
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,2610XM,2611,2620,2620XM,2621
|
||||
|
||||
device:2621XM
|
||||
|
||||
device:2651XM
|
||||
|
||||
device:2691
|
||||
|
||||
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
|
||||
note: !CatOS ver 9.00.03 through 9.00.06 have problems when trunking. Upgrade to 9.00.07 or higher.
|
||||
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: Catlayst 2940
|
||||
|
||||
device: 2940-8TT
|
||||
|
||||
device-family: Catalyst 2950
|
||||
|
||||
device: 2950-t24
|
||||
|
||||
device-family: Catalyst 2970
|
||||
macsuck:vlan
|
||||
note: Acts just like IOS Catalyst 6500 series
|
||||
class: Layer3::C6500
|
||||
|
||||
device: 2970G-24T-E
|
||||
|
||||
device-family: Catalyst 3500 XL
|
||||
portmac: yes
|
||||
macsuck: vlan
|
||||
note: L2 only IOS devices - Just like Catalyst 2900 series from SNMP
|
||||
note: IOS Version 12.0(5)XP is buggy and doesn't do VLAN Community indexing correctly.
|
||||
class: Layer2::C2900
|
||||
|
||||
device: 3508GXL
|
||||
|
||||
device: 3524XL
|
||||
|
||||
device: 3548XL
|
||||
|
||||
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
|
||||
macsuck: vlan
|
||||
|
||||
device-family: Catalyst 3750
|
||||
class: Layer3::C6500
|
||||
|
||||
device-family: Catalyst 4000
|
||||
duplex: both
|
||||
macsuck: vlan
|
||||
class: Layer3::C6500
|
||||
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.
|
||||
note: !IOS Version 12.1.8a reported not to respond to BRIDGE-MIB calls.
|
||||
|
||||
device: wsc4006
|
||||
|
||||
device: 4507
|
||||
class: Layer3::C6500
|
||||
note: !Has serious slowdown/timeout problems with SNMP
|
||||
|
||||
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.
|
||||
note: !Problem with IOS 12.2.17d-SXB ... upgrade to -SXB1 or higher.
|
||||
|
||||
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: HP 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
|
||||
note: duplex issues?
|
||||
|
||||
device: 4104GL
|
||||
duplex: link
|
||||
|
||||
device: 4108GL,8000,2626,2650,8000
|
||||
note: VLAN info in Q-BRIDGE-MIB
|
||||
|
||||
# NORTEL
|
||||
device-vendor: Nortel Networks
|
||||
|
||||
device-family: BayStack Hub
|
||||
macsuck: yes
|
||||
duplex: both
|
||||
cdp: proprietary
|
||||
ver: 1
|
||||
class: Layer1::Bayhub
|
||||
note: !Uses proprietary MIBs to provide MAC to port mapping.
|
||||
|
||||
device: 102
|
||||
|
||||
device-family: Baystack Switch
|
||||
macsuck: yes
|
||||
duplex: both
|
||||
cdp: proprietary
|
||||
class: Layer2::Baystack
|
||||
|
||||
device: 303,304
|
||||
|
||||
device: 350
|
||||
|
||||
device: 380
|
||||
|
||||
device: 410
|
||||
|
||||
device: 420
|
||||
|
||||
device: 450
|
||||
note: !Some versions > 4.X in stacked configuration have SNMP timeout issues.
|
||||
note: Labels full duplex as 20Mbit connection.
|
||||
|
||||
device: 460,470
|
||||
|
||||
device: 5510,5520
|
||||
|
||||
device: BPS
|
||||
|
||||
device-family: Centillion
|
||||
macsuck: yes
|
||||
duplex: both
|
||||
cdp: proprietary
|
||||
class: Layer2::Centillion
|
||||
note: !Must be on version 4.x or 5.x (VLAN based) software.
|
||||
|
||||
device: 5000BH
|
||||
|
||||
device: 5005BH
|
||||
|
||||
device: C100
|
||||
|
||||
device: C50
|
||||
|
||||
device-family: AP222x
|
||||
macsuck: yes
|
||||
duplex: both
|
||||
cdp: proprietary
|
||||
class: Layer2::NAP222x
|
||||
note: !Upgrade to version 1.3 or higher.
|
||||
note: Sends out topology packets if enabled but does not build neighbor table.
|
||||
|
||||
device: AP-2220
|
||||
|
||||
device: AP-2221
|
||||
|
||||
device: AP-2225
|
||||
|
||||
device-family: Alteon AD
|
||||
arpnip: yes
|
||||
macsuck: yes
|
||||
duplex: both
|
||||
cdp: no
|
||||
class: Layer3::AlteonAD
|
||||
note: !Some versions have issues with continuous SNMP polling. Upgrade to 10.0.30.7 or higher.
|
||||
|
||||
device: AD2
|
||||
|
||||
device: AD3
|
||||
|
||||
device: AD4
|
||||
|
||||
device: 180
|
||||
|
||||
device: 183
|
||||
|
||||
device: 184
|
||||
|
||||
device-family: BayRS
|
||||
arpnip: yes
|
||||
macsuck: yes
|
||||
portmac: yes
|
||||
duplex: both
|
||||
cdp: no
|
||||
class: Layer3::BayRS
|
||||
|
||||
device: AN
|
||||
|
||||
device: ARN
|
||||
|
||||
device: ASN
|
||||
|
||||
device: BLN
|
||||
|
||||
device: Passport 2430
|
||||
|
||||
device: Passport 5430
|
||||
|
||||
device-family: Contivity
|
||||
arpnip: yes
|
||||
macsuck: no
|
||||
portmac: yes
|
||||
duplex: no
|
||||
cdp: no
|
||||
class: Layer3::Contivity
|
||||
|
||||
device: 100,400,600
|
||||
|
||||
device: 1000,1010,1050
|
||||
|
||||
device: 1500,1600,1700,1740
|
||||
|
||||
device: 2500,2600,2700
|
||||
|
||||
device: 4500,4600,5000
|
||||
|
||||
|
||||
device-family: Passport LAN
|
||||
arpnip: yes
|
||||
macsuck: yes
|
||||
portmac: yes
|
||||
duplex: both
|
||||
cdp: proprietary
|
||||
class: Layer3::Passport
|
||||
note: !Code versions < 3.2 vlan based mac-suck and are unsupported. Upgrade code.
|
||||
note: !3.2 code versions < 3.2.2.2 have Bridge MIB loop. Upgrade code.
|
||||
|
||||
device: 8603,8606,8610
|
||||
|
||||
device: 8610co
|
||||
|
||||
# Proxim
|
||||
device-vendor: Proxim
|
||||
|
||||
device-family: Orinoco
|
||||
macsuck: yes
|
||||
duplex: no
|
||||
cdp: no
|
||||
class: Layer2::Orinoco
|
||||
|
||||
device: AP-1000
|
||||
|
||||
device: AP-2000
|
||||
|
||||
device: WavePOINT-II
|
||||
|
||||
# Zyxel
|
||||
device-vendor: Zyxel
|
||||
class: Layer2::ZyXEL_DSLAM
|
||||
note: Doesn't report sysServices (layers)
|
||||
|
||||
device-family: Zyxel DSLAM
|
||||
|
||||
device:AAM10008-61, AAM1008-63
|
||||
159
Info/Bridge.pm
159
Info/Bridge.pm
@@ -1,8 +1,12 @@
|
||||
# SNMP::Info::Bridge
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2002,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:
|
||||
@@ -28,7 +32,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Bridge;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -44,15 +48,22 @@ $DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
$INIT = 0;
|
||||
%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress');
|
||||
|
||||
%MIBS = ('BRIDGE-MIB' => 'dot1dBaseBridgeAddress',
|
||||
'Q-BRIDGE-MIB' => 'dot1qPvid',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'b_mac' => 'dot1dBaseBridgeAddress',
|
||||
'b_ports' => 'dot1dBaseNumPorts',
|
||||
'b_type' => 'dot1dBaseType',
|
||||
'b_mac' => 'dot1dBaseBridgeAddress',
|
||||
'b_ports' => 'dot1dBaseNumPorts',
|
||||
'b_type' => 'dot1dBaseType',
|
||||
# Spanning Tree Protocol
|
||||
'stp_ver' => 'dot1dStpProtocolSpecification',
|
||||
'stp_ver' => 'dot1dStpProtocolSpecification',
|
||||
'stp_time' => 'dot1dStpTimeSinceTopologyChange',
|
||||
'stp_root' => 'dot1dStpDesignatedRoot',
|
||||
# Q-BRIDGE-MIB
|
||||
'qb_vlans_max' => 'dot1qMaxSupportedVlans',
|
||||
'qb_vlans' => 'dot1qNumVlans',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
@@ -76,12 +87,18 @@ $INIT = 0;
|
||||
'stp_p_root' => 'dot1dStpPortDesignatedRoot',
|
||||
'stp_p_bridge' => 'dot1dStpPortDesignatedBridge',
|
||||
'stp_p_port' => 'dot1dStpPortDesignatedPort',
|
||||
# Q-BRIDGE-MIB :
|
||||
'qb_i_vlan' => 'dot1qPvid',
|
||||
'qb_i_vlan_type' => 'dot1qPortAcceptableFrameTypes',
|
||||
'qb_v_name' => 'dot1qVlanStaticName',
|
||||
'qb_v_stat' => 'dot1qVlanStaticRowStatus',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::MUNGE,
|
||||
# Add ones for our class
|
||||
'b_mac' => \&SNMP::Info::munge_mac,
|
||||
'fw_mac' => \&SNMP::Info::munge_mac,
|
||||
'bs_mac' => \&SNMP::Info::munge_mac,
|
||||
'stp_root' => \&SNMP::Info::munge_mac,
|
||||
@@ -115,13 +132,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Bridge - Perl5 Interface to BRIDGE-MIB
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
BRIDGE-MIB is used by most Layer 2 devices like Switches
|
||||
|
||||
Inherits all methods from SNMP::Info
|
||||
SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB (RFC1493)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -129,40 +140,66 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $bridge = new SNMP::Info::Bridge(DestHost => 'myswitch',
|
||||
Community => 'public');
|
||||
my $mac = $bridge->mac();
|
||||
my $bridge = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'switch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $cdp->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
# Grab Forwarding Tables
|
||||
my $interfaces = $bridge->interfaces();
|
||||
my $fw_mac = $bridge->fw_mac();
|
||||
my $fw_port = $bridge->fw_port();
|
||||
my $bp_index = $bridge->bp_index();
|
||||
|
||||
foreach my $fw_index (keys %$fw_mac){
|
||||
my $mac = $fw_mac->{$fw_index};
|
||||
my $bp_id = $fw_port->{$fw_index};
|
||||
my $iid = $bp_index->{$bp_id};
|
||||
my $port = $interfaces->{$iid};
|
||||
|
||||
print "Port:$port forwarding to $mac\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
BRIDGE-MIB is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info.
|
||||
|
||||
Q-BRIDGE-MIB holds 802.11q information -- VLANs and Trunking. Cisco tends not to use this MIB, but some
|
||||
proprietary ones. HP and some nicer vendors use this. This is from C<RFC2674_q>.
|
||||
|
||||
Create or use a subclass of SNMP::Info that inherits this class. Do not use directly.
|
||||
|
||||
For debugging you can call new() directly as you would in SNMP::Info
|
||||
|
||||
my $bridge = new SNMP::Info::Bridge(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Bridge()
|
||||
=item BRIDGE-MIB
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item Q-BRIDGE-MIB
|
||||
|
||||
my $bridge = new SNMP::Info::Bridge(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $bridge;
|
||||
|
||||
=item $bridge->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $bridge->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$bridge->session($newsession);
|
||||
f<rfc2674_q.mib>
|
||||
|
||||
=back
|
||||
|
||||
=head1 Bridge Global Configuration Values
|
||||
BRIDGE-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
@@ -202,9 +239,22 @@ Returns root of STP.
|
||||
|
||||
(B<dot1dStpDesignatedRoot>)
|
||||
|
||||
=item $bridge->qb_vlans_max()
|
||||
|
||||
(B<dot1qMaxSupportedVlans>)
|
||||
|
||||
=item $bridge->qb_vlans()
|
||||
|
||||
Number of VLANS on this device.
|
||||
|
||||
(B<dot1qNumVlans>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Forwarding Table (dot1dTpFdbEntry)
|
||||
|
||||
@@ -315,4 +365,35 @@ this port's segment."
|
||||
|
||||
=back
|
||||
|
||||
=head2 Q-BRIDGE Data
|
||||
|
||||
=over
|
||||
|
||||
=item $bridge->qb_i_vlan()
|
||||
|
||||
Gives the vlan used by interfaces
|
||||
|
||||
(B<dot1qPvid>)
|
||||
|
||||
=item $bridge->qb_i_vlan_type()
|
||||
|
||||
Either C<admitAll> or C<admitOnlyVlanTagged>. This is a good spot to find
|
||||
trunk ports.
|
||||
|
||||
(B<dot1qPortAcceptableFrameTypes>)
|
||||
|
||||
=item $bridge->qb_v_name()
|
||||
|
||||
Human-entered name for vlans.
|
||||
|
||||
(B<dot1qVlanStaticName>)
|
||||
|
||||
=item $bridge->qb_v_stat()
|
||||
|
||||
uhh. C<active> !
|
||||
|
||||
(B<dot1qVlanStaticRowStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
295
Info/CDP.pm
295
Info/CDP.pm
@@ -1,6 +1,9 @@
|
||||
# SNMP::Info::CDP
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +31,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::CDP;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -59,7 +62,7 @@ $INIT = 0;
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
'c_if' => 'cdpCacheIfIndex',
|
||||
'c_index' => 'cdpCacheIfIndex',
|
||||
'c_proto' => 'cdpCacheAddressType',
|
||||
'c_ip' => 'cdpCacheAddress',
|
||||
'c_ver' => 'cdpCacheVersion',
|
||||
@@ -73,11 +76,32 @@ $INIT = 0;
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'c_capabilities' => \&SNMP::Info::munge_octet2hex,
|
||||
'c_capabilities' => \&munge_caps,
|
||||
'c_platform' => \&munge_null,
|
||||
'c_domain' => \&munge_null,
|
||||
'c_port' => \&munge_null,
|
||||
'c_id' => \&munge_null,
|
||||
'c_ver' => \&munge_null,
|
||||
'c_ip' => \&SNMP::Info::munge_ip
|
||||
);
|
||||
|
||||
# munge_null() - removes nulls (\0)
|
||||
sub munge_null {
|
||||
my $text = shift || return;
|
||||
|
||||
$text =~ s/\0//g;
|
||||
return $text;
|
||||
}
|
||||
|
||||
sub munge_caps {
|
||||
my $caps = shift;
|
||||
return undef unless defined $caps;
|
||||
|
||||
my $bits = substr(unpack("B*",$caps),-7);
|
||||
return $bits;
|
||||
|
||||
|
||||
}
|
||||
sub hasCDP {
|
||||
my $cdp = shift;
|
||||
|
||||
@@ -94,6 +118,34 @@ sub hasCDP {
|
||||
|
||||
return $cdp->cdp_run();
|
||||
}
|
||||
|
||||
sub c_if {
|
||||
my $cdp = shift;
|
||||
|
||||
# See if by some miracle Cisco implemented the cdpCacheIfIndex entry
|
||||
my $c_index = $cdp->c_index();
|
||||
return $c_index if defined $c_index;
|
||||
|
||||
# Nope, didn't think so. Now we fake it.
|
||||
my $c_ip = $cdp->c_ip();
|
||||
unless (defined $c_ip){
|
||||
$cdp->{error} = "SNMP::Info::CDP::c_if() - Device doesn't have c_ip() data. Can't fake c_index()";
|
||||
$DEBUG and carp($cdp->error(1));
|
||||
return undef;
|
||||
}
|
||||
|
||||
my %c_if;
|
||||
foreach my $key (keys %$c_ip){
|
||||
next unless defined $key;
|
||||
my $iid = $key;
|
||||
# Truncate .1 from cdp cache entry
|
||||
$iid =~ s/\.\d+$//;
|
||||
$c_if{$key} = $iid;
|
||||
}
|
||||
|
||||
return \%c_if;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
@@ -101,56 +153,69 @@ __END__
|
||||
|
||||
SNMP::Info::CDP - Perl5 Interface to Cisco Discovery Protocol (CDP) using SNMP
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
CDP provides Layer 2 discovery of attached devices that also
|
||||
speak CDP, including switches, routers and hubs.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $cdp = new SNMP::Info::CDP( DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
|
||||
@neighbor_ips = values( %{$cdp->ip()} );
|
||||
my $cdp = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'router',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $cdp->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
=over
|
||||
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
|
||||
|
||||
=item new SNMP::Info::CDP()
|
||||
# Print out a map of device ports with CDP neighbors:
|
||||
my $interfaces = $cdp->interfaces();
|
||||
my $c_if = $cdp->c_if();
|
||||
my $c_ip = $cdp->c_ip();
|
||||
my $c_port = $cdp->c_port();
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
foreach my $cdp_key (keys %$c_ip){
|
||||
my $iid = $c_if->{$cdp_key};
|
||||
my $port = $interfaces->{$iid};
|
||||
my $neighbor = $c_ip->{$cdp_key};
|
||||
my $neighbor_port = $c_port->{$cdp_key};
|
||||
print "Port : $port connected to $neighbor / $neighbor_port\n";
|
||||
}
|
||||
|
||||
my $cdp = new SNMP::Info::CDP(
|
||||
DestHost => $host,
|
||||
Community => 'public'
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $cdp;
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=item $cdp->session()
|
||||
SNMP::Info::CDP is a subclass of SNMP::Info that provides an object oriented
|
||||
interface to CDP information through SNMP.
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP,
|
||||
mostly switches and routers. CDP is implemented in Cisco and some HP devices.
|
||||
|
||||
# Get
|
||||
my $sess = $cdp->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$cdp->session($newsession);
|
||||
|
||||
=back
|
||||
|
||||
=head2 Your Device May Vary
|
||||
Create or use a device subclass that inherits this class. Do not use directly.
|
||||
|
||||
Each device implements a subset of the global and cache entries.
|
||||
Check the return value to see if that data is held by the device.
|
||||
|
||||
=head1 CDP GLOBAL VALUES
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-CDP-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
@@ -162,7 +227,8 @@ Accounts for SNMP version 1 devices which may have CDP but not cdp_run()
|
||||
|
||||
=item $cdp->cdp_run()
|
||||
|
||||
Is CDP enabled on this device?
|
||||
Is CDP enabled on this device? Note that a lot of Cisco devices that implement
|
||||
CDP don't implement this value. @#%$!
|
||||
|
||||
(B<cdpGlobalRun>)
|
||||
|
||||
@@ -188,51 +254,44 @@ This is the device id broadcast via CDP to other devices, and is what is retriev
|
||||
|
||||
=back
|
||||
|
||||
=head1 CDP CACHE ENTRIES
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 CDP CACHE ENTRIES
|
||||
|
||||
=over
|
||||
|
||||
=item $cdp->c_proto()
|
||||
|
||||
Returns remote address type received. Usually IP.
|
||||
|
||||
(B<cdpCacheAddressType>)
|
||||
|
||||
=item $cdp->c_ip()
|
||||
|
||||
Returns remote IP address
|
||||
|
||||
(B<cdpCacheAddress>)
|
||||
|
||||
=item $cdp->c_ver()
|
||||
|
||||
Returns remote hardware version
|
||||
|
||||
(B<cdpCacheVersion>)
|
||||
|
||||
=item $cdp->c_id()
|
||||
|
||||
Returns remote device id string
|
||||
|
||||
(B<cdpCacheDeviceId>)
|
||||
|
||||
=item $cdp->c_port()
|
||||
|
||||
Returns remote port ID
|
||||
|
||||
(B<cdpDevicePort>)
|
||||
|
||||
=item $cdp->c_platform()
|
||||
|
||||
Returns remote platform id
|
||||
|
||||
(B<cdpCachePlatform>)
|
||||
|
||||
=item $cdp->c_capabilities()
|
||||
|
||||
Returns Device Functional Capabilities bitmap.
|
||||
Returns Device Functional Capabilities. Results are munged into an ascii
|
||||
binary string, 7 digits long, MSB. Each digit represents a bit from the
|
||||
table below.
|
||||
|
||||
Anyone know where I can get info on how to decode this?
|
||||
From L<http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#18843>:
|
||||
|
||||
(Bit) - Description
|
||||
|
||||
=over
|
||||
|
||||
=item (0x40) - Provides level 1 functionality.
|
||||
|
||||
=item (0x20) - The bridge or switch does not forward IGMP Report packets on nonrouter ports.
|
||||
|
||||
=item (0x10) - Sends and receives packets for at least one network layer protocol. If the device is routing the protocol, this bit should not be set.
|
||||
|
||||
=item (0x08) - Performs level 2 switching. The difference between this bit and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This device is assumed to be deployed in a physical loop-free topology.
|
||||
|
||||
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge would set both this bit and bit 0x02.
|
||||
|
||||
=item (0x02) - Performs level 2 transparent bridging.
|
||||
|
||||
=item (0x01) - Performs level 3 routing for at least one network layer protocol.
|
||||
|
||||
=back
|
||||
|
||||
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to this information.
|
||||
|
||||
(B<cdpCacheCapabilities>)
|
||||
|
||||
@@ -242,18 +301,92 @@ Returns remote VTP Management Domain as defined in CISCO-VTP-MIB::managementDoma
|
||||
|
||||
(B<cdpCacheVTPMgmtDomain>)
|
||||
|
||||
=item $cdp->c_vlan()
|
||||
|
||||
Returns the remote interface native VLAN.
|
||||
|
||||
(B<cdpCacheNativeVLAN>)
|
||||
|
||||
=item $cdp->c_duplex()
|
||||
|
||||
Returns the port duplex status from remote devices.
|
||||
|
||||
(B<cdpCacheDuplex>)
|
||||
|
||||
=item $cdp->c_id()
|
||||
|
||||
Returns remote device id string
|
||||
|
||||
(B<cdpCacheDeviceId>)
|
||||
|
||||
=item $cdp->c_if()
|
||||
|
||||
Returns the mapping to the SNMP Interface Table.
|
||||
|
||||
Note that a lot devices don't implement $cdp->c_index(), So if it isn't around,
|
||||
we fake it.
|
||||
|
||||
In order to map the cdp table entry back to the interfaces() entry, we truncate the last number
|
||||
off of it :
|
||||
|
||||
# it exists, yay.
|
||||
my $c_index = $device->c_index();
|
||||
return $c_index if defined $c_index;
|
||||
|
||||
# if not, let's fake it
|
||||
my $c_ip = $device->c_ip();
|
||||
|
||||
my %c_if
|
||||
foreach my $key (keys %$c_ip){
|
||||
$iid = $key;
|
||||
## Truncate off .1 from cdp response
|
||||
$iid =~ s/\.\d+$//;
|
||||
$c_if{$key} = $iid;
|
||||
}
|
||||
|
||||
return \%c_if;
|
||||
|
||||
|
||||
=item $cdp->c_index()
|
||||
|
||||
Returns the mapping to the SNMP2 Interface table for CDP Cache Entries.
|
||||
|
||||
Most devices don't implement this, so you probably want to use $cdp->c_if() instead.
|
||||
|
||||
See c_if() entry.
|
||||
|
||||
(B<cdpCacheIfIndex>)
|
||||
|
||||
=item $cdp->c_ip()
|
||||
|
||||
Returns remote IP address
|
||||
|
||||
(B<cdpCacheAddress>)
|
||||
|
||||
=item $cdp->c_platform()
|
||||
|
||||
Returns remote platform id
|
||||
|
||||
(B<cdpCachePlatform>)
|
||||
|
||||
=item $cdp->c_port()
|
||||
|
||||
Returns remote port ID
|
||||
|
||||
(B<cdpDevicePort>)
|
||||
|
||||
=item $cdp->c_proto()
|
||||
|
||||
Returns remote address type received. Usually IP.
|
||||
|
||||
(B<cdpCacheAddressType>)
|
||||
|
||||
=item $cdp->c_ver()
|
||||
|
||||
Returns remote hardware version
|
||||
|
||||
(B<cdpCacheVersion>)
|
||||
|
||||
=item $cdp->c_vlan()
|
||||
|
||||
Returns the remote interface native VLAN.
|
||||
|
||||
(B<cdpCacheNativeVLAN>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
706
Info/CiscoStack.pm
Normal file
706
Info/CiscoStack.pm
Normal file
@@ -0,0 +1,706 @@
|
||||
# SNMP::Info::CiscoStack
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c)2003,2004 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.9;
|
||||
# $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',
|
||||
'CISCO-PORT-SECURITY-MIB' => 'ciscoPortSecurityMIB',
|
||||
);
|
||||
|
||||
%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',
|
||||
# CISCO-PORT-SECURITY-MIB
|
||||
'cps_clear' => 'cpsGlobalClearSecureMacAddresses',
|
||||
'cps_notify' => 'cpsGlobalSNMPNotifControl',
|
||||
'cps_rate' => 'cpsGlobalSNMPNotifRate',
|
||||
'cps_enable' => 'cpsGlobalPortSecurityEnable',
|
||||
'cps_mac_count' => 'cpsGlobalTotalSecureAddress',
|
||||
'cps_mac_max' => 'cpsGlobalMaxSecureAddress',
|
||||
);
|
||||
|
||||
%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-PORT-SECURITY-MIB::cpsIfConfigTable
|
||||
'cps_i_limit_val' => 'cpsIfInvalidSrcRateLimitValue',
|
||||
'cps_i_limit' => 'cpsIfInvalidSrcRateLimitEnable',
|
||||
'cps_i_sticky' => 'cpsIfStickyEnable',
|
||||
'cps_i_clear_type' => 'cpsIfClearSecureMacAddresses',
|
||||
'cps_i_shutdown' => 'cpsIfShutdownTimeout',
|
||||
'cps_i_flood' => 'cpsIfUnicastFloodingEnable',
|
||||
'cps_i_clear' => 'cpsIfClearSecureAddresses',
|
||||
'cps_i_mac' => 'cpsIfSecureLastMacAddress',
|
||||
'cps_i_count' => 'cpsIfViolationCount',
|
||||
'cps_i_action' => 'cpsIfViolationAction',
|
||||
'cps_i_mac_static' => 'cpsIfStaticMacAddrAgingEnable',
|
||||
'cps_i_mac_type' => 'cpsIfSecureMacAddrAgingType',
|
||||
'cps_i_mac_age' => 'cpsIfSecureMacAddrAgingTime',
|
||||
'cps_i_mac_count' => 'cpsIfCurrentSecureMacAddrCount',
|
||||
'cps_i_mac_max' => 'cpsIfMaxSecureMacAddr',
|
||||
'cps_i_status' => 'cpsIfPortSecurityStatus',
|
||||
'cps_i_enable' => 'cpsIfPortSecurityEnable',
|
||||
# CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
|
||||
'cps_i_v_mac_count' => 'cpsIfVlanCurSecureMacAddrCount',
|
||||
'cps_i_v_mac_max' => 'cpsIfVlanMaxSecureMacAddr',
|
||||
'cps_i_v' => 'cpsIfVlanIndex',
|
||||
# CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
|
||||
'cps_i_v_mac_status' => 'cpsIfVlanSecureMacAddrRowStatus',
|
||||
'cps_i_v_mac_age' => 'cpsIfVlanSecureMacAddrRemainAge',
|
||||
'cps_i_v_mac_type' => 'cpsIfVlanSecureMacAddrType',
|
||||
'cps_i_v_vlan' => 'cpsIfVlanSecureVlanIndex',
|
||||
'cps_i_v_mac' => 'cpsIfVlanSecureMacAddress',
|
||||
# CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
|
||||
'cps_m_status' => 'cpsSecureMacAddrRowStatus',
|
||||
'cps_m_age' => 'cpsSecureMacAddrRemainingAge',
|
||||
'cps_m_type' => 'cpsSecureMacAddrType',
|
||||
'cps_m_mac' => 'cpsSecureMacAddress',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
'cps_i_mac' => \&SNMP::Info::munge_mac,
|
||||
'cps_m_mac' => \&SNMP::Info::munge_mac,
|
||||
'cps_i_v_mac' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
%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 - Intefaces to data from CISCO-STACK-MIB and CISCO-PORT-SECURITY-MIB
|
||||
|
||||
=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
|
||||
|
||||
=item CISCO-PORT-SECURITY-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz or from
|
||||
Netdisco-mib package at netdisco.org.
|
||||
|
||||
=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
|
||||
|
||||
=head2 CISCO-PORT-SECURITY-MIB globals
|
||||
|
||||
See CISCO-PORT-SECURITY-MIB for details.
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->cps_clear()
|
||||
|
||||
B<cpsGlobalClearSecureMacAddresses>
|
||||
|
||||
=item $stack->cps_notify()
|
||||
|
||||
B<cpsGlobalSNMPNotifControl>
|
||||
|
||||
=item $stack->cps_rate()
|
||||
|
||||
B<cpsGlobalSNMPNotifRate>
|
||||
|
||||
=item $stack->cps_enable()
|
||||
|
||||
B<cpsGlobalPortSecurityEnable>
|
||||
|
||||
=item $stack->cps_mac_count()
|
||||
|
||||
B<cpsGlobalTotalSecureAddress>
|
||||
|
||||
=item $stack->cps_mac_max()
|
||||
|
||||
B<cpsGlobalMaxSecureAddress>
|
||||
|
||||
=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
|
||||
|
||||
|
||||
=head2 CISCO-PORT-SECURITY-MIB - Interface Config Table
|
||||
|
||||
See CISCO-PORT-SECURITY-MIB for details.
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->cps_i_limit_val()
|
||||
|
||||
B<cpsIfInvalidSrcRateLimitValue>
|
||||
|
||||
=item $stack->cps_i_limit()
|
||||
|
||||
B<cpsIfInvalidSrcRateLimitEnable>
|
||||
|
||||
=item $stack->cps_i_sticky()
|
||||
|
||||
B<cpsIfStickyEnable>
|
||||
|
||||
=item $stack->cps_i_clear_type()
|
||||
|
||||
B<cpsIfClearSecureMacAddresses>
|
||||
|
||||
=item $stack->cps_i_shutdown()
|
||||
|
||||
B<cpsIfShutdownTimeout>
|
||||
|
||||
=item $stack->cps_i_flood()
|
||||
|
||||
B<cpsIfUnicastFloodingEnable>
|
||||
|
||||
=item $stack->cps_i_clear()
|
||||
|
||||
B<cpsIfClearSecureAddresses>
|
||||
|
||||
=item $stack->cps_i_mac()
|
||||
|
||||
B<cpsIfSecureLastMacAddress>
|
||||
|
||||
=item $stack->cps_i_count()
|
||||
|
||||
B<cpsIfViolationCount>
|
||||
|
||||
=item $stack->cps_i_action()
|
||||
|
||||
B<cpsIfViolationAction>
|
||||
|
||||
=item $stack->cps_i_mac_static()
|
||||
|
||||
B<cpsIfStaticMacAddrAgingEnable>
|
||||
|
||||
=item $stack->cps_i_mac_type()
|
||||
|
||||
B<cpsIfSecureMacAddrAgingType>
|
||||
|
||||
=item $stack->cps_i_mac_age()
|
||||
|
||||
B<cpsIfSecureMacAddrAgingTime>
|
||||
|
||||
=item $stack->cps_i_mac_count()
|
||||
|
||||
B<cpsIfCurrentSecureMacAddrCount>
|
||||
|
||||
=item $stack->cps_i_mac_max()
|
||||
|
||||
B<cpsIfMaxSecureMacAddr>
|
||||
|
||||
=item $stack->cps_i_status()
|
||||
|
||||
B<cpsIfPortSecurityStatus>
|
||||
|
||||
=item $stack->cps_i_enable()
|
||||
|
||||
B<cpsIfPortSecurityEnable>
|
||||
|
||||
=back
|
||||
|
||||
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanTable
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->cps_i_v_mac_count()
|
||||
|
||||
B<cpsIfVlanCurSecureMacAddrCount>
|
||||
|
||||
=item $stack->cps_i_v_mac_max()
|
||||
|
||||
B<cpsIfVlanMaxSecureMacAddr>
|
||||
|
||||
=item $stack->cps_i_v()
|
||||
|
||||
B<cpsIfVlanIndex>
|
||||
|
||||
=back
|
||||
|
||||
=head2 CISCO-PORT-SECURITY-MIB::cpsIfVlanSecureMacAddrTable
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->cps_i_v_mac_status()
|
||||
|
||||
B<cpsIfVlanSecureMacAddrRowStatus>
|
||||
|
||||
=item $stack->cps_i_v_mac_age()
|
||||
|
||||
B<cpsIfVlanSecureMacAddrRemainAge>
|
||||
|
||||
=item $stack->cps_i_v_mac_type()
|
||||
|
||||
B<cpsIfVlanSecureMacAddrType>
|
||||
|
||||
=item $stack->cps_i_v_vlan()
|
||||
|
||||
B<cpsIfVlanSecureVlanIndex>
|
||||
|
||||
=item $stack->cps_i_v_mac()
|
||||
|
||||
B<cpsIfVlanSecureMacAddress>
|
||||
|
||||
=back
|
||||
|
||||
=head2 CISCO-PORT-SECURITY-MIB::cpsSecureMacAddressTable
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->cps_m_status()
|
||||
|
||||
B<cpsSecureMacAddrRowStatus>
|
||||
|
||||
=item $stack->cps_m_age()
|
||||
|
||||
B<cpsSecureMacAddrRemainingAge>
|
||||
|
||||
=item $stack->cps_m_type()
|
||||
|
||||
B<cpsSecureMacAddrType>
|
||||
|
||||
=item $stack->cps_m_mac()
|
||||
|
||||
B<cpsSecureMacAddress>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
273
Info/CiscoStats.pm
Normal file
273
Info/CiscoStats.pm
Normal file
@@ -0,0 +1,273 @@
|
||||
# SNMP::Info::CiscoStats
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Changes since Version 0.7 Copyright (c) 2004 Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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::CiscoStats;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
|
||||
@SNMP::Info::CiscoStats::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::CiscoStats::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
$INIT = 0;
|
||||
%MIBS = (
|
||||
'RFC1213-MIB' => 'sysDescr',
|
||||
'CISCO-PROCESS-MIB' => 'cpmCPUTotal5sec',
|
||||
'CISCO-MEMORY-POOL-MIB' => 'ciscoMemoryPoolUsed'
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'description' => 'sysDescr',
|
||||
# We will use the numeric OID's so that we don't require people
|
||||
# to install v1 MIBs, which can conflict.
|
||||
# OLD-CISCO-CPU-MIB:avgBusyPer
|
||||
'ios_cpu' => '1.3.6.1.4.1.9.2.1.56.0',
|
||||
'ios_cpu_1min' => '1.3.6.1.4.1.9.2.1.57.0',
|
||||
'ios_cpu_5min' => '1.3.6.1.4.1.9.2.1.58.0',
|
||||
# CISCO-PROCESS-MIB
|
||||
'cat_cpu' => 'cpmCPUTotal5sec.9',
|
||||
'cat_cpu_1min' => 'cpmCPUTotal1min.9',
|
||||
'cat_cpu_5min' => 'cpmCPUTotal5min.9',
|
||||
# CISCO-MEMORY-POOL-MIB
|
||||
'mem_free' => 'ciscoMemoryPoolFree.1',
|
||||
'mem_used' => 'ciscoMemoryPoolUsed.1',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
);
|
||||
|
||||
sub os {
|
||||
my $l2 = shift;
|
||||
my $descr = $l2->description();
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $l2 = shift;
|
||||
my $os = $l2->os();
|
||||
my $descr = $l2->description();
|
||||
|
||||
# Older Catalysts
|
||||
if (defined $os and $os eq 'catalyst' and defined $descr and $descr =~ m/V(\d{1}\.\d{2}\.\d{2})/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
# Newer Catalysts and IOS devices
|
||||
if (defined $descr and $descr =~ m/Version (\d+\.\d+\([^)]+\)[^,\s]*)(,|\s)+/ ){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub cpu {
|
||||
my $self = shift;
|
||||
my $ios_cpu = $self->ios_cpu();
|
||||
return $ios_cpu if defined $ios_cpu;
|
||||
my $cat_cpu = $self->cat_cpu();
|
||||
return $cat_cpu;
|
||||
}
|
||||
|
||||
sub cpu_1min {
|
||||
my $self = shift;
|
||||
my $ios_cpu_1min = $self->ios_cpu_1min();
|
||||
return $ios_cpu_1min if defined $ios_cpu_1min;
|
||||
my $cat_cpu_1min = $self->cat_cpu_1min();
|
||||
return $cat_cpu_1min;
|
||||
}
|
||||
|
||||
sub cpu_5min {
|
||||
my $self = shift;
|
||||
my $ios_cpu_5min = $self->ios_cpu_5min();
|
||||
return $ios_cpu_5min if defined $ios_cpu_5min;
|
||||
my $cat_cpu_5min = $self->cat_cpu_5min();
|
||||
return $cat_cpu_5min;
|
||||
}
|
||||
|
||||
sub mem_total {
|
||||
my $self = shift;
|
||||
my $mem_free = $self->mem_free();
|
||||
my $mem_used = $self->mem_used();
|
||||
return undef unless defined $mem_free and defined $mem_used;
|
||||
return $mem_free + $mem_used;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::CiscoStats - 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::CiscoStats is a subclass of SNMP::Info that provides cpu, memory, os and
|
||||
version information about Cisco Devices.
|
||||
|
||||
Use or create in a subclass of SNMP::Info. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
none.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-PROCESS-MIB
|
||||
|
||||
=item CISCO-MEMORY-POOL-MIB
|
||||
|
||||
=item RFC1213-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $ciscostats->cpu()
|
||||
|
||||
Returns ios_cpu() or cat_cpu(), whichever is available.
|
||||
|
||||
=item $ciscostats->cpu_1min()
|
||||
|
||||
Returns ios_cpu_1min() or cat_cpu1min(), whichever is available.
|
||||
|
||||
=item $ciscostats->cpu_5min()
|
||||
|
||||
Returns ios_cpu_5min() or cat_cpu5min(), whichever is available.
|
||||
|
||||
=item $ciscostats->mem_total()
|
||||
|
||||
Returns mem_free() + mem_used()
|
||||
|
||||
=item $ciscostats->os()
|
||||
|
||||
Trys to parse if device is running IOS or CatOS from description()
|
||||
|
||||
=item $ciscostats->os_ver()
|
||||
|
||||
Trys to parse device operating system version from description()
|
||||
|
||||
=item $ciscostats->ios_cpu()
|
||||
|
||||
Current CPU usage in percents of device.
|
||||
|
||||
B<1.3.6.1.4.1.9.2.1.56.0> =
|
||||
B<OLD-CISCO-CPU-MIB:avgBusyPer>
|
||||
|
||||
=item $ciscostats->ios_cpu_1min()
|
||||
|
||||
Average CPU Usage in percents of device over last minute.
|
||||
|
||||
B<1.3.6.1.4.1.9.2.1.57.0>
|
||||
|
||||
=item $ciscostats->ios_cpu_5min()
|
||||
|
||||
Average CPU Usage in percents of device over last 5 minutes.
|
||||
|
||||
B<1.3.6.1.4.1.9.2.1.58.0>
|
||||
|
||||
=item $ciscostats->cat_cpu()
|
||||
|
||||
Current CPU usage in percents of device.
|
||||
|
||||
B<CISCO-PROCESS-MIB::cpmCPUTotal5sec.9>
|
||||
|
||||
=item $ciscostats->cat_cpu_1min()
|
||||
|
||||
Average CPU Usage in percents of device over last minute.
|
||||
|
||||
B<CISCO-PROCESS-MIB::cpmCPUTotal1min.9>
|
||||
|
||||
=item $ciscostats->cat_cpu_5min()
|
||||
|
||||
Average CPU Usage in percents of device over last 5 minutes.
|
||||
|
||||
B<CISCO-PROCESS-MIB::cpmCPUTotal5min.9>
|
||||
|
||||
=item $ciscostats->mem_free()
|
||||
|
||||
Main DRAM free in device. In bytes.
|
||||
|
||||
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolFree.1>
|
||||
|
||||
=item $ciscostats->mem_used()
|
||||
|
||||
Main DRAM used in device. In bytes.
|
||||
|
||||
B<CISCO-MEMORY-POOL-MIB::ciscoMemoryPoolUsed.1>
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
None.
|
||||
|
||||
=cut
|
||||
411
Info/CiscoVTP.pm
Normal file
411
Info/CiscoVTP.pm
Normal file
@@ -0,0 +1,411 @@
|
||||
# SNMP::Info::CiscoVTP
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# 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.9;
|
||||
# $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',
|
||||
'CISCO-VLAN-MEMBERSHIP-MIB' => 'vmMembershipEntry',
|
||||
'CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB' => 'cviRoutedVlanIfIndex',
|
||||
);
|
||||
|
||||
%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',
|
||||
|
||||
# CISCO-VLAN-MEMBERSHIP-MIB
|
||||
# VmMembershipTable
|
||||
'i_vlan_type' => 'vmVlanType',
|
||||
'i_vlan2' => 'vmVlan',
|
||||
'i_vlan_stat' => 'vmPortStatus',
|
||||
'i_vlan_1' => 'vmVlans',
|
||||
'i_vlan_2' => 'vmVlans2k',
|
||||
'i_vlan_3' => 'vmVlans3k',
|
||||
'i_vlan_4' => 'vmVlans4k',
|
||||
|
||||
# CISCO-VLAN-IFTABLE-RELATIONSHIP-MIB
|
||||
'v_cvi_if' => 'cviRoutedVlanIfIndex',
|
||||
|
||||
# TODO Add these tables if someone wants them..
|
||||
# vtpEditControlTable
|
||||
# vtpVlanEditTable
|
||||
# vtpStatsTable
|
||||
# vlanTrunkPortTable
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
);
|
||||
|
||||
|
||||
sub i_vlan {
|
||||
my $vtp = shift;
|
||||
|
||||
# Check for CISCO-VLAN-MIB
|
||||
my $i_vlan = $vtp->i_vlan2();
|
||||
return $i_vlan if defined $i_vlan;
|
||||
|
||||
# Check in CISCO-VLAN-IFTABLE-RELATION-MIB
|
||||
my $v_cvi_if = $vtp->v_cvi_if();
|
||||
return undef unless defined $v_cvi_if;
|
||||
|
||||
# Translate vlan.physical_interface -> iid
|
||||
# to iid -> vlan
|
||||
$i_vlan = {};
|
||||
foreach my $i (keys %$v_cvi_if){
|
||||
my ($vlan,$phys) = split(/\./,$i);
|
||||
my $iid = $v_cvi_if->{$i};
|
||||
|
||||
$i_vlan->{$iid}=$vlan;
|
||||
}
|
||||
|
||||
return $i_vlan;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::CiscoVTP - Perl5 Interface to Cisco's VLAN Management MIBs
|
||||
|
||||
=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 cisco device's VLAN and VTP Domain memebership.
|
||||
|
||||
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
|
||||
|
||||
=item CISCO-VLAN-MEMBERSHIP-MIB
|
||||
|
||||
=item CISCO-VLAN-IFTABLE-RELATIONSHIP-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
|
||||
|
||||
This table is from CISCO-VTP-MIB::vtpVlanTable
|
||||
|
||||
=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 VLAN Interface Table
|
||||
|
||||
This table is from CISCO-VLAN-MEMBERSHIP-MIB::VmMembershipTable
|
||||
|
||||
=over
|
||||
|
||||
=item $vtp->i_vlan_type()
|
||||
|
||||
Static, Dynamic, or multiVlan.
|
||||
|
||||
C<vmVlanType>
|
||||
|
||||
=item $vtp->i_vlan()
|
||||
|
||||
The VLAN that a port is assigned to.
|
||||
|
||||
0 for no VLAN assigned.
|
||||
|
||||
C<vmVlan>
|
||||
|
||||
=item $vtp->i_vlan_stat()
|
||||
|
||||
Inactive, active, shutdown.
|
||||
|
||||
C<vmPortStatus>
|
||||
|
||||
=item $vtp->i_vlan_1()
|
||||
|
||||
Each bit represents a VLAN. This is 0 through 1023
|
||||
|
||||
C<vmVlans>
|
||||
|
||||
=item $vtp->i_vlan_2()
|
||||
|
||||
Each bit represents a VLAN. This is 1024 through 2047
|
||||
|
||||
C<vmVlans2k>
|
||||
|
||||
=item $vtp->i_vlan_3()
|
||||
|
||||
Each bit represents a VLAN. This is 2048 through 3071
|
||||
|
||||
C<vmVlans3k>
|
||||
|
||||
=item $vtp->i_vlan_4()
|
||||
|
||||
Each bit represents a VLAN. This is 3072 through 4095
|
||||
|
||||
C<vmVlans4k>
|
||||
|
||||
=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
|
||||
200
Info/Entity.pm
Normal file
200
Info/Entity.pm
Normal file
@@ -0,0 +1,200 @@
|
||||
# SNMP::Info::Entity
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# 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::Entity;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %MIBS %FUNCS %GLOBALS %MUNGE $INIT/;
|
||||
@SNMP::Info::Entity::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::Entity::EXPORT_OK = qw//;
|
||||
|
||||
$INIT = 0;
|
||||
%MIBS = ('ENTITY-MIB' => 'entPhysicalSerialNum');
|
||||
|
||||
%GLOBALS = (
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
'e_class' => 'entPhysicalClass',
|
||||
'e_descr' => 'entPhysicalDescr',
|
||||
'e_fwver' => 'entPhysicalFirmwareRev',
|
||||
'e_hwver' => 'entPhysicalHardwareRev',
|
||||
'e_map' => 'entAliasMappingIdentifier',
|
||||
'e_model' => 'entPhysicalModelName',
|
||||
'e_name' => 'entPhysicalName',
|
||||
'e_parent' => 'entPhysicalContainedIn',
|
||||
'e_serial' => 'entPhysicalSerialNum',
|
||||
'e_swver' => 'entPhysicalSoftwareRev',
|
||||
'e_type' => 'entPhysicalVendorType',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
);
|
||||
|
||||
sub e_port {
|
||||
my $entity = shift;
|
||||
my $e_map = $entity->e_map();
|
||||
|
||||
my %e_port;
|
||||
|
||||
foreach my $e_id (keys %$e_map) {
|
||||
my $id = $e_id;
|
||||
$id =~ s/\.0$//;
|
||||
|
||||
my $iid = $e_map->{$e_id};
|
||||
$iid =~ s/.*\.//;
|
||||
|
||||
$e_port{$id} = $iid;
|
||||
}
|
||||
|
||||
return \%e_port;
|
||||
}
|
||||
1;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Entity - Perl5 Interface to SNMP data stored in ENTITY-MIB.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $entity = 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 = $entity->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
ENTITY-MIB is used by some Layer 2 devices like HP Switches and Aironet Access Points
|
||||
|
||||
Create or use a device subclass that inherit this class. Do not use directly.
|
||||
|
||||
For debugging purposes you can call this class directly as you would SNMP::Info
|
||||
|
||||
my $entity = new SNMP::Info::Entity (...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
none.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item ENTITY-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
none.
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Entity Table
|
||||
|
||||
=over
|
||||
|
||||
=item $entity->e_class()
|
||||
|
||||
(C<entPhysicalClass>)
|
||||
|
||||
=item $entity->e_descr()
|
||||
|
||||
(C<entPhysicalClass>)
|
||||
|
||||
=item $entity->e_fwver()
|
||||
|
||||
(C<entPhysicalFirmwareRev>)
|
||||
|
||||
=item $entity->e_hwver()
|
||||
|
||||
(C<entPhysicalHardwareRev>)
|
||||
|
||||
=item $entity->e_map()
|
||||
|
||||
(C<entAliasMappingIdentifier>)
|
||||
|
||||
=item $entity->e_model()
|
||||
|
||||
(C<entPhysicalModelName>)
|
||||
|
||||
=item $entity->e_name()
|
||||
|
||||
(C<entPhysicalName>)
|
||||
|
||||
=item $entity->e_parent()
|
||||
|
||||
(C<entPhysicalContainedIn>)
|
||||
|
||||
=item $entity->e_port()
|
||||
|
||||
Maps EntityTable entries to the Interface Table (IfTable) using
|
||||
$entity->e_map()
|
||||
|
||||
=item $entity->e_serial()
|
||||
|
||||
(C<entPhysicalSerialNum>)
|
||||
|
||||
=item $entity->e_swver()
|
||||
|
||||
(C<entPhysicalSoftwareRev>)
|
||||
|
||||
=item $entity->e_type()
|
||||
|
||||
(C<entPhysicalVendorType>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::EtherLike
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::EtherLike;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -52,8 +54,25 @@ $INIT = 0;
|
||||
|
||||
%FUNCS = (
|
||||
# EtherLike StatsTable
|
||||
'el_index' => 'dot3StatsIndex',
|
||||
'el_duplex' => 'dot3StatsDuplexStatus',
|
||||
'el_chipset' => 'dot3StatsEtherChipSet',
|
||||
'el_coll_excess' => 'dot3StatsExcessiveCollisions',
|
||||
'el_coll_late' => 'dot3StatsLateCollisions',
|
||||
'el_coll_mult' => 'dot3StatsMultipleCollisionFrames',
|
||||
'el_coll_single' => 'dot3StatsSingleCollisionFrames',
|
||||
'el_duplex' => 'dot3StatsDuplexStatus',
|
||||
'el_error_alignment' => 'dot3StatsAlignmentErrors',
|
||||
'el_error_fcs' => 'dot3StatsFCSErrors',
|
||||
'el_error_cs' => 'dot3StatsCarrierSenseErrors',
|
||||
'el_error_frame' => 'dot3StatsFrameTooLongs',
|
||||
'el_error_mac_rec' => 'dot3StatsInternalMacReceiveErrors',
|
||||
'el_error_mac_xmit' => 'dot3StatsInternalMacTransmitErrors',
|
||||
'el_error_sqe' => 'dot3StatsSQETestErrors',
|
||||
'el_error_symbol' => 'dot3StatsSymbolErrors',
|
||||
'el_index' => 'dot3StatsIndex',
|
||||
'el_xmit_defer' => 'dot3StatsDeferredTransmissions',
|
||||
# Ethernet-like Collision Statistics Group
|
||||
'el_coll_count' => 'dot3CollCount',
|
||||
'el_coll_freq' => 'dot3CollFrequencies'
|
||||
);
|
||||
|
||||
%MUNGE = ( %SNMP::Info::MUNGE );
|
||||
@@ -66,62 +85,77 @@ __END__
|
||||
|
||||
SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
ETHERLIKE-MIB is used by some Layer 3 Devices such as Cisco routers.
|
||||
|
||||
Inherits all methods from SNMP::Info
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $el = new SNMP::Info::EtherLike(DestHost => 'myrouter',
|
||||
Community => 'public');
|
||||
my $el = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'router',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
my $class = $cdp->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
my $el_decoder = $el->el_index();
|
||||
my $el_duplex = $el->el_duplex();
|
||||
# Find the duplex setting for a port on a device that implements ETHERLIKE-MIB
|
||||
my $interfaces = $el->interfaces();
|
||||
my $el_index = $el->el_index();
|
||||
my $el_duplex = $el->el_duplex();
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
foreach my $el_port (keys %$el_duplex){
|
||||
my $duplex = $el_duplex->{$el_port};
|
||||
my $iid = $el_index->{$el_port};
|
||||
my $port = $interfaces->{$iid};
|
||||
|
||||
$duplex = 'half' if $duplex =~/half/i;
|
||||
$duplex = 'full' if $duplex =~/full/i;
|
||||
$duplex = 'auto' if $duplex =~/auto/i;
|
||||
|
||||
print "PORT:$port set to duplex:$duplex\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::EtherLike is a subclass of SNMP::Info that supplies
|
||||
access to the ETHERLIKE-MIB used by some Layer 3 Devices such as Cisco routers.
|
||||
|
||||
Use or create a subclass of SNMP::Info that inherits this one. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::EtherLike()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $el = new SNMP::Info::EtherLike(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $el;
|
||||
|
||||
=item $el->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $el->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$el->session($newsession);
|
||||
=item ETHERLIKE-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item None
|
||||
|
||||
=back
|
||||
|
||||
=head1 ETHERLIKE STATS TABLE (dot3StatsTable)
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 ETHERLIKE STATS TABLE (dot3StatsTable)
|
||||
|
||||
=over
|
||||
|
||||
@@ -137,6 +171,70 @@ Returns reference to hash. Indexes Stats Table to Duplex Status of port.
|
||||
|
||||
(B<dot3StatsDuplexStatus>)
|
||||
|
||||
=item $el->el_chipset()
|
||||
|
||||
(B<dot3StatsEtherChipSet>)
|
||||
|
||||
=item $el->el_coll_excess()
|
||||
|
||||
(B<dot3StatsExcessiveCollisions>)
|
||||
|
||||
=item $el->el_coll_late()
|
||||
|
||||
(B<dot3StatsLateCollisions>)
|
||||
|
||||
=item $el->el_coll_mult()
|
||||
|
||||
(B<dot3StatsMultipleCollisionFrames>)
|
||||
|
||||
=item $el->el_coll_single()
|
||||
|
||||
(B<dot3StatsSingleCollisionFrames>)
|
||||
|
||||
=item $el->el_error_alignment()
|
||||
|
||||
(B<dot3StatsAlignmentErrors>)
|
||||
|
||||
=item $el->el_error_fcs()
|
||||
|
||||
(B<dot3StatsFCSErrors>)
|
||||
|
||||
=item $el->el_error_cs()
|
||||
|
||||
(B<dot3StatsCarrierSenseErrors>)
|
||||
|
||||
=item $el->el_error_frame()
|
||||
|
||||
(B<dot3StatsFrameTooLongs>)
|
||||
|
||||
=item $el->el_error_mac_rec()
|
||||
|
||||
(B<dot3StatsInternalMacReceiveErrors>)
|
||||
|
||||
=item $el->el_error_mac_xmit()
|
||||
|
||||
(B<dot3StatsInternalMacTransmitErrors>)
|
||||
|
||||
=item $el->el_error_sqe()
|
||||
|
||||
(B<dot3StatsSQETestErrors>)
|
||||
|
||||
=item $el->el_error_symbol()
|
||||
|
||||
(B<dot3StatsSymbolErrors>)
|
||||
|
||||
=item $el->el_xmit_defer()
|
||||
|
||||
(B<dot3StatsDeferredTransmissions>)
|
||||
|
||||
=item $el->el_coll_count()
|
||||
|
||||
(B<dot3CollCount>)
|
||||
|
||||
=item $el->el_coll_freq()
|
||||
|
||||
(B<dot3CollFrequencies>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
397
Info/FDP.pm
Normal file
397
Info/FDP.pm
Normal file
@@ -0,0 +1,397 @@
|
||||
# SNMP::Info::FDP
|
||||
# Bruce Rodger
|
||||
# $Id$
|
||||
#
|
||||
# (c) 2004 Bruce Rodger, Max Baker
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2002,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::FDP;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use Carp;
|
||||
|
||||
@SNMP::Info::FDP::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::FDP::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
|
||||
# Debug
|
||||
$DEBUG=1;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
# Five data structures required by SNMP::Info
|
||||
$INIT = 0;
|
||||
%MIBS = ( 'FOUNDRY-SN-SWITCH-GROUP-MIB' => 'snFdpGlobalRun' );
|
||||
|
||||
# Notice we dont inherit the default GLOBALS and FUNCS
|
||||
# only the default MUNGE.
|
||||
%GLOBALS = (
|
||||
# CDP-Compatibility
|
||||
'cdp_run' => 'snFdpGlobalRun',
|
||||
'cdp_interval' => 'snFdpGlobalMessageInterval',
|
||||
'cdp_holdtime' => 'snFdpGlobalHoldTime',
|
||||
'cdp_id' => 'snFdpGlobalDeviceId',
|
||||
#
|
||||
'fdp_run' => 'snFdpGlobalRun',
|
||||
'fdp_interval' => 'snFdpGlobalMessageInterval',
|
||||
'fdp_holdtime' => 'snFdpGlobalHoldTime',
|
||||
'fdp_id' => 'snFdpGlobalDeviceId',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
'c_index' => 'snFdpCacheIfIndex',
|
||||
'c_proto' => 'snFdpCacheAddressType',
|
||||
'c_ip' => 'snFdpCacheAddress',
|
||||
'c_ver' => 'snFdpCacheVersion',
|
||||
'c_id' => 'snFdpCacheDeviceId',
|
||||
'c_port' => 'snFdpCacheDevicePort',
|
||||
'c_platform' => 'snFdpCachePlatform',
|
||||
'c_capabilities' => 'snFdpCacheCapabilities',
|
||||
'c_domain' => 'snFdpCacheVTPMgmtDomain',
|
||||
'c_vlan' => 'snFdpCacheNativeVLAN',
|
||||
'c_duplex' => 'snFdpCacheDuplex'
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'c_capabilities' => \&munge_caps,
|
||||
'c_ip' => \&SNMP::Info::munge_ip
|
||||
);
|
||||
|
||||
|
||||
sub munge_caps {
|
||||
my $caps = shift;
|
||||
return undef unless defined $caps;
|
||||
|
||||
my $bits = substr(unpack("B*",$caps),-7);
|
||||
return $bits;
|
||||
|
||||
|
||||
}
|
||||
sub hasFDP {
|
||||
my $fdp = shift;
|
||||
|
||||
my $ver = $fdp->{_version};
|
||||
#my $ver = $fdp->fdp_ver;
|
||||
|
||||
|
||||
|
||||
# SNMP v1 clients dont have the globals
|
||||
if (defined $ver and $ver == 1){
|
||||
my $fdp_ip = $fdp->fdp_ip();
|
||||
# See if anything in fdp cache, if so we have fdp
|
||||
return 1 if (defined $fdp_ip and scalar(keys %$fdp_ip)) ;
|
||||
return undef;
|
||||
}
|
||||
|
||||
return $fdp->fdp_run();
|
||||
}
|
||||
|
||||
sub c_if {
|
||||
my $fdp = shift;
|
||||
|
||||
|
||||
|
||||
# See if by some miracle Cisco implemented the fdpCacheIfIndex entry
|
||||
my $fdp_index = $fdp->fdp_index();
|
||||
return $fdp_index if defined $fdp_index;
|
||||
|
||||
# Nope, didn't think so. Now we fake it.
|
||||
my $fdp_ip = $fdp->c_ip();
|
||||
unless (defined $fdp_ip){
|
||||
$fdp->{error} = "SNMP::Info::FDP:fdp_if() - Device doesn't have fdp_ip() data. Can't fake fdp_index()";
|
||||
$DEBUG and carp($fdp->error(1));
|
||||
return undef;
|
||||
}
|
||||
|
||||
my %fdp_if;
|
||||
foreach my $key (keys %$fdp_ip){
|
||||
next unless defined $key;
|
||||
my $iid = $key;
|
||||
# Truncate .1 from fdp cache entry
|
||||
$iid =~ s/\.\d+$//;
|
||||
$fdp_if{$key} = $iid;
|
||||
}
|
||||
|
||||
return \%fdp_if;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::FDP - Perl5 Interface to Foundry Discovery Protocol (FDP) using SNMP
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $fdp = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'router',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
my $class = $fdp->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
$hasfdp = $fdp->hasFDP() ? 'yes' : 'no';
|
||||
|
||||
# Print out a map of device ports with FDP neighbors:
|
||||
my $interfaces = $fdp->interfaces();
|
||||
my $fdp_if = $fdp->fdp_if();
|
||||
my $fdp_ip = $fdp->fdp_ip();
|
||||
my $fdp_port = $fdp->fdp_port();
|
||||
|
||||
foreach my $fdp_key (keys %$fdp_ip){
|
||||
my $iid = $fdp_if->{$fdp_key};
|
||||
my $port = $interfaces->{$iid};
|
||||
my $neighbor = $fdp_ip->{$fdp_key};
|
||||
my $neighbor_port = $fdp_port->{$fdp_key};
|
||||
print "Port : $port connected to $neighbor / $neighbor_port\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::FDP is a subclass of SNMP::Info that provides an object oriented
|
||||
interface to FDP information through SNMP.
|
||||
|
||||
FDP is a Layer 2 protocol that supplies topology information of
|
||||
devices that also speak FDP, mostly switches and routers. It has
|
||||
similar functionality to Cisco's CDP, and the SNMP interface is
|
||||
virtually identical. FDP is implemented in Foundry devices, including
|
||||
the Bigiron and Fastiron range.
|
||||
|
||||
Create or use a device subclass that inherits this class. Do not use directly.
|
||||
|
||||
Each device implements a subset of the global and cache entries.
|
||||
Check the return value to see if that data is held by the device.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item FOUNDRY-SN-SWITCH-GROUP-MIB
|
||||
|
||||
Needs a reasonably recent MIB. Works OK with B2R07604A.mib, but doesn't
|
||||
work with B2R07600C.
|
||||
|
||||
|
||||
=back
|
||||
|
||||
MIBs are normally distributed with each code update. Contact your vendor,
|
||||
or trawl through google...
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $fdp->hasFDP()
|
||||
|
||||
Is FDP is active in this device?
|
||||
|
||||
Accounts for SNMP version 1 devices which may have FDP but not fdp_run()
|
||||
|
||||
=item $fdp->fdp_run()
|
||||
|
||||
Is FDP enabled on this device?
|
||||
|
||||
(B<fdpGlobalRun>)
|
||||
|
||||
=item $fdp->fdp_interval()
|
||||
|
||||
Interval in seconds at which FDP messages are generated.
|
||||
|
||||
(B<fdpGlobalMessageInterval>)
|
||||
|
||||
=item $fdp->fdp_holdtime()
|
||||
|
||||
Time in seconds that FDP messages are kept.
|
||||
|
||||
(B<fdpGlobalHoldTime>)
|
||||
|
||||
=item $fdp->fdp_id()
|
||||
|
||||
Returns FDP device ID.
|
||||
|
||||
This is the device id broadcast via FDP to other devices, and is what is retrieved from remote devices with $fdp->id().
|
||||
|
||||
(B<fdpGlobalDeviceId>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 FDP CACHE ENTRIES
|
||||
|
||||
=over
|
||||
|
||||
=item $fdp->fdp_capabilities()
|
||||
|
||||
Returns Device Functional Capabilities. Results are munged into an ascii
|
||||
binary string, 7 digits long, MSB. Each digit represents a bit from the
|
||||
table below.
|
||||
|
||||
From L<http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm#18843>:
|
||||
|
||||
(Bit) - Description
|
||||
|
||||
=over
|
||||
|
||||
=item (0x40) - Provides level 1 functionality.
|
||||
|
||||
=item (0x20) - The bridge or switch does not forward IGMP Report packets on nonrouter ports.
|
||||
|
||||
=item (0x10) - Sends and receives packets for at least one network layer protocol. If the device is routing the protocol, this bit should not be set.
|
||||
|
||||
=item (0x08) - Performs level 2 switching. The difference between this bit and bit 0x02 is that a switch does not run the Spanning-Tree Protocol. This device is assumed to be deployed in a physical loop-free topology.
|
||||
|
||||
=item (0x04) - Performs level 2 source-route bridging. A source-route bridge would set both this bit and bit 0x02.
|
||||
|
||||
=item (0x02) - Performs level 2 transparent bridging.
|
||||
|
||||
=item (0x01) - Performs level 3 routing for at least one network layer protocol.
|
||||
|
||||
=back
|
||||
|
||||
Thanks to Martin Lorensen C<martin -at- lorensen.dk> for a pointer to this information.
|
||||
|
||||
(B<fdpCacheCapabilities>)
|
||||
|
||||
=item $fdp->fdp_domain()
|
||||
|
||||
The CDP version of this returns remote VTP Management Domain as defined in CISCO-VTP-MIB::managementDomainName
|
||||
|
||||
(B<fdpCacheVTPMgmtDomain>)
|
||||
|
||||
=item $fdp->fdp_duplex()
|
||||
|
||||
Returns the port duplex status from remote devices.
|
||||
|
||||
(B<fdpCacheDuplex>)
|
||||
|
||||
=item $fdp->fdp_id()
|
||||
|
||||
Returns remote device id string
|
||||
|
||||
(B<fdpCacheDeviceId>)
|
||||
|
||||
=item $fdp->fdp_if()
|
||||
|
||||
Returns the mapping to the SNMP Interface Table.
|
||||
|
||||
Note that a lot devices don't implement $fdp->fdp_index(), So if it isn't around,
|
||||
we fake it.
|
||||
|
||||
In order to map the fdp table entry back to the interfaces() entry, we truncate the last number
|
||||
off of it :
|
||||
|
||||
# it exists, yay.
|
||||
my $fdp_index = $device->fdp_index();
|
||||
return $fdp_index if defined $fdp_index;
|
||||
|
||||
# if not, let's fake it
|
||||
my $fdp_ip = $device->fdp_ip();
|
||||
|
||||
my %fdp_if
|
||||
foreach my $key (keys %$fdp_ip){
|
||||
$iid = $key;
|
||||
## Truncate off .1 from fdp response
|
||||
$iid =~ s/\.\d+$//;
|
||||
$fdp_if{$key} = $iid;
|
||||
}
|
||||
|
||||
return \%fdp_if;
|
||||
|
||||
|
||||
=item $fdp->fdp_index()
|
||||
|
||||
Returns the mapping to the SNMP2 Interface table for FDP Cache Entries.
|
||||
|
||||
Most devices don't implement this, so you probably want to use $fdp->fdp_if() instead.
|
||||
|
||||
See fdp_if() entry.
|
||||
|
||||
(B<fdpCacheIfIndex>)
|
||||
|
||||
=item $fdp->fdp_ip()
|
||||
|
||||
Returns remote IP address
|
||||
|
||||
(B<fdpCacheAddress>)
|
||||
|
||||
=item $fdp->fdp_platform()
|
||||
|
||||
Returns remote platform id
|
||||
|
||||
(B<fdpCachePlatform>)
|
||||
|
||||
=item $fdp->fdp_port()
|
||||
|
||||
Returns remote port ID
|
||||
|
||||
(B<fdpDevicePort>)
|
||||
|
||||
=item $fdp->fdp_proto()
|
||||
|
||||
Returns remote address type received. Usually IP.
|
||||
|
||||
(B<fdpCacheAddressType>)
|
||||
|
||||
=item $fdp->fdp_ver()
|
||||
|
||||
Returns remote hardware version
|
||||
|
||||
(B<fdpCacheVersion>)
|
||||
|
||||
=item $fdp->fdp_vlan()
|
||||
|
||||
Returns the remote interface native VLAN.
|
||||
|
||||
(B<fdpCacheNativeVLAN>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
127
Info/Layer1.pm
127
Info/Layer1.pm
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer1 - SNMP Interface to Layer1 Devices
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -163,24 +165,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer1 - Perl5 Interface to Layer1 network devices.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Layer1 device through SNMP. Information is stored in a number of MIBs.
|
||||
|
||||
See super classes for descriptions of other available methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info
|
||||
|
||||
MIBS:
|
||||
|
||||
MIBS listed in SNMP::Info
|
||||
|
||||
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
SNMP::Info::Layer1 - Perl5 Interface to network devices serving Layer1 only.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -188,45 +173,72 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $l1 = new SNMP::Info::Layer1(DestHost => 'mybridge' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $l1 = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $l1->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
# Let's get some basic Port information
|
||||
my $interfaces = $l1->interfaces();
|
||||
my $i_up = $l1->i_up();
|
||||
my $i_speed = $l1->i_speed();
|
||||
|
||||
foreach my $iid (keys %$interfaces) {
|
||||
my $port = $interfaces->{$iid};
|
||||
my $up = $i_up->{$iid};
|
||||
my $speed = $i_speed->{$iid}
|
||||
print "Port $port is $up. Port runs at $speed.\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is usually used as a superclass for more specific device classes listed under
|
||||
SNMP::Info::Layer1::* Please read all docs under SNMP::Info first.
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Layer1 device through SNMP. Information is stored in a number of MIBs.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $l1 = new SNMP::Info::Layer1(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer1()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $l1 = new SNMP::Info::Layer1(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $l1;
|
||||
|
||||
=item $l1->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $l1->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$l1->session($newsession);
|
||||
=item SNMP::Info
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item $l1->vendor()
|
||||
=item SNMP-REPEATER-MIB
|
||||
|
||||
Trys to discover the vendor from $l1->model() and $l1->vendor()
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs required for SNMP::Info
|
||||
|
||||
=back
|
||||
|
||||
SNMP-REPEATER-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $l1->ports_managed()
|
||||
|
||||
@@ -234,6 +246,16 @@ Gets the number of ports under the interface mib
|
||||
|
||||
(B<ifNumber>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $l1->vendor()
|
||||
|
||||
Trys to discover the vendor from $l1->model() and $l1->vendor()
|
||||
|
||||
=item $l1->ports()
|
||||
|
||||
Adds the values from rptr_ports() and ports_managed()
|
||||
@@ -246,8 +268,15 @@ Number of 'groups' in the Repeater MIB
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info 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
|
||||
@@ -292,4 +321,8 @@ Group (slot) Number for given port.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# SNMP::Info::Layer1::Allied
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, Regents of the University of California
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1::Allied;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
@@ -64,6 +66,19 @@ sub vendor {
|
||||
return 'allied';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'allied';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $allied = shift;
|
||||
my $descr = $allied->description();
|
||||
|
||||
if ($descr =~ m/version (\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $allied = shift;
|
||||
|
||||
@@ -111,68 +126,74 @@ __END__
|
||||
|
||||
SNMP::Info::Layer1::Allied - SNMP Interface to old Allied Hubs
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Allied device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info::Layer1
|
||||
|
||||
Required MIBs:
|
||||
|
||||
ATI-MIB - Download for your device from http://www.allied-telesyn.com/allied/support/
|
||||
|
||||
MIBs listed in SNMP::Info::Layer1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $allied = new SNMP::Info::Layer1::Allied(DestHost => 'mycat1900' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $allied = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myhub',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $l1->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Allied device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer1::Allied()
|
||||
=item SNMP::Info::Layer1
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=back
|
||||
|
||||
my $allied = new SNMP::Info::Layer1::Allied(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $allied;
|
||||
=head2 Required MIBs
|
||||
|
||||
=item $allied->session()
|
||||
=over
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
=item ATI-MIB
|
||||
|
||||
# Get
|
||||
my $sess = $allied->session();
|
||||
Download for your device from http://www.allied-telesyn.com/allied/support/
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$allied->session($newsession);
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs listed in SNMP::Info::Layer1 and its inherited classes.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $allied->vendor()
|
||||
|
||||
Returns 'allied' :)
|
||||
|
||||
=item $allied->os()
|
||||
|
||||
Returns 'allied'
|
||||
|
||||
=item $allied->os_ver()
|
||||
|
||||
Culls Version from description()
|
||||
|
||||
=item $allied->root_ip()
|
||||
|
||||
Returns IP Address of Managed Hub.
|
||||
@@ -185,6 +206,10 @@ Trys to cull out AT-nnnnX out of the description field.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::Layer1
|
||||
|
||||
See documentation in SNMP::Info::Layer1 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
@@ -216,4 +241,8 @@ the values of ati_up() to 'up' and 'down'.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer1
|
||||
|
||||
See documentation in SNMP::Info::Layer1 for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# SNMP::Info::Layer1::Asante
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, Regents of the University of California
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer1::Asante;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
@@ -80,6 +82,19 @@ sub interfaces {
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'asante';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $asante = shift;
|
||||
my $descr = $asante->description();
|
||||
|
||||
if ($descr =~ /software v(\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'asante';
|
||||
}
|
||||
@@ -154,64 +169,65 @@ __END__
|
||||
|
||||
SNMP::Info::Layer1::Asante - SNMP Interface to old Asante 1012 Hubs
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Asante device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info::Layer1
|
||||
|
||||
Required MIBs:
|
||||
|
||||
ASANTE-HUB1012-MIB - Download from http://www.mibdepot.com
|
||||
|
||||
MIBs listed in SNMP::Info::Layer1
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $asante = new SNMP::Info::Layer1::Asante(DestHost => 'mycat1900' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $asante = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $asante->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Asante device through SNMP.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer1::Asante()
|
||||
=item SNMP::Info::Layer1
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=back
|
||||
|
||||
my $asante = new SNMP::Info::Layer1::Asante(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $asante;
|
||||
=head2 Required MIBs
|
||||
|
||||
=item $asante->session()
|
||||
=over
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
=item ASANTE-HUB1012-MIB
|
||||
|
||||
# Get
|
||||
my $sess = $asante->session();
|
||||
Download from http://www.mibdepot.com
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$asante->session($newsession);
|
||||
=item MIBs listed in SNMP::Info::Layer1
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $asante->os()
|
||||
|
||||
Returns 'asante'
|
||||
|
||||
=item $asante->os_ver()
|
||||
|
||||
Culls software version from description()
|
||||
|
||||
=item $asante->vendor()
|
||||
|
||||
Returns 'asante' :)
|
||||
@@ -228,6 +244,10 @@ Trys to cull out AT-nnnnX out of the description field.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals inherited from SNMP::Info::Layer1
|
||||
|
||||
See documentation in SNMP::Info::Layer1 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
@@ -259,4 +279,8 @@ the values of ati_up() to 'up' and 'down'.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer1
|
||||
|
||||
See documentation in SNMP::Info::Layer1 for details.
|
||||
|
||||
=cut
|
||||
|
||||
533
Info/Layer1/Bayhub.pm
Normal file
533
Info/Layer1/Bayhub.pm
Normal file
@@ -0,0 +1,533 @@
|
||||
# SNMP::Info::Layer1::Bayhub
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,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::Layer1::Bayhub;
|
||||
$VERSION = 0.9;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::NortelStack;
|
||||
use SNMP::Info::SONMP;
|
||||
|
||||
@SNMP::Info::Layer1::Bayhub::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/;
|
||||
@SNMP::Info::Layer1::Bayhub::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::NortelStack::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
'S5-ETHERNET-COMMON-MIB' => 's5EnPortTable',
|
||||
'S5-COMMON-STATS-MIB' => 's5CmStat',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::NortelStack::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::NortelStack::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
# S5-ETHERNET-COMMON-MIB::s5EnPortTable
|
||||
'bayhub_pb_index' => 's5EnPortBrdIndx',
|
||||
'bayhub_pp_index' => 's5EnPortIndx',
|
||||
'bayhub_up_admin' => 's5EnPortPartStatus',
|
||||
'bayhub_up' => 's5EnPortLinkStatus',
|
||||
# S5-COMMON-STATS-MIB::s5CmSNodeTable
|
||||
'bayhub_nb_index' => 's5CmSNodeBrdIndx',
|
||||
'bayhub_np_index' => 's5CmSNodePortIndx',
|
||||
'fw_mac' => 's5CmSNodeMacAddr',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::NortelStack::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
);
|
||||
|
||||
sub layers {
|
||||
return '00000011';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'bay_hub';
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $bayhub = shift;
|
||||
my $id = $bayhub->id();
|
||||
return undef unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
$model =~ s/^sreg-//i;
|
||||
|
||||
return 'Baystack Hub' if ($model =~ /BayStackEth/);
|
||||
return '5000' if ($model =~ /5000/);
|
||||
return '5005' if ($model =~ /5005/);
|
||||
return $model;
|
||||
}
|
||||
|
||||
# Hubs do not support ifMIB requirements for get MAC
|
||||
# and port status
|
||||
sub i_index {
|
||||
my $bayhub = shift;
|
||||
my $b_index = $bayhub->bayhub_pb_index();
|
||||
my $p_index = $bayhub->bayhub_pp_index();
|
||||
my $model = $bayhub->model();
|
||||
|
||||
my %i_index;
|
||||
foreach my $iid (keys %$b_index){
|
||||
my $board = $b_index->{$iid};
|
||||
next unless defined $board;
|
||||
my $port = $p_index->{$iid}||0;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $board;
|
||||
if (! ($comidx % 5)) {
|
||||
$board = ($board / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = ($board*256)+$port;
|
||||
|
||||
$i_index{$iid} = $index;
|
||||
}
|
||||
return \%i_index;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $bayhub = shift;
|
||||
my $i_index = $bayhub->i_index();
|
||||
|
||||
my %if;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
# Index numbers are deterministic slot * 256 + port
|
||||
my $port = $index % 256;
|
||||
my $slot = int($index / 256);
|
||||
|
||||
my $slotport = "$slot.$port";
|
||||
|
||||
$if{$index} = $slotport;
|
||||
}
|
||||
|
||||
return \%if;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $bayhub = shift;
|
||||
my $port_index = $bayhub->i_index();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
my $duplex = 'half';
|
||||
$i_duplex{$index}=$duplex;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $bayhub = shift;
|
||||
my $port_index = $bayhub->i_index();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
my $duplex = 'half';
|
||||
$i_duplex_admin{$index}=$duplex;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_speed {
|
||||
my $bayhub = shift;
|
||||
my $port_index = $bayhub->i_index();
|
||||
|
||||
my %i_speed;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
my $speed = '10 Mbps';
|
||||
$i_speed{$index}=$speed;
|
||||
}
|
||||
return \%i_speed;
|
||||
}
|
||||
|
||||
sub i_up {
|
||||
my $bayhub = shift;
|
||||
my $port_index = $bayhub->i_index();
|
||||
my $link_stat = $bayhub->bayhub_up();
|
||||
|
||||
my %i_up;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $link_stat = $link_stat->{$iid};
|
||||
next unless defined $link_stat;
|
||||
|
||||
$link_stat = 'up' if $link_stat =~ /on/i;
|
||||
$link_stat = 'down' if $link_stat =~ /off/i;
|
||||
|
||||
$i_up{$index}=$link_stat;
|
||||
}
|
||||
return \%i_up;
|
||||
}
|
||||
|
||||
sub i_up_admin {
|
||||
my $bayhub = shift;
|
||||
my $i_index = $bayhub->i_index();
|
||||
my $link_stat = $bayhub->bayhub_up_admin();
|
||||
|
||||
my %i_up_admin;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $link_stat = $link_stat->{$iid};
|
||||
next unless defined $link_stat;
|
||||
|
||||
$i_up_admin{$index}=$link_stat;
|
||||
}
|
||||
return \%i_up_admin;
|
||||
}
|
||||
# Hubs do not support the standard Bridge MIB
|
||||
sub bp_index {
|
||||
my $bayhub = shift;
|
||||
my $b_index = $bayhub->bayhub_nb_index();
|
||||
my $p_index = $bayhub->bayhub_np_index();
|
||||
my $model = $bayhub->model();
|
||||
|
||||
my %bp_index;
|
||||
foreach my $iid (keys %$b_index){
|
||||
my $board = $b_index->{$iid};
|
||||
next unless defined $board;
|
||||
my $port = $p_index->{$iid}||0;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $board;
|
||||
if (! ($comidx % 5)) {
|
||||
$board = ($board / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = ($board*256)+$port;
|
||||
|
||||
$bp_index{$index} = $index;
|
||||
}
|
||||
return \%bp_index;
|
||||
}
|
||||
|
||||
sub fw_port {
|
||||
my $bayhub = shift;
|
||||
my $b_index = $bayhub->bayhub_nb_index();
|
||||
my $p_index = $bayhub->bayhub_np_index();
|
||||
my $model = $bayhub->model();
|
||||
|
||||
my %fw_port;
|
||||
foreach my $iid (keys %$b_index){
|
||||
my $board = $b_index->{$iid};
|
||||
next unless defined $board;
|
||||
my $port = $p_index->{$iid}||0;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $board;
|
||||
if (! ($comidx % 5)) {
|
||||
$board = ($board / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$board = int($board/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = ($board*256)+$port;
|
||||
|
||||
$fw_port{$iid} = $index;
|
||||
}
|
||||
return \%fw_port;
|
||||
}
|
||||
|
||||
sub index_factor {
|
||||
return 256;
|
||||
}
|
||||
|
||||
sub slot_offset {
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer1::Bayhub - SNMP Interface to Bay / Nortel Hubs
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#Let SNMP::Info determine the correct subclass for you.
|
||||
|
||||
my $bayhub = 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 = $bayhub->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Bayhub device through SNMP. Also provides device MAC to port mapping through the propietary 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 $bayhub = new SNMP::Info::Layer1::Bayhub(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=item SNMP::Info::NortelStack
|
||||
|
||||
=item SNMP::Info::SONMP
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item S5-ETHERNET-COMMON-MIB
|
||||
|
||||
=item S5-COMMON-STATS-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::NortelStack for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::SONMP for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status. Go to http://www.nortelnetworks.com Technical Support, Browse Technical Support,
|
||||
Select by Product Families, BayStack, BayStack: Hubs - 150 Series, 10BASE-T,
|
||||
Software. Filter on mibs and download the latest version's archive.
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $bayhub->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $bayhub->os()
|
||||
|
||||
Returns 'Bay Hub'
|
||||
|
||||
=item $bayhub->model()
|
||||
|
||||
Cross references $bayhub->id() to the SYNOPTICS-MIB and returns
|
||||
the results.
|
||||
|
||||
Removes sreg- from the model name
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $bayhub->layers()
|
||||
|
||||
Returns 00000011. Class emulates Layer 2 functionality through proprietary MIBs.
|
||||
|
||||
=item $bayhub->index_factor()
|
||||
|
||||
Required by SNMP::Info::SONMP. Number representing the number of ports
|
||||
reserved per slot within the device MIB. Returns 256.
|
||||
|
||||
=item $bayhub->slot_offset()
|
||||
|
||||
Required by SNMP::Info::SONMP. Offset if slot numbering does not
|
||||
start at 0. Returns 0.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP 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 $bayhub->i_index()
|
||||
|
||||
Returns reference to map of IIDs to Interface index.
|
||||
|
||||
Since hubs do not support ifIndex, the interface index is created using the
|
||||
formula (board * 256 + port).
|
||||
|
||||
=item $bayhub->interfaces()
|
||||
|
||||
Returns reference to map of IIDs to physical ports.
|
||||
|
||||
=item $bayhub->i_duplex()
|
||||
|
||||
Returns half, hubs do not support full duplex.
|
||||
|
||||
=item $bayhub->i_duplex_admin()
|
||||
|
||||
Returns half, hubs do not support full duplex.
|
||||
|
||||
=item $bayhub->i_speed()
|
||||
|
||||
Currently returns 10 Mbps. The class does not currently support 100 Mbps hubs.
|
||||
|
||||
=item $bayhub->i_up()
|
||||
|
||||
Returns (B<s5EnPortLinkStatus>) for each port. Translates on/off to up/down.
|
||||
|
||||
=item $bayhub->i_up_admin()
|
||||
|
||||
Returns (B<s5EnPortPartStatus>) for each port.
|
||||
|
||||
=item $bayhub->bp_index()
|
||||
|
||||
Simulates bridge MIB by returning reference to a hash containing the index for
|
||||
both the keys and values.
|
||||
|
||||
=item $bayhub->fw_port()
|
||||
|
||||
Returns reference to map of IIDs of the S5-COMMON-STATS-MIB::s5CmSNodeTable
|
||||
to the Interface index.
|
||||
|
||||
=item $bayhub->fw_mac()
|
||||
|
||||
(B<s5CmSNodeMacAddr>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=cut
|
||||
196
Info/Layer2.pm
196
Info/Layer2.pm
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer2 - SNMP Interface to Layer2 Devices
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker -- All changes from Version 0.7 on
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -37,10 +39,11 @@ use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::CDP;
|
||||
use SNMP::Info::CiscoStats;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MUNGE $INIT/;
|
||||
|
||||
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::CDP Exporter/;
|
||||
@SNMP::Info::Layer2::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::CDP SNMP::Info::CiscoStats Exporter/;
|
||||
@SNMP::Info::Layer2::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
@@ -53,21 +56,27 @@ $INIT = 0;
|
||||
%MIBS = ( %SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
'CISCO-PRODUCTS-MIB' => 'sysName',
|
||||
'CISCO-STACK-MIB' => 'wsc1900sysID',
|
||||
# 'HP-ICF-OID' => 'hpSwitch4000',
|
||||
%SNMP::Info::CiscoStats::MIBS,
|
||||
'CISCO-PRODUCTS-MIB' => 'sysName', # for model()
|
||||
'CISCO-STACK-MIB' => 'wsc1900sysID', # some older catalysts live here
|
||||
'ENTITY-MIB' => 'entPhysicalName', # for serial stuff
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::CDP::GLOBALS,
|
||||
%SNMP::Info::CiscoStats::GLOBALS,
|
||||
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::CDP::FUNCS,
|
||||
%SNMP::Info::CiscoStats::FUNCS,
|
||||
'ent_serial' => 'entPhysicalSerialNum',
|
||||
'ent_chassis'=> 'entPhysicalDescr',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
@@ -75,6 +84,7 @@ $INIT = 0;
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::CDP::MUNGE,
|
||||
%SNMP::Info::CiscoStats::MUNGE,
|
||||
);
|
||||
|
||||
# Method OverRides
|
||||
@@ -85,7 +95,7 @@ sub model {
|
||||
my $l2 = shift;
|
||||
my $id = $l2->id();
|
||||
my $model = &SNMP::translateObj($id);
|
||||
|
||||
|
||||
# HP
|
||||
$model =~ s/^hpswitch//i;
|
||||
|
||||
@@ -112,6 +122,25 @@ sub vendor {
|
||||
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $l2 = shift;
|
||||
|
||||
my $serial1 = $l2->serial1();
|
||||
my $ent_chassis = $l2->ent_chassis() || {};
|
||||
my $ent_serial = $l2->ent_serial() || {};
|
||||
|
||||
my $serial2 = $ent_serial->{1} || undef;
|
||||
my $chassis = $ent_chassis->{1} || undef;
|
||||
|
||||
# precedence
|
||||
# serial2,chassis parse,serial1
|
||||
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
|
||||
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
|
||||
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $l2 = shift;
|
||||
|
||||
@@ -160,31 +189,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2 - Perl5 Interface to Layer2 network devices.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Layer2 device through SNMP. Information is stored in a number of MIBs.
|
||||
|
||||
See super classes for descriptions of other available methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info
|
||||
SNMP::Info::Bridge
|
||||
SNMP::Info::CDP
|
||||
|
||||
MIBS:
|
||||
|
||||
CISCO-PRODUCTS-MIB - Needed for ID of Cisco Products
|
||||
CISCO-STACK-MIB - Needed for ID of Cisco Products
|
||||
##HP-ICF-OID - Needed for ID of HP Products
|
||||
MIBS listed in SNMP::Info::Bridge and SNMP::Info::CDP
|
||||
|
||||
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
HP MIBs can be found at http://www.hp.com/rnd/software
|
||||
SNMP::Info::Layer2 - Perl5 Interface to network devices serving Layer2 only.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -192,46 +197,90 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $l2 = new SNMP::Info::Layer2(DestHost => 'mybridge' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $l2 = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $l2->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
# Let's get some basic Port information
|
||||
my $interfaces = $l2->interfaces();
|
||||
my $i_up = $l2->i_up();
|
||||
my $i_speed = $l2->i_speed();
|
||||
foreach my $iid (keys %$interfaces) {
|
||||
my $port = $interfaces->{$iid};
|
||||
my $up = $i_up->{$iid};
|
||||
my $speed = $i_speed->{$iid}
|
||||
print "Port $port is $up. Port runs at $speed.\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is usually used as a superclass for more specific device classes listed under
|
||||
SNMP::Info::Layer2::* Please read all docs under SNMP::Info first.
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Layer2 device through SNMP. Information is stored in a number of MIBs.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $l2 = new SNMP::Info::Layer2(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2()
|
||||
=item SNMP::Info
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
my $l2 = new SNMP::Info::Layer2(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $l2;
|
||||
=item SNMP::Info::CDP
|
||||
|
||||
=item $l2->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $l2->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$l2->session($newsession);
|
||||
=item SNMP::Info::CiscoStats
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CISCO-PRODUCTS-MIB
|
||||
|
||||
Needed for ID of Cisco Products
|
||||
|
||||
=item CISCO-STACK-MIB
|
||||
|
||||
Needed for ID of Cisco Products
|
||||
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs required by the inherited classes listed above.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $l2->model()
|
||||
|
||||
Cross references $l2->id() with product IDs in the
|
||||
Cisco and HP specific MIBs.
|
||||
Cisco MIBs.
|
||||
|
||||
For HP devices, removes 'hpswitch' from the name
|
||||
|
||||
@@ -239,11 +288,30 @@ For Cisco devices, removes 'sysid' from the name
|
||||
|
||||
=item $l2->vendor()
|
||||
|
||||
Trys to discover the vendor from $l2->model() and $l2->vendor()
|
||||
Trys to discover the vendor from $l2->model() and $l2->description()
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::CDP
|
||||
|
||||
See documentation in SNMP::Info::CDP for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::CiscoStats
|
||||
|
||||
See documentation in SNMP::Info::CiscoStats for details.
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
@@ -263,4 +331,20 @@ Ignores ports with B<ifType> of loopback,propvirtual,other, and cpu
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CDP
|
||||
|
||||
See documentation in SNMP::Info::CDP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoStats
|
||||
|
||||
See documentation in SNMP::Info::CiscoStats for details.
|
||||
|
||||
=cut
|
||||
|
||||
248
Info/Layer2/Aironet.pm
Normal file
248
Info/Layer2/Aironet.pm
Normal file
@@ -0,0 +1,248 @@
|
||||
# SNMP::Info::Layer2::Aironet
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# 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::Layer2::Aironet;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::Entity;
|
||||
use SNMP::Info::EtherLike;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
|
||||
@SNMP::Info::Layer2::Aironet::ISA = qw/SNMP::Info::Layer2 SNMP::Info::Entity SNMP::Info::EtherLike
|
||||
SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer2::Aironet::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::Entity::GLOBALS,
|
||||
%SNMP::Info::EtherLike::GLOBALS,
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
'serial' => 'entPhysicalSerialNum.1',
|
||||
'descr' => 'sysDescr'
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
%SNMP::Info::Entity::FUNCS,
|
||||
%SNMP::Info::EtherLike::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::Entity::MIBS,
|
||||
%SNMP::Info::EtherLike::MIBS,
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
%SNMP::Info::Entity::MUNGE,
|
||||
%SNMP::Info::EtherLike::MUNGE,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
);
|
||||
|
||||
|
||||
sub vendor {
|
||||
# Sorry, but it's true.
|
||||
return 'cisco';
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $aironet = shift;
|
||||
my $i_description = $aironet->i_description();
|
||||
|
||||
return $i_description;
|
||||
}
|
||||
|
||||
# Tag on e_descr.1
|
||||
sub description {
|
||||
my $aironet = shift;
|
||||
my $descr = $aironet->descr();
|
||||
my $e_descr = $aironet->e_descr();
|
||||
|
||||
$descr = "$e_descr->{1} $descr" if defined $e_descr->{1};
|
||||
|
||||
return $descr;
|
||||
}
|
||||
|
||||
# Fetch duplex from EtherLike
|
||||
sub i_duplex {
|
||||
my $aironet = shift;
|
||||
my $el_duplex = $aironet->el_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $d (keys %$el_duplex){
|
||||
my $val = $el_duplex->{$d};
|
||||
next unless defined $val;
|
||||
$i_duplex{$d} = 'full' if $val =~ /full/i;
|
||||
$i_duplex{$d} = 'half' if $val =~ /half/i;
|
||||
}
|
||||
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Aironet - SNMP Interface to Cisco Aironet devices running IOS.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $aironet = 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 = $aironet->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides interface to SNMP Data available on newer Aironet devices running Cisco IOS.
|
||||
|
||||
Note there are two classes for Aironet devices :
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer3::Aironet
|
||||
|
||||
This class is for devices running Aironet software (older)
|
||||
|
||||
=item SNMP::Info::Layer2::Aironet
|
||||
|
||||
This class is for devices running Cisco IOS software (newer)
|
||||
|
||||
=back
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $aironet = new SNMP::Info::Layer2::Aironet(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
=item SNMP::Info::Entity
|
||||
|
||||
=item SNMP::Info::EtherLike
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs required by the inherited classes listed above.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->discription()
|
||||
|
||||
Adds info from method e_descr() from SNMP::Info::Entity
|
||||
|
||||
=item $aironet->vendor()
|
||||
|
||||
Returns 'cisco' :)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Entity
|
||||
|
||||
See documentation in SNMP::Info::Entity for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::EtherLike
|
||||
|
||||
See documentation in SNMP::Info::EtherLike for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->interfaces()
|
||||
|
||||
Uses the i_description() field.
|
||||
|
||||
=item $aironet->i_duplex()
|
||||
|
||||
Crosses information from SNMP::Info::EtherLike to get duplex info for interfaces.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Entity
|
||||
|
||||
See documentation in SNMP::Info::Entity for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::EtherLike
|
||||
|
||||
See documentation in SNMP::Info::EtherLike for details.
|
||||
|
||||
=cut
|
||||
246
Info/Layer2/Allied.pm
Normal file
246
Info/Layer2/Allied.pm
Normal file
@@ -0,0 +1,246 @@
|
||||
# SNMP::Info::Layer2::Allied
|
||||
# Max Baker <max@warped.org>, Dmitry Sergienko <dmitry@trifle.net>
|
||||
#
|
||||
# Copyright (c) 2004 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 Netdisco 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::Layer2::Allied;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::Layer1;
|
||||
|
||||
@SNMP::Info::Layer2::Allied::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
@SNMP::Info::Layer2::Allied::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
'ip_adresses'=> 'atNetAddress',
|
||||
'ip_mac' => 'atPhysAddress',
|
||||
'i_name' => 'ifName',
|
||||
'i_up2' => 'ifOperStatus',
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
'AtiSwitch-MIB' => 'atiswitchProductType',
|
||||
'AtiStackInfo-MIB' => 'atiswitchEnhancedStacking',
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
return 'allied';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'allied';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $allied = shift;
|
||||
my $descr = $allied->description();
|
||||
|
||||
if ($descr =~ m/version (\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $allied = shift;
|
||||
|
||||
my $desc = $allied->description();
|
||||
|
||||
if ($desc =~ /(AT-80\d{2}\S*)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub ip {
|
||||
my $allied = shift;
|
||||
my $ip_hash = $allied->ip_addresses();
|
||||
my $ip;
|
||||
my $found_ip;
|
||||
|
||||
foreach $ip (values %{$ip_hash}) {
|
||||
my $found_ip = SNMP::Info::munge_ip($ip) if (defined $ip);
|
||||
last; # this is only one IP address
|
||||
}
|
||||
return $found_ip;
|
||||
}
|
||||
|
||||
sub mac{
|
||||
my $allied = shift;
|
||||
my $mac_hash = $allied->ip_mac();
|
||||
my $mac;
|
||||
my $found_mac;
|
||||
|
||||
foreach $mac (values %{$mac_hash}) {
|
||||
$found_mac = SNMP::Info::munge_mac($mac);
|
||||
last; # this is only one MAC address
|
||||
}
|
||||
return $found_mac;
|
||||
}
|
||||
|
||||
sub i_up {
|
||||
my $allied = shift;
|
||||
|
||||
my $i_up = SNMP::Info::Layer1::i_up($allied);
|
||||
my $i_up2 = $allied->i_up2();
|
||||
|
||||
foreach my $port (keys %$ati_up){
|
||||
my $up = $ati_up->{$port};
|
||||
$i_up->{$port} = 'down' if $up eq 'linktesterror';
|
||||
$i_up->{$port} = 'up' if $up eq 'nolinktesterror';
|
||||
}
|
||||
|
||||
return $i_up;
|
||||
}
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Allied - SNMP Interface to Allied Telesyn switches
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $allied = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myhub',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $l1->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Allied device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer1
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item ATI-MIB
|
||||
|
||||
Download for your device from http://www.allied-telesyn.com/allied/support/
|
||||
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs listed in SNMP::Info::Layer1 and its inherited classes.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $allied->vendor()
|
||||
|
||||
Returns 'allied' :)
|
||||
|
||||
=item $allied->os()
|
||||
|
||||
Returns 'allied'
|
||||
|
||||
=item $allied->os_ver()
|
||||
|
||||
Culls Version from description()
|
||||
|
||||
=item $allied->root_ip()
|
||||
|
||||
Returns IP Address of Managed Hub.
|
||||
|
||||
(B<actualIpAddr>)
|
||||
|
||||
=item $allied->model()
|
||||
|
||||
Trys to cull out AT-nnnnX out of the description field.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::Layer1
|
||||
|
||||
See documentation in SNMP::Info::Layer1 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $allied->i_name()
|
||||
|
||||
Returns reference to map of IIDs to human-set port name.
|
||||
|
||||
=item $allied->i_up()
|
||||
|
||||
Returns reference to map of IIDs to link status. Changes
|
||||
the values of ati_up() to 'up' and 'down'.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Allied MIB
|
||||
|
||||
=over
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -1,5 +1,8 @@
|
||||
# SNMP::Info::Layer2::Bay
|
||||
# Max Baker <max@warped.org>
|
||||
# This module depricated. See Layer2::BayStack
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
@@ -28,7 +31,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::Bay;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
@@ -73,6 +76,44 @@ $SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
|
||||
'i_mac2' => \&SNMP::Info::munge_mac ,
|
||||
);
|
||||
|
||||
sub os {
|
||||
return 'bay';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $bay = shift;
|
||||
my $descr = $bay->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
# 303 / 304
|
||||
if ($descr =~ m/Rev: \d+\.\d+\.\d+\.\d+-(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
# 450
|
||||
if ($descr =~ m/SW:v(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub os_bin {
|
||||
my $bay = shift;
|
||||
my $descr = $bay->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
# 303 / 304
|
||||
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
# 450
|
||||
if ($descr =~ m/FW:v(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
# or nortel, or synopsis?
|
||||
return 'bay';
|
||||
@@ -116,7 +157,9 @@ sub i_mac {
|
||||
sub model {
|
||||
my $bay = shift;
|
||||
my $id = $bay->id();
|
||||
return undef unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
$model =~ s/^sreg-//i;
|
||||
|
||||
my $descr = $bay->description();
|
||||
@@ -136,6 +179,7 @@ sub c_if {
|
||||
my %c_if;
|
||||
foreach my $entry (keys %$bay_topo_port){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next unless defined $port;
|
||||
next if $port == 0;
|
||||
$c_if{"$port.1"} = $port;
|
||||
}
|
||||
@@ -154,7 +198,8 @@ sub c_ip {
|
||||
my %ip_port;
|
||||
foreach my $entry (keys %$bay_topo_ip){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next if $port == 0;
|
||||
next unless defined $port;
|
||||
next if ($port =~ /^[\d\.]+$/ and $port == 0);
|
||||
my $ip = $bay_topo_ip->{$entry};
|
||||
push(@{$ip_port{$port}},$ip);
|
||||
}
|
||||
@@ -180,6 +225,7 @@ sub c_port {
|
||||
my %c_port;
|
||||
foreach my $entry (keys %$bay_topo_seg){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next unless defined $port;
|
||||
next if $port == 0;
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
@@ -204,7 +250,7 @@ sub c_platform {
|
||||
|
||||
my %c_platform;
|
||||
foreach my $entry (keys %$bay_topo_platform){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
my $port = $bay_topo_port->{$entry} || 0;
|
||||
next if $port == 0;
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
@@ -218,38 +264,12 @@ sub c_platform {
|
||||
return \%c_platform;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network Switches
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Bay device through SNMP.
|
||||
|
||||
Inherits from
|
||||
|
||||
SNMP::Info::Layer2
|
||||
|
||||
Required MIBs:
|
||||
|
||||
SYNOPTICS-ROOT-MIB
|
||||
S5-ETH-MULTISEG-TOPOLOGY-MIB
|
||||
MIBS listed in SNMP::Info::Layer2
|
||||
|
||||
Bay MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, if you still have a service contract they can be downloaded at
|
||||
www.nortelnetworks.com
|
||||
|
||||
They have also been seen at : http://www.inotech.com/mibs/vendor/baynetworks/synoptics/synoptics.asp
|
||||
|
||||
Or http://www.oidview.com/mibs/detail.html under Synoptics.
|
||||
|
||||
You will need at least the two listed above, and probably a few more.
|
||||
SNMP::Info::Layer2::Bay - SNMP Interface to old Bay Network BayStack Switches
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -257,40 +277,53 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $bay = new SNMP::Info::Layer2::Bay(DestHost => 'mybayswitch' ,
|
||||
Community => 'public' );
|
||||
This module is Depricated. Please use Layer2::BayStack instead.
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Bay device through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $bay = new SNMP::Info::Layer2::Bay(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::Bay()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $bay = new SNMP::Info::Layer2::Bay(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $bay;
|
||||
|
||||
=item $bay->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $bay->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$bay->session($newsession);
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item SYNOPTICS-ROOT-MIB
|
||||
|
||||
=item S5-ETH-MULTISEG-TOPOLOGY-MIB
|
||||
|
||||
=item Inherited classes
|
||||
|
||||
MIBs required by SNMP::Info::Layer2 and its superclasses.
|
||||
|
||||
=back
|
||||
|
||||
Bay MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, if you still have a service contract they can be downloaded at
|
||||
www.nortelnetworks.com
|
||||
|
||||
They have also been seen at : http://www.inotech.com/mibs/vendor/baynetworks/synoptics/synoptics.asp
|
||||
|
||||
Or http://www.oidview.com/mibs/detail.html under Synoptics. Check also www.mibdepot.com
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $bay->vendor()
|
||||
@@ -319,8 +352,15 @@ Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 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
|
||||
@@ -427,4 +467,8 @@ Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() i
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=cut
|
||||
|
||||
426
Info/Layer2/Baystack.pm
Normal file
426
Info/Layer2/Baystack.pm
Normal file
@@ -0,0 +1,426 @@
|
||||
# SNMP::Info::Layer2::Baystack
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
# 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::Layer2::Baystack;
|
||||
$VERSION = 0.9;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::NortelStack;
|
||||
use SNMP::Info::SONMP;
|
||||
use SNMP::Info::RapidCity;
|
||||
|
||||
@SNMP::Info::Layer2::Baystack::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP SNMP::Info::RapidCity Exporter/;
|
||||
@SNMP::Info::Layer2::Baystack::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::NortelStack::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
%SNMP::Info::RapidCity::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::NortelStack::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
%SNMP::Info::RapidCity::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::NortelStack::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
%SNMP::Info::RapidCity::FUNCS,
|
||||
'i_name2' => 'ifName',
|
||||
'i_mac2' => 'ifPhysAddress',
|
||||
);
|
||||
|
||||
# 450's report full duplex as speed = 20mbps?!
|
||||
$SNMP::Info::SPEED_MAP{20_000_000} = '10 Mbps';
|
||||
$SNMP::Info::SPEED_MAP{200_000_000} = '100 Mbps';
|
||||
$SNMP::Info::SPEED_MAP{2_000_000_000} = '1.0 Gbps';
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::NortelStack::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
%SNMP::Info::RapidCity::MUNGE,
|
||||
'i_mac2' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
sub os {
|
||||
my $baystack = shift;
|
||||
my $descr = $baystack->description();
|
||||
my $model = $baystack->model();
|
||||
|
||||
if ((defined $model and $model =~ /(470|460|BPS|5510|5520)/) and (defined $descr and $descr =~ m/SW:v[3-5]/i)) {
|
||||
return 'boss';
|
||||
}
|
||||
return 'baystack';
|
||||
}
|
||||
|
||||
sub os_bin {
|
||||
my $baystack = shift;
|
||||
my $descr = $baystack->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
# 303 / 304
|
||||
if ($descr =~ m/Rev: \d+\.(\d+\.\d+\.\d+)-\d+\.\d+\.\d+\.\d+/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
# 450
|
||||
if ($descr =~ m/FW:V(\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
if ($descr =~ m/FW:(\d+\.\d+\.\d+\.\d+)/i){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $baystack = shift;
|
||||
my $id = $baystack->id();
|
||||
return undef unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
$model =~ s/^sreg-//i;
|
||||
|
||||
my $descr = $baystack->description();
|
||||
|
||||
return '303' if (defined $descr and $descr =~ /\D303\D/);
|
||||
return '304' if (defined $descr and $descr =~ /\D304\D/);
|
||||
return '350' if ($model =~ /BayStack350/);
|
||||
return '380' if ($model =~ /BayStack380/);
|
||||
return '410' if ($model =~ /BayStack410/);
|
||||
return '420' if ($model =~ /BayStack420/);
|
||||
return '425' if ($model =~ /BayStack425/);
|
||||
return '450' if ($model =~ /BayStack450/);
|
||||
return '470' if ($model =~ /BayStack470/i);
|
||||
return '460' if ($model =~ /BayStack460/i);
|
||||
return 'BPS' if ($model =~ /BPS2000/i);
|
||||
return '5510' if ($model =~ /BayStack5510/i);
|
||||
return '5520' if ($model =~ /BayStack5520/i);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $baystack = shift;
|
||||
my $i_type = $baystack->i_type();
|
||||
|
||||
my %i_ignore;
|
||||
foreach my $if (keys %$i_type){
|
||||
my $type = $i_type->{$if};
|
||||
next unless defined $type;
|
||||
$i_ignore{$if}++ if $type =~ /(54|loopback|propvirtual|cpu)/i;
|
||||
}
|
||||
return \%i_ignore;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $baystack = shift;
|
||||
my $i_index = $baystack->i_index();
|
||||
my $index_factor = $baystack->index_factor();
|
||||
my $slot_offset = $baystack->slot_offset();
|
||||
|
||||
my %if;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
# Ignore cascade ports
|
||||
next if $index > 513;
|
||||
|
||||
my $port = ($index % $index_factor);
|
||||
my $slot = (int($index / $index_factor)) + $slot_offset;
|
||||
|
||||
my $slotport = "$slot.$port";
|
||||
$if{$iid} = $slotport;
|
||||
}
|
||||
return \%if;
|
||||
}
|
||||
|
||||
sub i_mac {
|
||||
my $baystack = shift;
|
||||
my $i_mac = $baystack->i_mac2();
|
||||
|
||||
my %i_mac;
|
||||
# Baystack 303's with a hw rev < 2.11.4.5 report the mac as all zeros
|
||||
foreach my $iid (keys %$i_mac){
|
||||
my $mac = $i_mac->{$iid};
|
||||
next unless defined $mac;
|
||||
next if $mac eq '00:00:00:00:00:00';
|
||||
$i_mac{$iid}=$mac;
|
||||
}
|
||||
return \%i_mac;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $baystack = shift;
|
||||
my $i_index = $baystack->i_index();
|
||||
my $i_alias = $baystack->i_alias();
|
||||
my $i_name2 = $baystack->i_name2();
|
||||
|
||||
my %i_name;
|
||||
foreach my $iid (keys %$i_name2){
|
||||
my $name = $i_name2->{$iid};
|
||||
my $alias = $i_alias->{$iid};
|
||||
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
|
||||
$alias :
|
||||
$name;
|
||||
}
|
||||
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub index_factor {
|
||||
my $baystack = shift;
|
||||
my $model = $baystack->model();
|
||||
my $os = $baystack->os();
|
||||
my $op_mode = $baystack->ns_op_mode();
|
||||
|
||||
$op_mode = 'pure' unless defined $op_mode;
|
||||
|
||||
my $index_factor = 32;
|
||||
$index_factor = 64 if ((defined $model and $model =~ /(470)/) or ($os eq 'BoSS') and ($op_mode eq 'pure'));
|
||||
|
||||
return $index_factor;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Baystack - SNMP Interface to Nortel Networks' Baystack Switches
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>),
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $baystack = 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 = $baystack->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a Nortel Networks'
|
||||
Baystack device through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $baystack = new SNMP::Info::Layer2::Baystack(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=item SNMP::Info::NortelStack
|
||||
|
||||
=item SNMP::Info::SONMP
|
||||
|
||||
=item SNMP::Info::RapidCity
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::NortelStack for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::SONMP for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::RapidCity for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $baystack->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $baystack->model()
|
||||
|
||||
Cross references $baystack->id() to the SYNOPTICS-MIB and returns
|
||||
the results. 303s and 304s have the same ID, so we have a hack
|
||||
to return depending on which it is.
|
||||
|
||||
Removes sreg- from the model name
|
||||
|
||||
=item $baystack->os()
|
||||
|
||||
Returns 'Baystack' or 'BoSS' depending on software version.
|
||||
|
||||
=item $baystack->os_bin()
|
||||
|
||||
Returns the firmware version extracted from B<sysDescr>.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $baystack->index_factor()
|
||||
|
||||
Required by SNMP::Info::SONMP. Number representing the number of ports
|
||||
reserved per slot within the device MIB.
|
||||
|
||||
Index factor on the Baystack switches are determined by the formula: Index
|
||||
Factor = 64 if (model = 470 or (os eq 'BoSS' and operating in pure mode))
|
||||
or else Index factor = 32.
|
||||
|
||||
Returns either 32 or 64 based upon the formula.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::RapidCity
|
||||
|
||||
See documentation in SNMP::Info::RapidCity 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 $baystack->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port.
|
||||
|
||||
Slot and port numbers on the Baystack switches are determined by the formula:
|
||||
|
||||
port = (Interface index % Index factor)
|
||||
slot = (int(Interface index / Index factor)) + Slot offset
|
||||
|
||||
The physical port name is returned as slot.port.
|
||||
|
||||
=item $baystack->i_ignore()
|
||||
|
||||
Returns reference to hash of IIDs to ignore.
|
||||
|
||||
=item $baystack->i_mac()
|
||||
|
||||
Returns the B<ifPhysAddress> table entries.
|
||||
|
||||
Removes all entries matching '00:00:00:00:00:00' -- Certain
|
||||
revisions of Baystack firmware report all zeros for each port mac.
|
||||
|
||||
=item $baystack->i_name()
|
||||
|
||||
Crosses ifName with ifAlias and returns the human set port name if exists.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::RapidCity
|
||||
|
||||
See documentation in SNMP::Info::RapidCity for details.
|
||||
|
||||
=cut
|
||||
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer2::C1900
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,25 +30,30 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::C1900;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
|
||||
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer2::C1900::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,
|
||||
'c1900_flash_status' => 'upgradeFlashBankStatus',
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
'i_type2' => 'ifType',
|
||||
'i_name2' => 'ifName',
|
||||
# ESSWITCH-MIB
|
||||
'c1900_p_index' => 'swPortIndex',
|
||||
'c1900_p_ifindex' => 'swPortIfIndex',
|
||||
@@ -60,16 +67,51 @@ use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
# Also known as the ESSWITCH-MIB
|
||||
'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000'
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
}
|
||||
sub os {
|
||||
return 'catalyst';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $c1900 = shift;
|
||||
|
||||
# Check for superclass one
|
||||
my $os_ver = $c1900->SUPER::os_ver();
|
||||
return $os_ver if defined $os_ver;
|
||||
|
||||
my $c1900_flash_status = $c1900->c1900_flash_status();
|
||||
return undef unless defined $c1900_flash_status;
|
||||
|
||||
if ($c1900_flash_status =~ m/V(\d+\.\d+(\.\d+)?)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
1;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $c1900 = shift;
|
||||
my $i_descr = $c1900->i_description();
|
||||
|
||||
foreach my $iid (keys %$i_descr){
|
||||
$i_descr->{$iid} =~ s/\s*$//;
|
||||
}
|
||||
return $i_descr;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $c1900 = shift;
|
||||
@@ -143,29 +185,28 @@ sub i_type {
|
||||
|
||||
return $i_type;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $c1900 = shift;
|
||||
my $i_name = $c1900->i_name2();
|
||||
my $c1900_p_name = $c1900->c1900_p_name();
|
||||
|
||||
foreach my $port (keys %$c1900_p_name){
|
||||
my $name = $c1900_p_name->{$port};
|
||||
next unless defined $name;
|
||||
next unless $name !~ /^\s*$/;
|
||||
$i_name->{$port} = $name;
|
||||
}
|
||||
|
||||
return $i_name;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::C1900 - SNMP Interface to old C1900 Network Switches
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
C1900 device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info::Layer2
|
||||
|
||||
Required MIBs:
|
||||
|
||||
STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
|
||||
MIBs listed in SNMP::Info::Layer2
|
||||
|
||||
ESSWITCH-MIB is included in the Version 1 MIBS from Cisco.
|
||||
They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
|
||||
SNMP::Info::Layer2::C1900 - Perl5 Interface to SNMP data from Cisco Catlyst 1900 Network Switches running CatOS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -173,48 +214,90 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $c1900 = new SNMP::Info::Layer2::C1900(DestHost => 'mycat1900' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $c1900 = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $c1900->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a Catalyst 1900 device through SNMP.
|
||||
See SNMP::Info for full documentation
|
||||
|
||||
Note that most of these devices only talk SNMP version 1, but not all.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $c1900 = new SNMP::Info::Layer2::C1900(...);
|
||||
|
||||
=head2 Inherited classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::C1900()
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=back
|
||||
|
||||
my $c1900 = new SNMP::Info::Layer2::C1900(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $c1900;
|
||||
=head2 Required MIBs
|
||||
|
||||
=item $c1900->session()
|
||||
=over
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
=item STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB)
|
||||
|
||||
# Get
|
||||
my $sess = $c1900->session();
|
||||
ESSWITCH-MIB is included in the Version 1 MIBS from Cisco.
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$c1900->session($newsession);
|
||||
They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
MIBs listed in SNMP::Info::Layer2
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $c1900->c1900_flash_status()
|
||||
|
||||
Usually contains the version of the software loaded in flash.
|
||||
Used by os_ver()
|
||||
|
||||
B<STAND-ALONE-ETHERNET-SWITCH-MIB::upgradeFlashBankStatus>
|
||||
|
||||
=item $c1900->os()
|
||||
|
||||
Returns 'catalyst'
|
||||
|
||||
=item $c1900->os_ver()
|
||||
|
||||
Returns CatOS version if obtainable. First tries to use
|
||||
SNMP::Info::CiscoStats->os_ver() . If that fails then it
|
||||
checks for the presence of $c1900->c1900_flash_status() and culls
|
||||
the version from there.
|
||||
|
||||
=item $c1900->vendor()
|
||||
|
||||
Returns 'cisco' :)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
@@ -233,6 +316,10 @@ Returns reference to hash of IIDs to admin duplex setting
|
||||
|
||||
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex_admin;
|
||||
|
||||
=item $c1900->i_name()
|
||||
|
||||
Crosses ifName with c1900_p_name() and returns the human set port name if exists.
|
||||
|
||||
=item $c1900->i_type()
|
||||
|
||||
Returns reference to hash of IID to port type
|
||||
@@ -291,4 +378,8 @@ B<swPortConnectorType>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# SNMP::Info::Layer2::C2900
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, Regents of the University of California
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,43 +30,52 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::C2900;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $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,
|
||||
'i_name' => 'ifAlias',
|
||||
# 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';
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
1;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $c2900 = shift;
|
||||
|
||||
@@ -134,20 +145,12 @@ sub interfaces {
|
||||
return \%if
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Network Switches
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
C2900 device through SNMP.
|
||||
|
||||
MIBS: CISCO-C2900-MIB
|
||||
|
||||
Inherits all SNMP::Info::Layer2 methods.
|
||||
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Switches running IOS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -155,40 +158,62 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $c2900 = new SNMP::Info::Layer2::C2900(DestHost => 'mycat2900' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $c2900 = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $c2900->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
C2900 device through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $c2900 = new SNMP::Info::Layer2::C2900(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::C2900()
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
my $c2900 = new SNMP::Info::Layer2::C2900(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $c2900;
|
||||
=back
|
||||
|
||||
=item $c2900->session()
|
||||
=head2 Required MIBs
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
=over
|
||||
|
||||
# Get
|
||||
my $sess = $c2900->session();
|
||||
=item CISCO-C2900-MIB
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$c2900->session($newsession);
|
||||
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
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $c2900->vendor()
|
||||
@@ -197,8 +222,19 @@ Sets or returns the SNMP::Session object
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
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
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
@@ -261,5 +297,12 @@ Sets or returns the SNMP::Session object
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
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,2004 Max Baker changes from version 0.8 and beyond
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,17 +29,19 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::Catalyst;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $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
|
||||
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %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,96 +50,28 @@ $DEBUG=0;
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MYMIBS = (
|
||||
'CISCO-STACK-MIB' => 'moduleType',
|
||||
'CISCO-VTP-MIB' => 'vtpVlanIndex'
|
||||
);
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::CiscoVTP::MIBS,
|
||||
%SNMP::Info::CiscoStack::MIBS,
|
||||
);
|
||||
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
%MYMIBS );
|
||||
|
||||
%MYGLOBALS = (
|
||||
# these are in CISCO-STACK-MIB
|
||||
'sysip' => 'sysIpAddr',
|
||||
'netmask' => 'sysNetMask',
|
||||
'broadcast' => 'sysBroadcast',
|
||||
'serial' => 'chassisSerialNumberString',
|
||||
'model' => 'chassisModel',
|
||||
'ps1_type' => 'chassisPs1Type',
|
||||
'ps1_status' => 'chassisPs1Status',
|
||||
'ps2_type' => 'chassisPs2Type',
|
||||
'ps2_status' => 'chassisPs2Status',
|
||||
'slots' => 'chassisNumSlots',
|
||||
'fan' => 'chassisFanStatus'
|
||||
);
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS,
|
||||
%MYGLOBALS
|
||||
);
|
||||
|
||||
%MYFUNCS = (
|
||||
'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::GLOBALS,
|
||||
%SNMP::Info::CiscoStack::GLOBALS,
|
||||
);
|
||||
%FUNCS = (
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer2::FUNCS,
|
||||
%MYFUNCS
|
||||
);
|
||||
|
||||
%MYMUNGE = (
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
%SNMP::Info::CiscoStack::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%MUNGE = (
|
||||
%SNMP::Info::Layer2::MUNGE,
|
||||
%MYMUNGE
|
||||
);
|
||||
|
||||
%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);
|
||||
}
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
%SNMP::Info::CiscoStack::MUNGE,
|
||||
);
|
||||
|
||||
# Overidden Methods
|
||||
|
||||
@@ -154,114 +89,37 @@ 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};
|
||||
$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';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'catalyst';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $cat = shift;
|
||||
my $os_ver = $cat->SUPER::os_ver();
|
||||
return $os_ver if defined $os_ver;
|
||||
|
||||
my $m_swver = $cat->m_swver();
|
||||
return undef unless defined $m_swver;
|
||||
|
||||
# assume .1 entry is the chassis and the sw version we want.
|
||||
return $m_swver->{1} if defined $m_swver->{1};
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
1;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco devices running Catalyst OS
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Catalyst device through SNMP. Information is stored in a number of
|
||||
MIB's such as IF-MIB, CISCO-CDP-MIB, CISCO-STACK-MIB, CISCO-VTP-MIB,
|
||||
and SWITCH-MIB.
|
||||
SNMP::Info::Layer2::Catalyst - Perl5 Interface to Cisco Catalyst 5000 series devices.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -269,241 +127,116 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $cat = new SNMP::Info::Layer2::Catalyst(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $cat = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $cat->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
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.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $cat = new SNMP::Info::Layer2::Catalyst(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::Catalyst()
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
my $cat = new SNMP::Info::Layer2::Catalyst(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $cat;
|
||||
|
||||
=item $cat->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $cat->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$cat->session($newsession);
|
||||
=item SNMP::Info::CiscoStack
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBAL Values
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->netmask()
|
||||
(B<sysNetMask>)
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
=item $cat->broadcast()
|
||||
(B<sysBroadcast>)
|
||||
See SNMP::Info::Layer2 for its own MIB requirements.
|
||||
|
||||
=item $cat->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
=item $cat->model()
|
||||
(B<chassisModel>)
|
||||
See SNMP::Info::CiscoStack for its own MIB requirements.
|
||||
|
||||
=item $cat->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
=back
|
||||
|
||||
=item $cat->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
These MIBs are found in the standard v2 MIBs from Cisco.
|
||||
|
||||
=item $cat->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
=head1 GLOBALS
|
||||
|
||||
=item $cat->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=item $cat->slots()
|
||||
(B<chassisNumSlots>)
|
||||
=over
|
||||
|
||||
=item $cat->fan()
|
||||
(B<chassisFanStatus>)
|
||||
=item $cat->os()
|
||||
|
||||
Returns 'catalyst'
|
||||
|
||||
=item $cat->os_ver()
|
||||
|
||||
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->vendor()
|
||||
|
||||
Returns 'cisco'
|
||||
Returns 'cisco'
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
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
|
||||
|
||||
=head2 Overrides
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=over
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
=item $cat->interfaces()
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
Crosses p_port() with i_index() to get physical names.
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
=item $cat->i_physical()
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
Returns a map to IID for ports that are physical ports, not vlans, etc.
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2::CiscoSTack
|
||||
|
||||
=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::Layer2::CiscoStack for details.
|
||||
|
||||
=cut
|
||||
|
||||
521
Info/Layer2/Centillion.pm
Normal file
521
Info/Layer2/Centillion.pm
Normal file
@@ -0,0 +1,521 @@
|
||||
# SNMP::Info::Layer2::Centillion
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::Layer2::Centillion;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::NortelStack;
|
||||
use SNMP::Info::SONMP;
|
||||
|
||||
@SNMP::Info::Layer2::Centillion::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::NortelStack SNMP::Info::SONMP Exporter/;
|
||||
@SNMP::Info::Layer2::Centillion::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::NortelStack::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
'CENTILLION-DOT3-EXTENSIONS-MIB' => 'cnDot3ExtnTable',
|
||||
'S5-COMMON-STATS-MIB' => 's5CmStat',
|
||||
'CENTILLION-VLAN-MIB' => 'cnVlanENETMgt',
|
||||
'CENTILLION-CONFIG-MIB' => 'sysTFTPStart',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::NortelStack::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
'tftp_action' => 'sysTFTPStart',
|
||||
'tftp_host' => 'sysTFTPIpAddress',
|
||||
'tftp_file' => 'sysTFTPFileName',
|
||||
'tftp_type' => 'sysTFTPFileType',
|
||||
'tftp_result' => 'sysTFTPResult',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::NortelStack::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
# CENTILLION-DOT3-EXTENSIONS-MIB::cnDot3ExtnTable
|
||||
'centillion_p_index' => 'cnDot3ExtnIfIndex',
|
||||
'centillion_p_duplex' => 'cnDot3ExtnIfOperConnectionType',
|
||||
'centillion_p_duplex_admin' => 'cnDot3ExtnIfAdminConnectionType',
|
||||
# S5-COMMON-STATS-MIB::s5CmSNodeTable
|
||||
'fw_mac' => 's5CmSNodeMacAddr',
|
||||
'fw_port' => 's5CmSNodeIfIndx',
|
||||
# CENTILLION-VLAN-MIB::cnVlanPortMemberTable
|
||||
'centillion_i_vlan_index' => 'cnVlanPortMemberIfIndex',
|
||||
'centillion_i_vlan' => 'cnVlanPortMemberVID',
|
||||
'centillion_i_vlan_type' => 'cnVlanPortMemberIngressType',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::NortelStack::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
);
|
||||
|
||||
sub os {
|
||||
return 'centillion';
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $centillion = shift;
|
||||
my $descr = $centillion->i_description();
|
||||
|
||||
my %i_ignore;
|
||||
foreach my $if (keys %$descr){
|
||||
my $type = $descr->{$if};
|
||||
# Skip virtual interfaces
|
||||
$i_ignore{$if}++ if $type =~ /(VE|VID|vc|lp)/i;
|
||||
}
|
||||
return \%i_ignore;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $centillion = shift;
|
||||
my $i_index = $centillion->i_index();
|
||||
my $i_descr = $centillion->i_description();
|
||||
|
||||
my %if;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $descr = $i_descr->{$iid};
|
||||
# Skip ATM and virtual interfaces
|
||||
next if $descr =~ /(VE|VID|vc|lp)/i;
|
||||
|
||||
# Index numbers are deterministic slot * 256 + port
|
||||
my $port = $index % 256;
|
||||
my $slot = int($index / 256);
|
||||
my $slotport = "$slot.$port";
|
||||
|
||||
$slotport = "$descr" if $descr =~ /(mcp)/i;
|
||||
|
||||
$if{$index} = $slotport;
|
||||
}
|
||||
|
||||
return \%if;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $centillion = shift;
|
||||
|
||||
my $port_index = $centillion->centillion_p_index();
|
||||
my $port_duplex = $centillion->centillion_p_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $duplex = $port_duplex->{$iid};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
$i_duplex{$index}=$duplex;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $centillion = shift;
|
||||
|
||||
my $port_index = $centillion->centillion_p_index();
|
||||
my $port_admin = $centillion->centillion_p_duplex_admin();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $iid (keys %$port_index){
|
||||
my $index = $port_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $duplex = $port_admin->{$iid};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
$duplex = 'auto' if $duplex =~ /auto/i;
|
||||
$i_duplex_admin{$index}=$duplex;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $centillion = shift;
|
||||
|
||||
my $cn_vlan_index = $centillion->centillion_i_vlan_index();
|
||||
my $cn_vlan = $centillion->centillion_i_vlan();
|
||||
|
||||
my %i_vlan;
|
||||
foreach my $iid (keys %$cn_vlan_index){
|
||||
my $index = $cn_vlan_index->{$iid};
|
||||
next unless defined $index;
|
||||
my $vlan = $cn_vlan->{$iid};
|
||||
next unless defined $vlan;
|
||||
|
||||
$i_vlan{$index}=$vlan;
|
||||
}
|
||||
return \%i_vlan;
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $centillion = shift;
|
||||
my $id = $centillion->id();
|
||||
return undef unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
$model =~ s/^sreg-//i;
|
||||
|
||||
return '5000BH' if ($model =~ /5000BH/);
|
||||
return '5005BH' if ($model =~ /5005BH/);
|
||||
return 'C100' if ($model =~ /Centillion100/);
|
||||
return 'C50N' if ($model =~ /Centillion50N/);
|
||||
return 'C50T' if ($model =~ /Centillion50T/);
|
||||
return $model;
|
||||
}
|
||||
|
||||
sub bp_index {
|
||||
my $centillion = shift;
|
||||
my $index = $centillion->fw_port();
|
||||
|
||||
my %bp_index;
|
||||
foreach my $iid (keys %$index){
|
||||
my $b_index = $index->{$iid};
|
||||
next unless defined $b_index;
|
||||
|
||||
#Index value is the same as ifIndex
|
||||
$bp_index{$b_index} = $b_index;
|
||||
}
|
||||
|
||||
return \%bp_index;
|
||||
}
|
||||
|
||||
sub index_factor {
|
||||
return 256;
|
||||
}
|
||||
|
||||
sub slot_offset {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Centillion - SNMP Interface to Nortel Centillion based ATM Switches
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $centillion = 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 = $centillion->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
Centillion device through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $centillion = new SNMP::Info::Layer2::centillion(...);
|
||||
|
||||
Note: This class supports version 4.X and 5.X which are VLAN based rather
|
||||
than bridge group based.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=item SNMP::Info::NortelStack
|
||||
|
||||
=item SNMP::Info::SONMP
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item CENTILLION-DOT3-EXTENSIONS-MIB
|
||||
|
||||
=item S5-COMMON-STATS-MIB
|
||||
|
||||
=item CENTILLION-VLAN-MIB
|
||||
|
||||
=item CENTILLION-CONFIG-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::NortelStack for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::SONMP for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status.
|
||||
|
||||
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
|
||||
Select by Product Families, Centillion, Centillion C100-C50 ATM Speed Modules,
|
||||
Software. Filter on mibs and download the latest version's archive.
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $centillion->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $centillion->model()
|
||||
|
||||
Cross references $centillion->id() to the SYNOPTICS-MIB and returns
|
||||
the results.
|
||||
|
||||
Removes sreg- from the model name
|
||||
|
||||
=item $centillion->os()
|
||||
|
||||
Returns 'Centillion'
|
||||
|
||||
=item $centillion->tftp_action()
|
||||
|
||||
(B<sysTFTPStart>)
|
||||
|
||||
=item $centillion->tftp_host()
|
||||
|
||||
(B<sysTFTPIpAddress>)
|
||||
|
||||
=item $centillion->tftp_file()
|
||||
|
||||
(B<sysTFTPFileName>)
|
||||
|
||||
=item $centillion->tftp_type()
|
||||
|
||||
(B<sysTFTPFileType>)
|
||||
|
||||
=item $centillion->tftp_result()
|
||||
|
||||
(B<sysTFTPResult>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $centillion->layers()
|
||||
|
||||
Returns 00000011. Class emulates Layer 2 functionality through proprietary MIBs.
|
||||
|
||||
=item $centillion->index_factor()
|
||||
|
||||
Required by SNMP::Info::SONMP. Number representing the number of ports
|
||||
reserved per slot within the device MIB. Returns 256.
|
||||
|
||||
=item $centillion->slot_offset()
|
||||
|
||||
Required by SNMP::Info::SONMP. Offset if slot numbering does not
|
||||
start at 0. Returns 0.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP 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 $centillion->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port.
|
||||
|
||||
Slot and port numbers on the Passport switches are determined by the formula:
|
||||
port = index % 256
|
||||
slot = int(index / 256)
|
||||
|
||||
The physical port name is returned as slot.port.
|
||||
|
||||
=item $centillion->i_duplex()
|
||||
|
||||
Returns reference to map of IIDs to current link duplex
|
||||
|
||||
=item $centillion->i_duplex_admin()
|
||||
|
||||
Returns reference to hash of IIDs to admin duplex setting
|
||||
|
||||
=item $centillion->i_ignore()
|
||||
|
||||
Returns reference to hash of IIDs to ignore.
|
||||
|
||||
=item $centillion->fw_mac()
|
||||
|
||||
(B<s5CmSNodeMacAddr>)
|
||||
|
||||
=item $centillion->fw_port()
|
||||
|
||||
(B<s5CmSNodeIfIndx>)
|
||||
|
||||
=item $centillion->bp_index()
|
||||
|
||||
Returns a mapping between ifIndex and the Bridge Table.
|
||||
|
||||
=item $centillion->i_vlan()
|
||||
|
||||
Returns a mapping between ifIndex and the VLAN.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Centillion 802.3 Extension Table (B<cnDot3ExtnTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $centillion->centillion_p_index()
|
||||
|
||||
Returns reference to hash. Maps table IIDs to Interface IIDs
|
||||
|
||||
(B<cnDot3ExtnIfIndex>)
|
||||
|
||||
=item $centillion->centillion_p_duplex()
|
||||
|
||||
Returns reference to hash. Maps port operational duplexes to IIDs
|
||||
|
||||
(B<cnDot3ExtnIfOperConnectionType>)
|
||||
|
||||
=item $centillion->rc_centillion_p_duplex_admin()
|
||||
|
||||
Returns reference to hash. Maps port admin duplexes to IIDs
|
||||
|
||||
(B<cnDot3ExtnIfAdminConnectionType>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Centillion VLAN Table (B<cnVlanPortMemberTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $centillion->centillion_i_vlan_index()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index
|
||||
|
||||
(B<cnVlanPortMemberIfIndex>)
|
||||
|
||||
=item $centillion->centillion_i_vlan()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: VLAN ID
|
||||
|
||||
(B<cnVlanPortMemberVID>)
|
||||
|
||||
=item $centillion->centillion_i_vlan_type()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: VLAN Type
|
||||
|
||||
(B<cnVlanPortMemberIngressType>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::NortelStack
|
||||
|
||||
See documentation in SNMP::Info::NortelStack for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=cut
|
||||
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer2::HP - SNMP Interface to HP ProCurve Switches
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer2::HP;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -36,88 +38,128 @@ use strict;
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::MAU;
|
||||
use SNMP::Info::Entity;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP
|
||||
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU Exporter/;
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT %MODEL_MAP %MUNGE $INIT/ ;
|
||||
|
||||
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU SNMP::Info::Entity Exporter/;
|
||||
@SNMP::Info::Layer2::HP::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
# See SNMP::Info for the details of these data structures and interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MYMIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum',
|
||||
'RFC1271-MIB' => 'logDescription',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
);
|
||||
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::MAU::MIBS,
|
||||
%MYMIBS );
|
||||
%SNMP::Info::Entity::MIBS,
|
||||
'RFC1271-MIB' => 'logDescription',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
'HP-VLAN' => 'hpVlanMemberIndex',
|
||||
'STATISTICS-MIB' => 'hpSwitchCpuStat',
|
||||
'NETSWITCH-MIB' => 'hpMsgBufFree',
|
||||
);
|
||||
|
||||
%MYGLOBALS = ('serial1' => 'entPhysicalSerialNum.1',
|
||||
# 'model' => 'entPhysicalModelName.1',
|
||||
);
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS,
|
||||
%SNMP::Info::MAU::GLOBALS,
|
||||
%MYGLOBALS
|
||||
);
|
||||
|
||||
%MYFUNCS = (
|
||||
'i_type2' => 'ifType',
|
||||
'e_map' => 'entAliasMappingIdentifier',
|
||||
'e_name' => 'entPhysicalName',
|
||||
'e_class' => 'entPhysicalClass',
|
||||
'e_parent' => 'entPhysicalContainedIn',
|
||||
'e_descr' => 'entPhysicalDescr',
|
||||
'e_type' => 'entPhysicalVendorType',
|
||||
'e_model' => 'entPhysicalModelName',
|
||||
'e_hwver' => 'entPhysicalHardwareRev',
|
||||
'e_swver' => 'entPhysicalSoftwareRev',
|
||||
'e_fwver' => 'entPhysicalFirmwareRev',
|
||||
'e_serial' => 'entPhysicalSerialNum',
|
||||
# RFC1271
|
||||
'l_descr' => 'logDescription'
|
||||
|
||||
%SNMP::Info::Entity::GLOBALS,
|
||||
'serial1' => 'entPhysicalSerialNum.1',
|
||||
'hp_cpu' => 'hpSwitchCpuStat.0',
|
||||
'hp_mem_total' => 'hpGlobalMemTotalBytes.1',
|
||||
'mem_free' => 'hpGlobalMemFreeBytes.1',
|
||||
'mem_used' => 'hpGlobalMemAllocBytes.1',
|
||||
'os_version' => 'hpSwitchOsVersion.0',
|
||||
'os_bin' => 'hpSwitchRomVersion.0',
|
||||
'mac' => 'hpSwitchBaseMACAddress.0',
|
||||
'hp_vlans' => 'hpVlanNumber',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer2::FUNCS,
|
||||
%SNMP::Info::MAU::FUNCS,
|
||||
%MYFUNCS
|
||||
);
|
||||
|
||||
%MYMUNGE = (
|
||||
%SNMP::Info::Entity::FUNCS,
|
||||
'i_type2' => 'ifType',
|
||||
# RFC1271
|
||||
'l_descr' => 'logDescription',
|
||||
# HP-VLAN-MIB
|
||||
'hp_v_index' => 'hpVlanDot1QID',
|
||||
'hp_v_name' => 'hpVlanIdentName',
|
||||
'hp_v_state' => 'hpVlanIdentState',
|
||||
'hp_v_type' => 'hpVlanIdentType',
|
||||
'hp_v_status' => 'hpVlanIdentStatus',
|
||||
'hp_v_mac' => 'hpVlanAddrPhysAddress',
|
||||
'hp_v_if_index'=> 'hpVlanMemberIndex',
|
||||
'hp_v_if_tag' => 'hpVlanMemberTagged2',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer2::MUNGE,
|
||||
%SNMP::Info::MAU::MUNGE,
|
||||
%MYMUNGE
|
||||
%SNMP::Info::Entity::MUNGE
|
||||
);
|
||||
|
||||
%MODEL_MAP = (
|
||||
'J4812A' => '2512',
|
||||
'J4819A' => '5308XL',
|
||||
'J4813A' => '2524',
|
||||
'J4805A' => '5304XL',
|
||||
'J4815A' => '3324XL',
|
||||
'J4865A' => '4108GL',
|
||||
'J4887A' => '4104GL',
|
||||
'J4874A' => '9315',
|
||||
);
|
||||
'J4093A' => '2424M',
|
||||
'J4110A' => '8000M',
|
||||
'J4120A' => '1600M',
|
||||
'J4121A' => '4000M',
|
||||
'J4122A' => '2400M',
|
||||
'J4138A' => '9308M',
|
||||
'J4139A' => '9304M',
|
||||
'J4812A' => '2512',
|
||||
'J4813A' => '2524',
|
||||
'J4819A' => '5308XL',
|
||||
'J4840A' => '6308M-SX',
|
||||
'J4841A' => '6208M-SX',
|
||||
'J4850A' => '5304XL',
|
||||
'J4865A' => '4108GL',
|
||||
'J4874A' => '9315M',
|
||||
'J4887A' => '4104GL',
|
||||
'J4899A' => '2650',
|
||||
'J4900A' => '2626',
|
||||
'J4902A' => '6108',
|
||||
'J4903A' => '2824',
|
||||
'J4904A' => '2848',
|
||||
'J8130A' => 'WAP-420-NA',
|
||||
'J8131A' => 'WAP-420-WW',
|
||||
'J8164A' => '2626-PWR',
|
||||
'J8165A' => '2650-PWR',
|
||||
);
|
||||
|
||||
# Method Overrides
|
||||
|
||||
sub cpu {
|
||||
my $hp = shift;
|
||||
return $hp->hp_cpu();
|
||||
}
|
||||
|
||||
sub mem_total {
|
||||
my $hp = shift;
|
||||
return $hp->hp_mem_total();
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'hp';
|
||||
}
|
||||
sub os_ver {
|
||||
my $hp = shift;
|
||||
my $os_version = $hp->os_version();
|
||||
return $os_version if defined $os_version;
|
||||
# Some older ones don't have this value,so we cull it from the description
|
||||
my $descr = $hp->description();
|
||||
if ($descr =~ m/revision ([A-Z]{1}\.\d{2}\.\d{2})/) {
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Lookup model number, and translate the part number to the common number
|
||||
sub model {
|
||||
my $hp = shift;
|
||||
my $id = $hp->id();
|
||||
return undef unless defined $id;
|
||||
my $model = &SNMP::translateObj($id);
|
||||
return $id unless defined $model;
|
||||
|
||||
$model =~ s/^hpswitch//i;
|
||||
|
||||
@@ -131,6 +173,7 @@ sub serial {
|
||||
# procurve 2xxx have this
|
||||
my $serial = $hp->serial1();
|
||||
|
||||
return undef unless defined $serial;
|
||||
# 4xxx dont
|
||||
return undef if $serial =~ /nosuchobject/i;
|
||||
|
||||
@@ -146,7 +189,6 @@ sub interfaces {
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $descr = $i_descr->{$iid};
|
||||
next unless defined $descr;
|
||||
#$if{$iid} = $iid;
|
||||
$if{$iid} = $descr if (defined $descr and length $descr);
|
||||
}
|
||||
|
||||
@@ -154,26 +196,6 @@ sub interfaces {
|
||||
|
||||
}
|
||||
|
||||
# e_port maps EntityTable entries to IfTable
|
||||
sub e_port {
|
||||
my $hp = shift;
|
||||
my $e_map = $hp->e_map();
|
||||
|
||||
my %e_port;
|
||||
|
||||
foreach my $e_id (keys %$e_map) {
|
||||
my $id = $e_id;
|
||||
$id =~ s/\.0$//;
|
||||
|
||||
my $iid = $e_map->{$e_id};
|
||||
$iid =~ s/.*\.//;
|
||||
|
||||
$e_port{$id} = $iid;
|
||||
}
|
||||
|
||||
return \%e_port;
|
||||
}
|
||||
|
||||
sub i_type {
|
||||
my $hp = shift;
|
||||
my $e_descr = $hp->e_descr();
|
||||
@@ -336,26 +358,49 @@ sub i_duplex_admin {
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
#sub i_up_admin {
|
||||
# my $hp = shift;
|
||||
#
|
||||
# my $mau_index = $hp->mau_index();
|
||||
# my $mau_status = $hp->mau_status();
|
||||
#
|
||||
# my %i_up_admin;
|
||||
# foreach my $mau_port (keys %$mau_status){
|
||||
# my $iid = $mau_index->{$mau_port};
|
||||
# next unless defined $iid;
|
||||
# my $status = $mau_status->{$mau_port};
|
||||
#
|
||||
# $i_up_admin{$iid} = ($status =~ /shutdown/i) ?
|
||||
# 'down' : 'up';
|
||||
# }
|
||||
#
|
||||
# return \%i_up_admin;
|
||||
#
|
||||
#}
|
||||
sub i_vlan {
|
||||
my $hp = shift;
|
||||
|
||||
my $interfaces = $hp->interfaces();
|
||||
|
||||
# Newer devices use Q-BRIDGE-MIB
|
||||
my $qb_i_vlan = $hp->qb_i_vlan();
|
||||
my $qb_i_vlan_type = $hp->qb_i_vlan_type();
|
||||
|
||||
my $i_vlan = {};
|
||||
|
||||
foreach my $if (keys %$qb_i_vlan){
|
||||
my $vlan = $qb_i_vlan->{$if};
|
||||
my $tagged = $qb_i_vlan_type->{$if};
|
||||
$tagged = (defined $tagged and $tagged eq 'admitOnlyVlanTagged') ? 1 : 0;
|
||||
next unless defined $vlan;
|
||||
$i_vlan->{$if}= $tagged ? 'trunk' : $vlan;
|
||||
}
|
||||
|
||||
# HP4000 ... get it from HP-VLAN
|
||||
# the hpvlanmembertagged2 table has an entry in the form of
|
||||
# vlan.interface = /untagged/no/tagged/auto
|
||||
unless (defined $qb_i_vlan and scalar(keys %$qb_i_vlan)){
|
||||
my $hp_v_index = $hp->hp_v_index();
|
||||
my $hp_v_if_tag = $hp->hp_v_if_tag();
|
||||
foreach my $row (keys %$hp_v_if_tag){
|
||||
my ($index,$if) = split(/\./,$row);
|
||||
|
||||
my $tag = $hp_v_if_tag->{$row};
|
||||
my $vlan = $hp_v_index->{$index};
|
||||
|
||||
next unless defined $tag;
|
||||
$vlan = 'Trunk' if $tag eq 'tagged';
|
||||
$vlan = 'Auto' if $tag eq 'auto';
|
||||
undef $vlan if $tag eq 'no';
|
||||
|
||||
|
||||
$i_vlan->{$if} = $vlan if defined $vlan;
|
||||
}
|
||||
}
|
||||
|
||||
return $i_vlan;
|
||||
}
|
||||
1;
|
||||
__END__
|
||||
|
||||
@@ -363,219 +408,214 @@ __END__
|
||||
|
||||
SNMP::Info::Layer2::HP - SNMP Interface to HP Procurve Switches
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
HP device through SNMP. Information is stored in a number of
|
||||
MIB's such as IF-MIB, ENTITY-MIB, RFC1271-MIB, HP-ICF-OID, MAU-MIB
|
||||
|
||||
MIBs required:
|
||||
|
||||
=over
|
||||
|
||||
=item RFC1271-MIB
|
||||
|
||||
=item HP-ICF-OID
|
||||
|
||||
=back
|
||||
|
||||
HP MIBs can be found at http://www.hp.com/rnd/software
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $hp = new SNMP::Info::Layer2::HP(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $hp = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $hp->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
HP ProCurve Switch via SNMP.
|
||||
|
||||
Note: Some HP Switches will connect via SNMP version 1, but a lot of config data will
|
||||
not be available. Make sure you try and connect with Version 2 first, and then fail back
|
||||
to version 1.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $hp = new SNMP::Info::Layer2::HP(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::HP()
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::Entity
|
||||
|
||||
my $hp = new SNMP::Info::Layer2::HP(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $hp;
|
||||
|
||||
=item $hp->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $hp->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$hp->session($newsession);
|
||||
|
||||
=item $hp->all(), $hp->load_all()
|
||||
|
||||
Runs each of the HP List methods and returns a hash reference.
|
||||
|
||||
$hp->all() will call $hp->load_all() once and then return cahced valued.
|
||||
Use $hp->load_all() to reload from the device.
|
||||
=item SNMP::Info::MAU
|
||||
|
||||
=back
|
||||
|
||||
=head1 HP Global Configuration Values
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->name()
|
||||
(B<sysName>)
|
||||
=item RFC1271-MIB
|
||||
|
||||
=item $hp->ip()
|
||||
(B<sysIpAddr>)
|
||||
Included in V2 mibs from Cisco
|
||||
|
||||
=item $hp->netmask()
|
||||
(B<sysNetMask>)
|
||||
=item HP-ICF-OID
|
||||
|
||||
=item $hp->broadcast()
|
||||
(B<sysBroadcast>)
|
||||
=item HP-VLAN
|
||||
|
||||
=item $hp->location()
|
||||
(B<sysLocation>)
|
||||
(this MIB new with SNMP::Info 0.8)
|
||||
|
||||
=item $hp->contact()
|
||||
(B<sysContact>)
|
||||
=item STATISTICS-MIB
|
||||
|
||||
=item $hp->description()
|
||||
(B<sysDescr>)
|
||||
=item NETSWITCH-MIB
|
||||
|
||||
=item $hp->layers()
|
||||
(B<sysServices>)
|
||||
=back
|
||||
|
||||
=item $hp->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
The last three MIBs listed are from HP and can be found at L<http://www.hp.com/rnd/software>
|
||||
or L<http://www.hp.com/rnd/software/MIBs.htm>
|
||||
|
||||
=head1 ChangeLog
|
||||
|
||||
Version 0.4 - Removed ENTITY-MIB e_*() methods to separate sub-class - SNMP::Info::Entity
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->cpu()
|
||||
|
||||
Returns CPU Utilization in percentage.
|
||||
|
||||
=item $hp->log()
|
||||
|
||||
Returns all the log entries from the switch's log that are not Link up or down messages.
|
||||
|
||||
=item $hp->mem_free()
|
||||
|
||||
Returns bytes of free memory
|
||||
|
||||
=item $hp->mem_total()
|
||||
|
||||
Return bytes of total memory
|
||||
|
||||
=item $hp->mem_used()
|
||||
|
||||
Returns bytes of used memory
|
||||
|
||||
=item $hp->model()
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $hp->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
Returns the model number of the HP Switch. Will translate between the HP Part number and
|
||||
the common model number with this map :
|
||||
|
||||
=item $hp->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
%MODEL_MAP = (
|
||||
'J4812A' => '2512',
|
||||
'J4819A' => '5308XL',
|
||||
'J4813A' => '2524',
|
||||
'J4805A' => '5304XL',
|
||||
'J4815A' => '3324XL',
|
||||
'J4865A' => '4108GL',
|
||||
'J4887A' => '4104GL',
|
||||
'J4874A' => '9315',
|
||||
);
|
||||
|
||||
=item $hp->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
=item $hp->os()
|
||||
|
||||
=item $hp->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
Returns hp
|
||||
|
||||
=item $hp->os_bin()
|
||||
|
||||
B<hpSwitchRomVersion.0>
|
||||
|
||||
=item $hp->os_ver()
|
||||
|
||||
Tries to use os_version() and if that fails will try and cull the version from
|
||||
the description field.
|
||||
|
||||
=item $hp->os_version()
|
||||
|
||||
B<hpSwitchOsVersion.0>
|
||||
|
||||
=item $hp->serial()
|
||||
|
||||
Returns serial number if available through SNMP
|
||||
|
||||
=item $hp->slots()
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=item $hp->fan()
|
||||
(B<chassisFanStatus>)
|
||||
Returns number of entries in $hp->e_name that have 'slot' in them.
|
||||
|
||||
=item $hp->vendor()
|
||||
|
||||
hp
|
||||
|
||||
=back
|
||||
|
||||
=head1 CATALYST TABLE ENTRIES
|
||||
=head2 Globals imported from SNMP::Info::Layer2
|
||||
|
||||
=head2 Module table
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Entity
|
||||
|
||||
See documentation in SNMP::Info::Entity for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::MAU
|
||||
|
||||
See documentation in SNMP::Info::MAU for details.
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->m_type(), $hp->load_m_type()
|
||||
(B<moduleType>)
|
||||
=item $hp->interfaces()
|
||||
|
||||
=item $hp->m_model(), $hp->load_m_model()
|
||||
(B<moduleModel>)
|
||||
Uses $hp->i_description()
|
||||
|
||||
=item $hp->m_serial(), $hp->load_m_serial()
|
||||
(B<moduleSerialNumber>)
|
||||
=item $hp->i_duplex()
|
||||
|
||||
=item $hp->m_status(), $hp->load_m_status()
|
||||
(B<moduleStatus>)
|
||||
Maps $hp->mau_index() with $hp->mau_link(). Methods inherited from
|
||||
SNMP::Info::MAU.
|
||||
|
||||
=item $hp->m_name(), $hp->load_m_name()
|
||||
(B<moduleName>)
|
||||
=item $hp->i_duplex_admin()
|
||||
|
||||
=item $hp->m_ports(), $hp->load_m_ports()
|
||||
(B<moduleNumPorts>)
|
||||
Maps $hp->mau_index() with $hp->mau_auto(), $hp->mau_autostat(),
|
||||
$hp->typeadmin(), and $mau_autosent(). Methods inherited from
|
||||
SNMP::Info::MAU.
|
||||
|
||||
=item $hp->m_ports_status(), $hp->load_m_ports_status()
|
||||
Returns a list of space separated status strings for the ports.
|
||||
To see the status of port 4 :
|
||||
@ports_status = split(' ', $hp->m_ports_status() );
|
||||
$port4 = $ports_status[3];
|
||||
=item $hp->i_name()
|
||||
|
||||
(B<modulePortStatus>)
|
||||
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
|
||||
|
||||
=item $hp->m_ports_hwver(), $hp->load_m_ports_hwver()
|
||||
(B<moduleHwVersion>)
|
||||
=item $hp->i_type()
|
||||
|
||||
=item $hp->m_ports_fwver(), $hp->load_m_ports_fwver()
|
||||
(B<moduleFwVersion>)
|
||||
Crosses i_type() with $hp->e_descr() using $hp->e_port()
|
||||
|
||||
=item $hp->m_ports_swver(), $hp->load_m_ports_swver()
|
||||
(B<moduleSwVersion>)
|
||||
=item $hp->i_vlan()
|
||||
|
||||
=item $hp->m_ports_ip(), $hp->load_m_ports_ip()
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $hp->m_ports_sub1(), $hp->load_m_ports_sub1()
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $hp->m_ports_sub2(), $hp->load_m_ports_sub2()
|
||||
(B<moduleSubType2>)
|
||||
Looks in Q-BRIDGE-MIB -- see SNMP::Info::Bridge
|
||||
|
||||
and for older devices looks in HP-VLAN.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
=over
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=item $hp->p_name(), $hp->load_p_name()
|
||||
(B<portName>)
|
||||
=head2 Table Methods imported from SNMP::Info::Entity
|
||||
|
||||
=item $hp->p_type(), $hp->load_p_type()
|
||||
(B<portType>)
|
||||
See documentation in SNMP::Info::Entity for details.
|
||||
|
||||
=item $hp->p_status(), $hp->load_p_status()
|
||||
(B<portOperStatus>)
|
||||
=head2 Table Methods imported from SNMP::Info::MAU
|
||||
|
||||
=item $hp->p_status2(), $hp->load_p_status2()
|
||||
(B<portAdditionalStatus>)
|
||||
See documentation in SNMP::Info::MAU for details.
|
||||
|
||||
=item $hp->p_speed(), $hp->load_p_speed()
|
||||
(B<portAdminSpeed>)
|
||||
|
||||
=item $hp->p_duplex(), $hp->load_p_duplex()
|
||||
(B<portDuplex>)
|
||||
|
||||
=item $hp->p_port(), $hp->load_p_port()
|
||||
(B<portIfIndex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 VLAN Entry Table
|
||||
|
||||
ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->v_state(), $hp->load_v_state()
|
||||
(B<vtpVlanState>)
|
||||
|
||||
=item $hp->v_type(), $hp->load_v_type()
|
||||
(B<vtpVlanType>)
|
||||
|
||||
=item $hp->v_name(), $hp->load_v_name()
|
||||
(B<vtpVlanName>)
|
||||
|
||||
=item $hp->v_mtu(), $hp->load_v_mtu()
|
||||
(B<vtpVlanMtu>)
|
||||
|
||||
=back
|
||||
=cut
|
||||
|
||||
500
Info/Layer2/NAP222x.pm
Normal file
500
Info/Layer2/NAP222x.pm
Normal file
@@ -0,0 +1,500 @@
|
||||
# SNMP::Info::Layer2::NAP222x
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::Layer2::NAP222x;
|
||||
$VERSION = 0.9;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::SONMP;
|
||||
|
||||
@SNMP::Info::Layer2::NAP222x::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP Exporter/;
|
||||
@SNMP::Info::Layer2::NAP222x::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
'NORTEL-WLAN-AP-MIB' => 'ntWlanSwHardwareVer',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
'nt_hw_ver' => 'ntWlanSwHardwareVer',
|
||||
'nt_fw_ver' => 'ntWlanSwBootRomVer',
|
||||
'nt_sw_ver' => 'ntWlanSwOpCodeVer',
|
||||
'nt_cc' => 'ntWlanSwCountryCode',
|
||||
'tftp_action' => 'ntWlanTransferStart',
|
||||
'tftp_host' => 'ntWlanFileServer',
|
||||
'tftp_file' => 'ntWlanDestFile',
|
||||
'tftp_type' => 'ntWlanFileType',
|
||||
'tftp_result' => 'ntWlanFileTransferStatus',
|
||||
'tftp_xtype' => 'ntWlanTransferType',
|
||||
'tftp_src_file' => 'ntWlanSrcFile',
|
||||
'ftp_user' => 'ntWlanUserName',
|
||||
'ftp_pass' => 'ntWlanPassword',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
'i_name2' => 'ifName',
|
||||
'bp_index_2' => 'dot1dTpFdbPort',
|
||||
# From ntWlanPortTable
|
||||
'nt_prt_name' => 'ntWlanPortName',
|
||||
'nt_dpx_admin' => 'ntWlanPortCapabilities',
|
||||
'nt_auto' => 'ntWlanPortAutonegotiation',
|
||||
'nt_dpx' => 'ntWlanPortSpeedDpxStatus',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
);
|
||||
|
||||
sub os {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $nap222x = shift;
|
||||
my $ver = $nap222x->nt_sw_ver();
|
||||
return undef unless defined $ver;
|
||||
|
||||
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub os_bin {
|
||||
my $nap222x = shift;
|
||||
my $bin = $nap222x->nt_fw_ver();
|
||||
return undef unless defined $bin;
|
||||
|
||||
if ($bin =~ m/(\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $nap222x = shift;
|
||||
my $descr = $nap222x->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
return 'AP-2220' if ($descr =~ /2220/);
|
||||
return 'AP-2221' if ($descr =~ /2221/);
|
||||
return 'AP-2225' if ($descr =~ /2225/);
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub mac {
|
||||
my $nap222x = shift;
|
||||
my $i_mac = $nap222x->i_mac();
|
||||
|
||||
# Return Interface MAC
|
||||
foreach my $entry (keys %$i_mac){
|
||||
my $sn = $i_mac->{$entry};
|
||||
next unless $sn;
|
||||
return $sn;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $nap222x = shift;
|
||||
my $i_mac = $nap222x->i_mac();
|
||||
|
||||
# Return Interface MAC
|
||||
foreach my $entry (keys %$i_mac){
|
||||
my $sn = $i_mac->{$entry};
|
||||
next unless $sn;
|
||||
return $sn;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $nap222x = shift;
|
||||
my $descr = $nap222x->i_description();
|
||||
|
||||
my %i_ignore;
|
||||
foreach my $if (keys %$descr){
|
||||
my $type = $descr->{$if};
|
||||
# Skip virtual interfaces
|
||||
$i_ignore{$if}++ if $type =~ /(loopback|lo|other)/i;
|
||||
}
|
||||
return \%i_ignore;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $nap222x = shift;
|
||||
my $interfaces = $nap222x->i_index();
|
||||
my $description = $nap222x->i_description();
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $desc = $description->{$iid};
|
||||
next unless defined $desc;
|
||||
next if $desc =~ /lo/i;
|
||||
|
||||
$interfaces{$iid} = $desc;
|
||||
}
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $nap222x = shift;
|
||||
|
||||
my $mode = $nap222x->nt_dpx();
|
||||
my $port_name = $nap222x->nt_prt_name();
|
||||
my $interfaces = $nap222x->interfaces();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port = $interfaces->{$if};
|
||||
next unless $port =~ /dp/i;
|
||||
foreach my $idx (keys %$mode) {
|
||||
my $name = $port_name->{$idx}||'unknown';
|
||||
next unless $name eq $port;
|
||||
my $duplex = $mode->{$idx};
|
||||
|
||||
$duplex = 'other' unless defined $duplex;
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
|
||||
$i_duplex{$if}=$duplex;
|
||||
}
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $nap222x = shift;
|
||||
|
||||
my $dpx_admin = $nap222x->nt_dpx_admin();
|
||||
my $nt_auto = $nap222x->nt_auto();
|
||||
my $interfaces = $nap222x->interfaces();
|
||||
my $port_name = $nap222x->nt_prt_name();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port = $interfaces->{$if};
|
||||
next unless $port =~ /dp/i;
|
||||
foreach my $idx (keys %$dpx_admin) {
|
||||
my $name = $port_name->{$idx}||'unknown';
|
||||
next unless $name eq $port;
|
||||
my $duplex = $dpx_admin->{$idx};
|
||||
my $auto = $nt_auto->{$idx};
|
||||
|
||||
$duplex = 'other' unless defined $duplex;
|
||||
$duplex = 'half' if ($duplex =~ /half/i and $auto =~ /disabled/i);
|
||||
$duplex = 'full' if ($duplex =~ /full/i and $auto =~ /disabled/i);
|
||||
$duplex = 'auto' if $auto =~ /enabled/i;
|
||||
|
||||
$i_duplex_admin{$if}=$duplex;
|
||||
}
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $nap222x = shift;
|
||||
my $interfaces = $nap222x->interfaces();
|
||||
|
||||
my %i_name;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $desc = $interfaces->{$if};
|
||||
next unless defined $desc;
|
||||
|
||||
my $name = 'unknown';
|
||||
$name = 'Ethernet Interface' if $desc =~ /dp/i;
|
||||
$name = 'Wireless Interface B' if $desc =~ /ndc/i;
|
||||
$name = 'Wireless Interface A' if $desc =~ /ar/i;
|
||||
|
||||
$i_name{$if} = $name;
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
# dot1dBasePortTable does not exist and dot1dTpFdbPort does not map to ifIndex
|
||||
sub bp_index {
|
||||
my $nap222x = shift;
|
||||
my $interfaces = $nap222x->interfaces();
|
||||
|
||||
my %bp_index;
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $desc = $interfaces->{$iid};
|
||||
next unless defined $desc;
|
||||
next unless $desc =~ /(ndc|ar)/i;
|
||||
|
||||
my $port = 1;
|
||||
$port = 2 if $desc =~ /ndc/i;
|
||||
|
||||
$bp_index{$port} = $iid;
|
||||
}
|
||||
return \%bp_index;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::nap222x - SNMP Interface to Nortel 2220 Series Access Points
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $nap222x = 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 = $nap222x->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a Nortel
|
||||
2220 series wireless Access Points through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $nap222x = new SNMP::Info::Layer2::nap222x(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=item SNMP::Info::SONMP
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item NORTEL-WLAN-AP-MIB
|
||||
|
||||
=item Inherited classes
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::SONMP for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status.
|
||||
|
||||
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
|
||||
Select by Product Families, Wireless LAN, WLAN - Access Point 2220, Software.
|
||||
Filter on mibs and download the latest version's archive.
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $nap222x->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $nap222x->model()
|
||||
|
||||
Returns the model extracted from B<sysDescr>.
|
||||
|
||||
=item $nap222x->os()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $nap222x->os_ver()
|
||||
|
||||
Returns the software version extracted from B<ntWlanSwOpCodeVer>.
|
||||
|
||||
=item $nap222x->os_bin()
|
||||
|
||||
Returns the firmware version extracted from B<ntWlanSwBootRomVer>.
|
||||
|
||||
=item $nap222x->mac()
|
||||
|
||||
Returns the MAC address of the first Ethernet Interface.
|
||||
|
||||
=item $nap222x->serial()
|
||||
|
||||
Returns the MAC address of the first Ethernet Interface.
|
||||
|
||||
=item $nap222x->nt_hw_ver()
|
||||
|
||||
Returns the hardware version.
|
||||
|
||||
B<ntWlanSwHardwareVer>
|
||||
|
||||
=item $nap222x->nt_cc()
|
||||
|
||||
Returns the country code of the AP.
|
||||
|
||||
B<ntWlanSwHardwareVer>
|
||||
|
||||
=item $nap222x->tftp_action()
|
||||
|
||||
B<ntWlanTransferStart>
|
||||
|
||||
=item $nap222x->tftp_host()
|
||||
|
||||
B<ntWlanFileServer>
|
||||
|
||||
=item $nap222x->tftp_file()
|
||||
|
||||
B<ntWlanDestFile>
|
||||
|
||||
=item $nap222x->tftp_type()
|
||||
|
||||
B<ntWlanFileType>
|
||||
|
||||
=item $nap222x->tftp_result()
|
||||
|
||||
B<ntWlanFileTransferStatus>
|
||||
|
||||
=item $nap222x->tftp_xtype()
|
||||
|
||||
B<ntWlanTransferType>
|
||||
|
||||
=item $nap222x->tftp_src_file()
|
||||
|
||||
B<ntWlanSrcFile>
|
||||
|
||||
=item $nap222x->ftp_user()
|
||||
|
||||
B<ntWlanUserName>
|
||||
|
||||
=item $nap222x->ftp_pass()
|
||||
|
||||
B<ntWlanPassword>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP 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 $nap222x->interfaces()
|
||||
|
||||
Returns reference to map of IIDs to physical ports.
|
||||
|
||||
=item $nap222x->i_ignore()
|
||||
|
||||
Returns reference to hash of IIDs to ignore.
|
||||
|
||||
=item $nap222x->i_duplex()
|
||||
|
||||
Returns reference to hash. Maps port operational duplexes to IIDs.
|
||||
|
||||
B<ntWlanPortSpeedDpxStatus>
|
||||
|
||||
=item $nap222x->i_duplex_admin()
|
||||
|
||||
Returns reference to hash. Maps port admin duplexes to IIDs.
|
||||
|
||||
B<ntWlanPortCapabilities>
|
||||
|
||||
=item $nap222x->i_name()
|
||||
|
||||
Returns a human name based upon port description.
|
||||
|
||||
=item $nap222x->bp_index()
|
||||
|
||||
Returns a mapping between ifIndex and the Bridge Table. This does not exist in
|
||||
the MIB and bridge port index is not the same as ifIndex so it is created.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=cut
|
||||
278
Info/Layer2/Orinoco.pm
Normal file
278
Info/Layer2/Orinoco.pm
Normal file
@@ -0,0 +1,278 @@
|
||||
# SNMP::Info::Layer2::Orinoco
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::Layer2::Orinoco;
|
||||
$VERSION = 0.9;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
|
||||
@SNMP::Info::Layer2::Orinoco::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
|
||||
@SNMP::Info::Layer2::Orinoco::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
);
|
||||
|
||||
sub os {
|
||||
return 'orinoco';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $orinoco = shift;
|
||||
my $descr = $orinoco->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
if ($descr =~ m/V(\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
if ($descr =~ m/v(\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub os_bin {
|
||||
my $orinoco = shift;
|
||||
my $descr = $orinoco->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
if ($descr =~ m/V(\d+\.\d+)$/){
|
||||
return $1;
|
||||
}
|
||||
if ($descr =~ m/v(\d+\.\d+\.\d+)$/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'Proxim';
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $orinoco = shift;
|
||||
my $descr = $orinoco->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
return 'AP-1000' if ($descr =~ /AP-1000/);
|
||||
return 'AP-2000' if ($descr =~ /AP-2000/);
|
||||
return 'WavePOINT-II' if ($descr =~ /WavePOINT-II/);
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $orinoco = shift;
|
||||
my $descr = $orinoco->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
$descr = $1 if $descr =~ /SN-(\S+)/;
|
||||
return $descr;
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $orinoco = shift;
|
||||
my $descr = $orinoco->i_description();
|
||||
|
||||
my %i_ignore;
|
||||
foreach my $if (keys %$descr){
|
||||
my $type = $descr->{$if};
|
||||
# Skip virtual interfaces
|
||||
$i_ignore{$if}++ if $type =~ /(lo|empty|PCMCIA)/i;
|
||||
}
|
||||
return \%i_ignore;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $orinoco = shift;
|
||||
my $interfaces = $orinoco->i_index();
|
||||
my $descriptions = $orinoco->i_description();
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $desc = $descriptions->{$iid};
|
||||
next unless defined $desc;
|
||||
next if $desc =~ /(lo|empty|PCMCIA)/i;
|
||||
|
||||
$desc = 'AMD' if $desc =~ /AMD/;
|
||||
|
||||
$interfaces{$iid} = $desc;
|
||||
}
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::Orinoco - SNMP Interface to Orinoco Series Access Points
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $orinoco = 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 = $orinoco->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a Orinoco
|
||||
Access Point through SNMP.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after
|
||||
determining a more specific class using the method above.
|
||||
|
||||
my $orinoco = new SNMP::Info::Layer2::Orinoco(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Inherited classes
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $orinoco->vendor()
|
||||
|
||||
Returns 'Proxim' :)
|
||||
|
||||
=item $orinoco->model()
|
||||
|
||||
Returns the model extracted from B<sysDescr>.
|
||||
|
||||
=item $orinoco->os()
|
||||
|
||||
Returns 'Orinoco'
|
||||
|
||||
=item $orinoco->os_ver()
|
||||
|
||||
Returns the software version extracted from B<sysDescr>.
|
||||
|
||||
=item $orinoco->os_bin()
|
||||
|
||||
Returns the firmware version extracted from B<sysDescr>.
|
||||
|
||||
=item $orinoco->serial()
|
||||
|
||||
Returns the serial number extracted from B<sysDescr>.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge 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 $orinoco->interfaces()
|
||||
|
||||
Returns reference to map of IIDs to physical ports.
|
||||
|
||||
=item $orinoco->i_ignore()
|
||||
|
||||
Returns reference to hash of IIDs to ignore.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=cut
|
||||
224
Info/Layer2/ZyXEL_DSLAM.pm
Normal file
224
Info/Layer2/ZyXEL_DSLAM.pm
Normal file
@@ -0,0 +1,224 @@
|
||||
# SNMP::Info::Layer2::ZyXEL_DSLAM
|
||||
# Dmitry Sergienko <dmitry@trifle.net>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker <max@warped.org>
|
||||
# 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 Netdisco 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::Layer2::ZyXEL_DSLAM;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
|
||||
@SNMP::Info::Layer2::ZyXEL_DSLAM::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
@SNMP::Info::Layer2::ZyXEL_DSLAM::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
# Set for No CDP
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer2::GLOBALS
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
'ip_adresses' => 'ipAdEntAddr',
|
||||
'i_name' => 'ifDescr',
|
||||
'i_description' => 'adslLineConfProfile',
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
'ADSL-LINE-MIB' => 'adslLineConfProfile'
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE
|
||||
);
|
||||
|
||||
|
||||
sub layers {
|
||||
my $zyxel = shift;
|
||||
my $layers = $zyxel->layers();
|
||||
return $layers if defined $layers;
|
||||
|
||||
# If these don't claim to have any layers, so we'll give them 1+2
|
||||
return '00000011';
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'zyxel';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'zyxel';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $zyxel = shift;
|
||||
my $descr = $zyxel->description();
|
||||
|
||||
if ($descr =~ m/version (\S+) /){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $zyxel = shift;
|
||||
|
||||
my $desc = $zyxel->description();
|
||||
|
||||
if ($desc =~ /8-port ADSL Module\(Annex A\)/){
|
||||
return "AAM1008-61";
|
||||
} elsif ($desc =~ /8-port ADSL Module\(Annex B\)/){
|
||||
return "AAM1008-63";
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub ip{
|
||||
my $zyxel = shift;
|
||||
my $ip_hash = $zyxel->ip_addresses();
|
||||
my $ip;
|
||||
|
||||
foreach $ip (keys %{$ip_hash}) {
|
||||
my $found_ip = $ip if (defined $ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::ZyXEL_DSLAM - SNMP Interface to ZyXEL DSLAM
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Dmitry Sergienko (C<dmitry@trifle.net>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $zyxel = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myhub',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
my $class = $l2->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides abstraction to the configuration information obtainable from a
|
||||
ZyXEL device through SNMP. See inherited classes' documentation for
|
||||
inherited methods.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer2
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item ADSL-LINE-MIB
|
||||
|
||||
This MIB assumedly obtainable through ZyXEL or possibly included with your device.
|
||||
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs listed in SNMP::Info::Layer2 and their inherited classes.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $zyxel->vendor()
|
||||
|
||||
Returns 'ZyXEL' :)
|
||||
|
||||
=item $zyxel->os()
|
||||
|
||||
Returns 'ZyXEL'
|
||||
|
||||
=item $zyxel->os_ver()
|
||||
|
||||
Culls Version from description()
|
||||
|
||||
=item $zyxel->ip()
|
||||
|
||||
Returns IP Address of DSLAM.
|
||||
|
||||
(B<ipAdEntAddr>)
|
||||
|
||||
=item $zyxel->model()
|
||||
|
||||
Trys to cull out model out of the description field.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $zyxel->i_name()
|
||||
|
||||
Returns reference to map of IIDs to port name (B<ifDescr>).
|
||||
|
||||
=item $zyxel->i_description()
|
||||
|
||||
Returns reference to map of IIDs to human-set port description (profile name).
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer2
|
||||
|
||||
See documentation in SNMP::Info::Layer2 for details.
|
||||
|
||||
=cut
|
||||
219
Info/Layer3.pm
219
Info/Layer3.pm
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer3 - SNMP Interface to Layer3 devices
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker -- All changes from Version 0.7 on
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -36,12 +38,14 @@ use strict;
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::CDP;
|
||||
use SNMP::Info::CiscoStats;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::EtherLike;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
|
||||
|
||||
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::CDP SNMP::Info::Bridge SNMP::Info::EtherLike Exporter/;
|
||||
@SNMP::Info::Layer3::ISA = qw/SNMP::Info SNMP::Info::CDP SNMP::Info::Bridge
|
||||
SNMP::Info::EtherLike SNMP::Info::CiscoStats Exporter/;
|
||||
@SNMP::Info::Layer3::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
@@ -50,11 +54,11 @@ $SNMP::debugging=$DEBUG;
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = ( %SNMP::Info::MIBS,
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::CDP::MIBS,
|
||||
%SNMP::Info::CiscoStats::MIBS,
|
||||
%SNMP::Info::EtherLike::MIBS,
|
||||
'ENTITY-MIB' => 'entPhysicalName',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
'CISCO-PRODUCTS-MIB' => 'sysName',
|
||||
'OSPF-MIB' => 'ospfRouterId',
|
||||
);
|
||||
@@ -63,16 +67,18 @@ $INIT = 0;
|
||||
# Inherit the super class ones
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::CDP::GLOBALS,
|
||||
%SNMP::Info::CiscoStats::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::EtherLike::GLOBALS,
|
||||
'mac' => 'ifPhysAddress.1',
|
||||
'chassis' => 'entPhysicalDescr.1',
|
||||
'serial1' => '.1.3.6.1.4.1.9.3.6.3.0', # OLD-CISCO-CHASSIS-MIB::chassisId.0
|
||||
'router_ip' => 'ospfRouterId.0',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::CDP::FUNCS,
|
||||
%SNMP::Info::CiscoStats::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::EtherLike::FUNCS,
|
||||
# IFMIB
|
||||
@@ -81,13 +87,16 @@ $INIT = 0;
|
||||
'at_index' => 'atIfIndex',
|
||||
'at_paddr' => 'atPhysAddress',
|
||||
'at_netaddr' => 'atNetAddress',
|
||||
'ospf_ip' => 'ospfHostIpAddress'
|
||||
'ospf_ip' => 'ospfHostIpAddress',
|
||||
'ent_serial' => 'entPhysicalSerialNum',
|
||||
'ent_chassis'=> 'entPhysicalDescr',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::CDP::MUNGE,
|
||||
%SNMP::Info::CiscoStats::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::EtherLike::MUNGE,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
@@ -106,12 +115,13 @@ sub root_ip {
|
||||
if (defined $ospf_ip and scalar(keys %$ospf_ip)){
|
||||
foreach my $key (keys %$ospf_ip){
|
||||
my $ip = $ospf_ip->{$key};
|
||||
next if $ip eq '0.0.0.0';
|
||||
print " SNMP::Layer3::root_ip() using $ip\n" if $DEBUG;
|
||||
return $ip;
|
||||
}
|
||||
}
|
||||
|
||||
return $router_ip if defined $router_ip;
|
||||
return $router_ip if (defined $router_ip and $router_ip ne '0.0.0.0');
|
||||
return undef;
|
||||
}
|
||||
|
||||
@@ -133,10 +143,20 @@ sub i_ignore {
|
||||
sub serial {
|
||||
my $l3 = shift;
|
||||
|
||||
my $chassis = $l3->chassis();
|
||||
my $serial1 = $l3->serial1();
|
||||
my $ent_chassis = $l3->ent_chassis() || {};
|
||||
my $ent_serial = $l3->ent_serial() || {};
|
||||
|
||||
my $serial2 = $ent_serial->{1} || undef;
|
||||
my $chassis = $ent_chassis->{1} || undef;
|
||||
|
||||
# precedence
|
||||
# serial2,chassis parse,serial1
|
||||
return $serial2 if (defined $serial2 and $serial2 !~ /^\s*$/);
|
||||
return $1 if (defined $chassis and $chassis =~ /serial#?:\s*([a-z0-9]+)/i);
|
||||
return $serial1 if (defined $serial1 and $serial1 !~ /^\s*$/);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
# $l3->model() - the sysObjectID returns an IID to an entry in
|
||||
@@ -144,8 +164,16 @@ sub serial {
|
||||
sub model {
|
||||
my $l3 = shift;
|
||||
my $id = $l3->id();
|
||||
|
||||
unless (defined $id){
|
||||
print " SNMP::Info::Layer3::model() - Device does not support sysObjectID\n" if $DEBUG;
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $model = &SNMP::translateObj($id);
|
||||
|
||||
return $id unless defined $model;
|
||||
|
||||
$model =~ s/^cisco//i;
|
||||
$model =~ s/^catalyst//;
|
||||
$model =~ s/^cat//;
|
||||
@@ -222,31 +250,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3 - Perl5 Interface to network devices using Layer3
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provides generic methods for accessing SNMP data for Layer 3 network devices.
|
||||
Includes support for Layer2+3 devices. See super classes for other inherited
|
||||
methods.
|
||||
|
||||
Inherits from:
|
||||
|
||||
SNMP::Info
|
||||
SNMP::Info::Bridge
|
||||
SNMP::Info::CDP
|
||||
SNMP::Info::EtherLike
|
||||
|
||||
Required MIBs:
|
||||
|
||||
ENTITY-MIB - For model identification
|
||||
CISCO-PRODUCTS-MIB - For model identification
|
||||
HP-ICF-OID - For model identification
|
||||
MIBS listed in SNMP::Info::CDP, SNMP::Info::Bridge, and SNMP::Info::Etherlike
|
||||
|
||||
Cisco MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
HP MIBs can be found at http://www.hp.com/rnd/software
|
||||
SNMP::Info::Layer3 - Perl5 Interface to network devices serving Layer3 or Layers 2 & 3
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -254,47 +258,83 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $l3 = new SNMP::Info::Layer3(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $l3 = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $l3->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
# Let's get some basic Port information
|
||||
my $interfaces = $l3->interfaces();
|
||||
my $i_up = $l3->i_up();
|
||||
my $i_speed = $l3->i_speed();
|
||||
foreach my $iid (keys %$interfaces) {
|
||||
my $port = $interfaces->{$iid};
|
||||
my $up = $i_up->{$iid};
|
||||
my $speed = $i_speed->{$iid}
|
||||
print "Port $port is $up. Port runs at $speed.\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class is usually used as a superclass for more specific device classes listed under
|
||||
SNMP::Info::Layer3::* Please read all docs under SNMP::Info first.
|
||||
|
||||
Provides generic methods for accessing SNMP data for Layer 3 network devices.
|
||||
Includes support for Layer2+3 devices.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $l3 = new SNMP::Info::Layer3(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer3()
|
||||
=item SNMP::Info
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
my $l3 = new SNMP::Info::Layer3(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $l3;
|
||||
=item SNMP::Info::CDP
|
||||
|
||||
=item $l3->session()
|
||||
=item SNMP::Info::CiscoStats
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $l3->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$l3->session($newsession);
|
||||
=item SNMP::Info::EtherLike
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item $l3->mac()
|
||||
=item CISCO-PRODUCTS-MIB
|
||||
|
||||
Returns root port mac address
|
||||
=item ENTITY-MIB
|
||||
|
||||
(B<ifPhysAddress.1>)
|
||||
=item OSPF-MIB
|
||||
|
||||
=item Inherited Classes
|
||||
|
||||
MIBs required by the inherited classes listed above.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $l3->chassis()
|
||||
|
||||
@@ -302,9 +342,21 @@ Returns Chassis type (model).
|
||||
|
||||
(B<entPhysicalDescr.1>)
|
||||
|
||||
=item $l3->serial()
|
||||
=item $l3->mac()
|
||||
|
||||
Trys to cull a serial number from $l3->chassis()
|
||||
Returns root port mac address
|
||||
|
||||
(B<ifPhysAddress.1>)
|
||||
|
||||
=item $l3->router_ip()
|
||||
|
||||
(B<ospfRouterId.0>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $l3->model()
|
||||
|
||||
@@ -312,14 +364,41 @@ Trys to reference $l3->id() to one of the product MIBs listed above
|
||||
|
||||
Removes 'cisco' from cisco devices for readability.
|
||||
|
||||
=item $l3->serial()
|
||||
|
||||
Trys to cull a serial number from $l3->chassis()
|
||||
|
||||
=item $l3->vendor()
|
||||
|
||||
Trys to cull a Vendor name from B<sysDescr>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::CDP
|
||||
|
||||
See documentation in SNMP::Info::CDP for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::CiscoStats
|
||||
|
||||
See documentation in SNMP::Info::CiscoStats for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::EtherLike
|
||||
|
||||
See documentation in SNMP::Info::EtherLike 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
|
||||
@@ -377,4 +456,24 @@ Returns reference to hash of Arp Cache Entries to IP Address
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CDP
|
||||
|
||||
See documentation in SNMP::Info::CDP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoStats
|
||||
|
||||
See documentation in SNMP::Info::CiscoStats for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::EtherLike
|
||||
|
||||
See documentation in SNMP::Info::EtherLike for details.
|
||||
|
||||
=cut
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer3::Aironet
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::Aironet;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -82,6 +84,26 @@ $INIT = 0;
|
||||
'fw_mac2' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
sub os {
|
||||
return 'aironet';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $aironet = shift;
|
||||
my $descr = $aironet->description();
|
||||
|
||||
# CAP340 11.21, AP4800-E 11.21
|
||||
if ($descr =~ /AP\d{3,4}(-\D+)?\s+(\d{2}\.\d{2})/){
|
||||
return $2;
|
||||
}
|
||||
|
||||
if ($descr =~ /Series\s*AP\s+(\d{2}\.\d{2})/){
|
||||
return $1;
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Override wireless port with static info
|
||||
sub bp_index {
|
||||
my $aironet = shift;
|
||||
@@ -110,11 +132,14 @@ sub fw_mac {
|
||||
# remove port 0 forwarding table entries, only port 0 static entries
|
||||
foreach my $fw (keys %$fw_mac){
|
||||
my $port = $fw_port->{$fw};
|
||||
next unless defined $port;
|
||||
delete $fw_mac->{$fw} if $port == 0;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -128,7 +153,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;
|
||||
@@ -189,11 +216,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Inherits all methods from SNMP::Info::Layer3
|
||||
SNMP::Info::Layer3::Aironet - Perl5 Interface to Cisco Aironet Wireless Devices running Aironet software, not IOS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -201,48 +224,70 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $aironet = new SNMP::Info::Layer3::Aironet(DestHost => 'myswitch',
|
||||
Community => 'public');
|
||||
my $mac = $aironet->mac();
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $aironet = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $aironet->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info subclass to provide access to SNMP data for an Aironet device running Aironet software,
|
||||
not cisco IOS.
|
||||
|
||||
Note there are two classes for Aironet devices :
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer3::Aironet()
|
||||
=item SNMP::Info::Layer3::Aironet
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
This class is for devices running Aironet software (older)
|
||||
|
||||
my $aironet = new SNMP::Info::Layer3::Aironet(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $aironet;
|
||||
=item SNMP::Info::Layer2::Aironet
|
||||
|
||||
=item $aironet->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $aironet->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$aironet->session($newsession);
|
||||
This class is for devices running Cisco IOS software (newer)
|
||||
|
||||
=back
|
||||
|
||||
=head1 Globals
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $aironet = new SNMP::Info::Layer3::Aironet(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->mac()
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
Gives the MAC Address of the wireless side
|
||||
=back
|
||||
|
||||
B<dot11StationID.2>
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item AWCVX-MIB
|
||||
|
||||
=item IEEE802dot11-MIB
|
||||
|
||||
=back
|
||||
|
||||
These MIBs are now included in the v2.tar.gz archive available from ftp.cisco.com. Make sure you
|
||||
have a current version.
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->awc_duplex()
|
||||
|
||||
@@ -250,47 +295,34 @@ Gives the admin duplex setting for the Ethernet Port.
|
||||
|
||||
B<awcEtherDuplex.0>
|
||||
|
||||
=item $aironet->mac()
|
||||
|
||||
Gives the MAC Address of the wireless side
|
||||
|
||||
B<dot11StationID.2>
|
||||
|
||||
=item $aironet->os()
|
||||
|
||||
'aironet'
|
||||
|
||||
=item $aironet->os_ver
|
||||
|
||||
Tries to cull the version from the description field.
|
||||
|
||||
=item $aironet->vendor()
|
||||
|
||||
Returns 'cisco'.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Layer3
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Aironet specific items
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->awc_default_mac()
|
||||
|
||||
Gives the default MAC address of each interface.
|
||||
|
||||
B<awcIfDefaultPhyAddress>
|
||||
|
||||
=item $aironet->awc_mac()
|
||||
|
||||
Gives the actual MAC address of each interface.
|
||||
|
||||
B<awcIfPhyAddress>
|
||||
|
||||
=item $aironet->awc_ip()
|
||||
|
||||
Gives the IP Address assigned to each interface.
|
||||
|
||||
B<awcIfIpAddress>
|
||||
|
||||
=item $aironet->awc_netmask()
|
||||
|
||||
Gives the NetMask for each interface.
|
||||
|
||||
B<awcIfIpNetMask>
|
||||
|
||||
=item $aironet->awc_msdu()
|
||||
|
||||
B<awcIfMSDUMaxLength>
|
||||
|
||||
=back
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
@@ -325,4 +357,42 @@ Ignores ports that are of type ``rptr'' and ``lo''.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Aironet specific items
|
||||
|
||||
=over
|
||||
|
||||
=item $aironet->awc_default_mac()
|
||||
|
||||
Gives the default MAC address of each interface.
|
||||
|
||||
B<awcIfDefaultPhyAddress>
|
||||
|
||||
=item $aironet->awc_mac()
|
||||
|
||||
Gives the actual MAC address of each interface.
|
||||
|
||||
B<awcIfPhyAddress>
|
||||
|
||||
=item $aironet->awc_ip()
|
||||
|
||||
Gives the IP Address assigned to each interface.
|
||||
|
||||
B<awcIfIpAddress>
|
||||
|
||||
=item $aironet->awc_netmask()
|
||||
|
||||
Gives the NetMask for each interface.
|
||||
|
||||
B<awcIfIpNetMask>
|
||||
|
||||
=item $aironet->awc_msdu()
|
||||
|
||||
B<awcIfMSDUMaxLength>
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Layer3
|
||||
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
=cut
|
||||
|
||||
470
Info/Layer3/AlteonAD.pm
Normal file
470
Info/Layer3/AlteonAD.pm
Normal file
@@ -0,0 +1,470 @@
|
||||
# SNMP::Info::Layer3::AlteonAD
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 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 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::Layer3::AlteonAD;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE /;
|
||||
|
||||
@SNMP::Info::Layer3::AlteonAD::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
|
||||
@SNMP::Info::Layer3::AlteonAD::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
'ALTEON-TIGON-SWITCH-MIB' => 'agSoftwareVersion',
|
||||
'ALTEON-TS-PHYSICAL-MIB' => 'agPortTableMaxEnt',
|
||||
'ALTEON-TS-NETWORK-MIB' => 'agPortTableMaxEnt',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
'sw_ver' => 'agSoftwareVersion',
|
||||
'tftp_action' => 'agTftpAction',
|
||||
'tftp_host' => 'agTftpServer',
|
||||
'tftp_file' => 'agTftpCfgFileName',
|
||||
'tftp_result' => 'agTftpLastActionStatus',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
'bp_index_2' => 'dot1dBasePortIfIndex',
|
||||
'i_name2' => 'ifName',
|
||||
# From RFC1213-MIB
|
||||
'at_index' => 'ipNetToMediaIfIndex',
|
||||
'at_paddr' => 'ipNetToMediaPhysAddress',
|
||||
'at_netaddr' => 'ipNetToMediaNetAddress',
|
||||
# From agPortCurCfgTable
|
||||
'ag_p_cfg_idx' => 'agPortCurCfgIndx',
|
||||
'ag_p_cfg_pref' => 'agPortCurCfgPrefLink',
|
||||
'ag_p_cfg_pvid' => 'agPortCurCfgPVID',
|
||||
'ag_p_cfg_fe_auto' => 'agPortCurCfgFastEthAutoNeg',
|
||||
'ag_p_cfg_fe_mode' => 'agPortCurCfgFastEthMode',
|
||||
'ag_p_cfg_ge_auto' => 'agPortCurCfgGigEthAutoNeg',
|
||||
'ag_p_cfg_name' => 'agPortCurCfgPortName',
|
||||
# From portInfoTable
|
||||
'p_info_idx' => 'portInfoIndx',
|
||||
'p_info_mode' => 'portInfoMode',
|
||||
# From portInfoTable
|
||||
'ip_cfg_vlan' => 'ipCurCfgIntfVlan',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
sub model {
|
||||
my $alteon = shift;
|
||||
my $desc = $alteon->description();
|
||||
return undef unless defined $desc;
|
||||
|
||||
return 'AD2' if ($desc =~ /AD2/);
|
||||
return 'AD3' if ($desc =~ /AD3/);
|
||||
return 'AD4' if ($desc =~ /AD4/);
|
||||
return '180' if ($desc =~ /180/);
|
||||
return '183' if ($desc =~ /183/);
|
||||
return '184' if ($desc =~ /184/);
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'webos';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $alteon = shift;
|
||||
my $version = $alteon->sw_ver();
|
||||
return undef unless defined $version;
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $alteon = shift;
|
||||
my $interfaces = $alteon->i_index();
|
||||
my $descriptions = $alteon->i_description();
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $desc = $descriptions->{$iid};
|
||||
next unless defined $desc;
|
||||
|
||||
if ($desc =~ /(^net\d+)/) {
|
||||
$desc = $1;
|
||||
}
|
||||
elsif (($iid > 256) and ($iid < 266)) {
|
||||
$desc = ($iid % 256);
|
||||
}
|
||||
$interfaces{$iid} = $desc;
|
||||
}
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $alteon = shift;
|
||||
|
||||
my $p_mode = $alteon->p_info_mode();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$p_mode){
|
||||
my $duplex = $p_mode->{$if};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
|
||||
my $idx = $if + 256;
|
||||
|
||||
$i_duplex{$idx}=$duplex;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $alteon = shift;
|
||||
|
||||
my $ag_pref = $alteon->ag_p_cfg_pref();
|
||||
my $ag_fe_auto = $alteon->ag_p_cfg_fe_auto();
|
||||
my $ag_fe_mode = $alteon->ag_p_cfg_fe_mode();
|
||||
my $ag_ge_auto = $alteon->ag_p_cfg_ge_auto();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$ag_pref){
|
||||
my $pref = $ag_pref->{$if};
|
||||
next unless defined $pref;
|
||||
|
||||
my $string = 'other';
|
||||
if ($pref =~ /gigabit/i) {
|
||||
my $ge_auto = $ag_ge_auto->{$if};
|
||||
$string = 'full' if ($ge_auto =~ /off/i);
|
||||
$string = 'auto' if ($ge_auto =~ /on/i);
|
||||
}
|
||||
elsif ($pref =~ /fast/i) {
|
||||
my $fe_auto = $ag_fe_auto->{$if};
|
||||
my $fe_mode = $ag_fe_mode->{$if};
|
||||
$string = 'half' if ($fe_mode =~ /half/i and $fe_auto =~ /off/i);
|
||||
$string = 'full' if ($fe_mode =~ /full/i and $fe_auto =~ /off/i);
|
||||
$string = 'auto' if $fe_auto =~ /on/i;
|
||||
}
|
||||
my $idx = $if + 256;
|
||||
|
||||
$i_duplex_admin{$idx}=$string;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $alteon = shift;
|
||||
|
||||
my $ag_vlans = $alteon->ag_p_cfg_pvid();
|
||||
my $ip_vlans = $alteon->ip_cfg_vlan();
|
||||
|
||||
|
||||
my %i_vlan;
|
||||
foreach my $if (keys %$ip_vlans){
|
||||
my $ip_vlanid = $ip_vlans->{$if};
|
||||
next unless defined $ip_vlanid;
|
||||
|
||||
$i_vlan{$if}=$ip_vlanid;
|
||||
}
|
||||
foreach my $if (keys %$ag_vlans){
|
||||
my $ag_vlanid = $ag_vlans->{$if};
|
||||
next unless defined $ag_vlanid;
|
||||
|
||||
my $idx = $if + 256;
|
||||
$i_vlan{$idx}=$ag_vlanid;
|
||||
}
|
||||
return \%i_vlan;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $alteon = shift;
|
||||
my $p_name = $alteon->ag_p_cfg_name();
|
||||
|
||||
my %i_name;
|
||||
foreach my $iid (keys %$p_name){
|
||||
my $name = $p_name->{$iid};
|
||||
next unless defined $name;
|
||||
my $idx = $iid + 256;
|
||||
$i_name{$idx} = $name;
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
# Bridge MIB does not map Bridge Port to ifIndex correctly
|
||||
sub bp_index {
|
||||
my $alteon = shift;
|
||||
my $b_index = $alteon->bp_index_2();
|
||||
|
||||
my %bp_index;
|
||||
foreach my $iid (keys %$b_index){
|
||||
my $port = $b_index->{$iid};
|
||||
next unless defined $port;
|
||||
$port = $port + 256;
|
||||
|
||||
$bp_index{$iid} = $port;
|
||||
}
|
||||
return \%bp_index;
|
||||
}
|
||||
|
||||
sub root_ip {
|
||||
my $alteon = shift;
|
||||
my $ip_table = $alteon->ip_table();
|
||||
|
||||
# Return First IP Address
|
||||
foreach my $entry (keys %$ip_table){
|
||||
my $router_ip = $ip_table->{$entry};
|
||||
print " SNMP::Layer3::AlteonAD::root_ip() using $router_ip\n" if $DEBUG;
|
||||
next unless $router_ip;
|
||||
return $router_ip if ($router_ip ne '0.0.0.0');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::AlteonAD - Perl5 Interface to Nortel Networks' Alteon Ace
|
||||
Director Series Layer 2-7 Switches.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $alteon = 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 = $alteon->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Layer 2-7 load balancing switches running Nortel Networks'
|
||||
Alteon Web OS Traffic Control Software.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after
|
||||
determining a more specific class using the method above.
|
||||
|
||||
my $alteon = new SNMP::Info::Layer3::AlteonAD(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item ALTEON-TIGON-SWITCH-MIB
|
||||
|
||||
=item ALTEON-TS-PHYSICAL-MIB
|
||||
|
||||
=item ALTEON-TS-NETWORK-MIB
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status. Go to http://www.nortelnetworks.com Techninal Support,
|
||||
Browse Technical Support, Select by Product Families, Alteon,
|
||||
Alteon Web OS Traffic Control Software, Software. Filter on mibs and download
|
||||
the latest version's archive.
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $alteon->model()
|
||||
|
||||
Returns the model extracted from B<sysDescr>
|
||||
|
||||
=item $alteon->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $alteon->os()
|
||||
|
||||
Returns 'WebOS'
|
||||
|
||||
=item $alteon->os_ver()
|
||||
|
||||
Returns the software version reported by B<agSoftwareVersion>
|
||||
|
||||
=item $alteon->root_ip()
|
||||
|
||||
Returns the primary IP used to communicate with the device. Currently returns
|
||||
the first interfaces IP.
|
||||
|
||||
=item $alteon->tftp_action()
|
||||
|
||||
(B<agTftpAction>)
|
||||
|
||||
=item $alteon->tftp_host()
|
||||
|
||||
(B<agTftpServer>)
|
||||
|
||||
=item $alteon->tftp_file()
|
||||
|
||||
(B<agTftpCfgFileName>)
|
||||
|
||||
=item $alteon->tftp_result()
|
||||
|
||||
(B<agTftpLastActionStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge 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 $alteon->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical port.
|
||||
|
||||
Utilizes description for network interfaces. Ports are determined by
|
||||
formula (ifIndex mod 256).
|
||||
|
||||
=item $alteon->i_duplex()
|
||||
|
||||
Returns reference to hash. Maps port operational duplexes to IIDs.
|
||||
|
||||
=item $alteon->i_duplex_admin()
|
||||
|
||||
Returns reference to hash. Maps port admin duplexes to IIDs.
|
||||
|
||||
=item $alteon->i_vlan()
|
||||
|
||||
Returns reference to hash. Maps port VLAN ID to IIDs.
|
||||
|
||||
=item $alteon->i_name()
|
||||
|
||||
Maps (B<agPortCurCfgPortName>) to port and returns the human set port name if exists.
|
||||
|
||||
=item $alteon->bp_index()
|
||||
|
||||
Returns a mapping between ifIndex and the Bridge Table.
|
||||
|
||||
=back
|
||||
|
||||
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $alteon->at_index()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
|
||||
=item $alteon->at_paddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
|
||||
=item $alteon->at_netaddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=cut
|
||||
550
Info/Layer3/BayRS.pm
Normal file
550
Info/Layer3/BayRS.pm
Normal file
@@ -0,0 +1,550 @@
|
||||
# SNMP::Info::Layer3::BayRS
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 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 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::Layer3::BayRS;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE %MODEL_MAP/;
|
||||
|
||||
@SNMP::Info::Layer3::BayRS::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
|
||||
@SNMP::Info::Layer3::BayRS::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
'Wellfleet-HARDWARE-MIB' => 'wfHwBpIdOpt',
|
||||
'Wellfleet-OSPF-MIB' => 'wfOspfRouterId',
|
||||
'Wellfleet-DOT1QTAG-CONFIG-MIB' => 'wfDot1qTagCfgVlanName',
|
||||
'Wellfleet-CSMACD-MIB' => 'wfCSMACDCct',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
'bp_id' => 'wfHwBpIdOpt',
|
||||
'bp_serial' => 'wfHwBpSerialNumber',
|
||||
'ospf_rtr_id' => 'wfOspfRouterId',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
'i_name2' => 'ifName',
|
||||
# From RFC1213-MIB
|
||||
'at_index' => 'ipNetToMediaIfIndex',
|
||||
'at_paddr' => 'ipNetToMediaPhysAddress',
|
||||
'at_netaddr' => 'ipNetToMediaNetAddress',
|
||||
# From Wellfleet-CSMACD-MIB::wfCSMACDTable
|
||||
'wf_csmacd_cct' => 'wfCSMACDCct',
|
||||
'wf_csmacd_slot' => 'wfCSMACDSlot',
|
||||
'wf_csmacd_conn' => 'wfCSMACDConnector',
|
||||
'wf_csmacd_mtu' => 'wfCSMACDMtu',
|
||||
'wf_duplex' => 'wfCSMACDLineCapability',
|
||||
'wf_csmacd_line' => 'wfCSMACDLineNumber',
|
||||
# From Wellfleet-CSMACD-MIB::wfCSMACDAutoNegTable
|
||||
'wf_auto' => 'wfCSMACDAutoNegSpeedSelect',
|
||||
# From Wellfleet-DOT1QTAG-CONFIG-MIB::wfDot1qTagConfigTable
|
||||
'wf_vlan_name' => 'wfDot1qTagCfgVlanName',
|
||||
'wf_local_vlan_id' => 'wfDot1qTagCfgLocalVlanId',
|
||||
'wf_global_vlan_id' => 'wfDot1qTagCfgGlobalVlanId',
|
||||
'wf_vlan_port' => 'wfDot1qTagCfgPhysicalPortId',
|
||||
# From Wellfleet-HARDWARE-MIB::wfHwTable
|
||||
'wf_hw_slot' => 'wfHwSlot',
|
||||
'wf_hw_mod_id' => 'wfHwModIdOpt',
|
||||
'wf_hw_mod_rev' => 'wfHwModRev',
|
||||
'wf_hw_mod_ser' => 'wfHwModSerialNumber',
|
||||
'wf_hw_mobo_id' => 'wfHwMotherBdIdOpt ',
|
||||
'wf_hw_mobo_rev' => 'wfHwMotherBdRev',
|
||||
'wf_hw_mobo_ser' => 'wfHwMotherBdSerialNumber',
|
||||
'wf_hw_diag' => 'wfHwDiagPromRev',
|
||||
'wf_hw_boot' => 'wfHwBootPromRev',
|
||||
'wf_hw_mobo_mem' => 'wfHwMotherBdMemorySize',
|
||||
'wf_hw_cfg_time' => 'wfHwConfigDateAndTime ',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
%MODEL_MAP = (
|
||||
'acefn' => 'FN',
|
||||
'aceln' => 'LN',
|
||||
'acecn' => 'CN',
|
||||
'afn' => 'AFN',
|
||||
'in' => 'IN',
|
||||
'an' => 'AN',
|
||||
'arn' => 'ARN',
|
||||
'sys5000' => '5000',
|
||||
'freln' => 'BLN',
|
||||
'frecn' => 'BCN',
|
||||
'frerbln' => 'BLN-2',
|
||||
'asn' => 'ASN',
|
||||
'asnzcable' => 'ASN-Z',
|
||||
'asnbcable' => 'ASN-B',
|
||||
);
|
||||
|
||||
sub model {
|
||||
my $bayrs = shift;
|
||||
my $bp_id = $bayrs->bp_id();
|
||||
|
||||
return defined $MODEL_MAP{$bp_id} ? $MODEL_MAP{$bp_id} : $bp_id;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'bayrs';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $bayrs = shift;
|
||||
my $descr = $bayrs->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
if ($descr =~ m/rel\/(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $bayrs = shift;
|
||||
my $serialnum = $bayrs->bp_serial();
|
||||
$serialnum = hex(join('','0x',map{sprintf "%02X", $_}unpack("C*",$serialnum)));
|
||||
|
||||
return $serialnum if defined $serialnum ;
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $bayrs = shift;
|
||||
my $description = $bayrs->i_description();
|
||||
my $vlan_ids = $bayrs->wf_global_vlan_id();
|
||||
my $vlan_idx = $bayrs->wf_local_vlan_id();
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$description){
|
||||
my $desc = $description->{$iid};
|
||||
next unless defined $desc;
|
||||
|
||||
$desc = $1 if $desc =~ /(^[A-Z]\d+)/;
|
||||
|
||||
$interfaces{$iid} = $desc;
|
||||
}
|
||||
foreach my $iid (keys %$vlan_ids){
|
||||
my $vlan = $vlan_ids->{$iid};
|
||||
next unless defined $vlan;
|
||||
my $vlan_if = $vlan_idx->{$iid};
|
||||
next unless defined $vlan_if;
|
||||
|
||||
my $desc = 'V' . $vlan;
|
||||
|
||||
$interfaces{$vlan_if} = $desc;
|
||||
}
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $bayrs = shift;
|
||||
my $i_index = $bayrs->i_index();
|
||||
my $description = $bayrs->i_description();
|
||||
my $v_name = $bayrs->wf_vlan_name();
|
||||
my $vlan_idx = $bayrs->wf_local_vlan_id();
|
||||
|
||||
my %i_name;
|
||||
foreach my $iid (keys %$description){
|
||||
my $name = $description->{$iid};
|
||||
next unless defined $name;
|
||||
$i_name{$iid} = $name;
|
||||
}
|
||||
# Get VLAN Virtual Router Interfaces
|
||||
foreach my $vid (keys %$v_name){
|
||||
my $v_name = $v_name->{$vid};
|
||||
next unless defined $v_name;
|
||||
my $vlan_if = $vlan_idx->{$vid};
|
||||
next unless defined $vlan_if;
|
||||
|
||||
$i_name{$vlan_if} = $v_name;
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $bayrs = shift;
|
||||
|
||||
my $wf_cct = $bayrs->wf_csmacd_cct();
|
||||
my $wf_duplex = $bayrs->wf_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$wf_cct){
|
||||
my $idx = $wf_cct->{$if};
|
||||
next unless defined $idx;
|
||||
my $duplex = $wf_duplex->{$if};
|
||||
next unless defined $duplex;
|
||||
|
||||
my $string = 'half';
|
||||
$string = 'full' if $duplex =~ /duplex/i;
|
||||
|
||||
$i_duplex{$idx}=$string;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $bayrs = shift;
|
||||
|
||||
my $wf_cct = $bayrs->wf_csmacd_cct();
|
||||
my $wf_duplex = $bayrs->wf_duplex();
|
||||
my $wf_auto = $bayrs->wf_auto();
|
||||
my $wf_slot = $bayrs->wf_csmacd_slot();
|
||||
my $wf_conn = $bayrs->wf_csmacd_conn();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$wf_cct){
|
||||
my $idx = $wf_cct->{$if};
|
||||
next unless defined $idx;
|
||||
my $duplex = $wf_duplex->{$if};
|
||||
next unless defined $duplex;
|
||||
my $slot = $wf_slot->{$if};
|
||||
my $conn = $wf_conn->{$if};
|
||||
my $auto_idx = "$slot.$conn";
|
||||
my $auto = $wf_auto->{$auto_idx};
|
||||
|
||||
my $string = 'other';
|
||||
if ($auto) {
|
||||
$string = 'half';
|
||||
$string = 'full' if $auto =~ /duplex/i;
|
||||
$string = 'auto' if $auto =~ /nway/i;
|
||||
}
|
||||
elsif ($duplex) {
|
||||
$string = 'half';
|
||||
$string = 'full' if $duplex =~ /duplex/i;
|
||||
}
|
||||
|
||||
$i_duplex_admin{$idx}=$string;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $bayrs = shift;
|
||||
|
||||
my $wf_cct = $bayrs->wf_csmacd_cct();
|
||||
my $wf_mtu = $bayrs->wf_csmacd_mtu();
|
||||
my $wf_line = $bayrs->wf_csmacd_line();
|
||||
my $wf_local_vid = $bayrs->wf_local_vlan_id();
|
||||
my $wf_global_vid = $bayrs->wf_global_vlan_id();
|
||||
my $wf_vport = $bayrs->wf_vlan_port();
|
||||
|
||||
my %i_vlan;
|
||||
# Look for VLANs on Ethernet Interfaces
|
||||
foreach my $if (keys %$wf_cct){
|
||||
my $idx = $wf_cct->{$if};
|
||||
next unless defined $idx;
|
||||
# Check MTU size, if unable to carry VLAN tag skip.
|
||||
my $mtu = $wf_mtu->{$if};
|
||||
next if (($mtu =~ /default/i) or ($mtu < 1522));
|
||||
my $line = $wf_line->{$if};
|
||||
my @vlans = ();
|
||||
foreach my $v_idx (keys %$wf_vport){
|
||||
my $port = $wf_vport->{$v_idx};
|
||||
next unless defined $port;
|
||||
next if ($port != $line);
|
||||
|
||||
my $vlan = $wf_global_vid->{$v_idx};
|
||||
push(@vlans, $vlan);
|
||||
}
|
||||
my $vlans = join (',', @vlans);
|
||||
$i_vlan{$idx}=$vlans;
|
||||
}
|
||||
# Add VLAN on VLAN Interfaces
|
||||
foreach my $idx (keys %$wf_global_vid){
|
||||
my $v_if = $wf_local_vid->{$idx};
|
||||
next unless defined $v_if;
|
||||
my $vlan = $wf_global_vid->{$idx};
|
||||
next unless defined $vlan;
|
||||
|
||||
$i_vlan{$v_if}=$vlan;
|
||||
}
|
||||
return \%i_vlan;
|
||||
}
|
||||
|
||||
sub root_ip {
|
||||
my $bayrs = shift;
|
||||
|
||||
my $ip_index = $bayrs->ip_index();
|
||||
my $ip_table = $bayrs->ip_table();
|
||||
|
||||
# Check for CLIP
|
||||
foreach my $entry (keys %$ip_index){
|
||||
my $idx = $ip_index->{$entry};
|
||||
next unless $idx == 0;
|
||||
my $clip = $ip_table->{$entry};
|
||||
next unless ((defined $clip) and ($clip eq '0.0.0.0'));
|
||||
print " SNMP::Layer3::BayRS::root_ip() using $clip\n" if $DEBUG;
|
||||
return $clip;
|
||||
}
|
||||
# Check for OSPF Router ID
|
||||
my $ospf_ip = $bayrs->ospf_rtr_id();
|
||||
if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0')) {
|
||||
print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" if $DEBUG;
|
||||
return $ospf_ip;
|
||||
}
|
||||
# Else Return First IP Address
|
||||
foreach my $entry (keys %$ip_table){
|
||||
my $ip = $ip_table->{$entry};
|
||||
print " SNMP::Layer3::BayRS::root_ip() using $ip\n" if $DEBUG;
|
||||
next unless $ip;
|
||||
return $ip if ($ip ne '0.0.0.0');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::BayRS - Perl5 Interface to Nortel Networks' routers running BayRS.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $bayrs = 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 = $bayrs->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for routers running Nortel Networks' BayRS.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $bayrs = new SNMP::Info::Layer3::BayRS(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Wellfleet-HARDWARE-MIB
|
||||
|
||||
=item Wellfleet-OSPF-MIB
|
||||
|
||||
=item Wellfleet-DOT1QTAG-CONFIG-MIB
|
||||
|
||||
=item Wellfleet-CSMACD-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status. Go to http://www.nortelnetworks.com Techninal Support, Browse
|
||||
Technical Support, Select by Product Families, BayRS Router Software,
|
||||
Router Software v 15.x, Software. Filter on mibs and download the latest
|
||||
version's archive.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $bayrs->model()
|
||||
|
||||
Returns the model of the BayRS router. Will translate between the MIB model and
|
||||
the common model with this map :
|
||||
|
||||
%MODEL_MAP = (
|
||||
'acefn' => 'FN',
|
||||
'aceln' => 'LN',
|
||||
'acecn' => 'CN',
|
||||
'afn' => 'AFN',
|
||||
'in' => 'IN',
|
||||
'an' => 'AN',
|
||||
'arn' => 'ARN',
|
||||
'sys5000' => '5000',
|
||||
'freln' => 'BLN',
|
||||
'frecn' => 'BCN',
|
||||
'frerbln' => 'BLN-2',
|
||||
'asn' => 'ASN',
|
||||
'asnzcable' => 'ASN-Z',
|
||||
'asnbcable' => 'ASN-B',
|
||||
);
|
||||
|
||||
=item $bayrs->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $bayrs->os()
|
||||
|
||||
Returns 'BayRS'
|
||||
|
||||
=item $bayrs->os_ver()
|
||||
|
||||
Returns the software version extracted from B<sysDescr>
|
||||
|
||||
=item $bayrs->serial()
|
||||
|
||||
Returns (B<wfHwBpSerialNumber>) after conversion to ASCII decimal
|
||||
|
||||
=item $bayrs->root_ip()
|
||||
|
||||
Returns the primary IP used to communicate with the router.
|
||||
|
||||
Returns the first found: CLIP (CircuitLess IP), (B<wfOspfRouterId>), or the first
|
||||
IP interface.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge 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 $bayrs->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port.
|
||||
|
||||
The physical port name is stripped to letter and numbers to signify
|
||||
port type and slot port (S11) if the default platform naming was
|
||||
maintained. Otherwise the port is the interface description.
|
||||
|
||||
=item $bayrs->i_name()
|
||||
|
||||
Returns (B<ifDescr>) along with VLAN name (B<wfDot1qTagCfgVlanName>) for VLAN
|
||||
interfaces.
|
||||
|
||||
=item $bayrs->i_duplex()
|
||||
|
||||
Returns reference to hash. Maps port operational duplexes to IIDs for Ethernet
|
||||
interfaces.
|
||||
|
||||
=item $bayrs->i_duplex_admin()
|
||||
|
||||
Returns reference to hash. Maps port admin duplexes to IIDs for Ethernet interfaces.
|
||||
|
||||
=item $bayrs->i_vlan()
|
||||
|
||||
Returns reference to hash. Maps port VLAN ID to IIDs.
|
||||
|
||||
=back
|
||||
|
||||
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $bayrs->at_index()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
|
||||
=item $bayrs->at_paddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
|
||||
=item $bayrs->at_netaddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=cut
|
||||
@@ -1,6 +1,7 @@
|
||||
# SNMP::Info::Layer3::C3550
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
# Copyright (c) 2003, Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,16 +29,18 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::C3550;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $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,17 @@ 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;
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
1;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
@@ -201,78 +127,70 @@ __END__
|
||||
|
||||
SNMP::Info::Layer3::C3550 - Perl5 Interface to Cisco Catalyst 3550 Layer 2/3 Switches running IOS
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Cisco Catalyst 3550 Layer 2/3 Switches. These devices run
|
||||
IOS but have some of the same charactersitics as the Catalyst WS-C family (5xxx,6xxx).
|
||||
For example, forwarding tables are held in VLANs, and extened interface information
|
||||
is gleened from CISCO-SWITCH-MIB.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $c3550 = new SNMP::Info::Layer3::C3550(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $c3550 = 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";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $c3550->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Cisco Catalyst 3550 Layer 2/3 Switches.
|
||||
|
||||
These devices run IOS but have some of the same charactersitics as the Catalyst WS-C family (5xxx,6xxx).
|
||||
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 $c3550 = new SNMP::Info::Layer3::C3550(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer3::C3550()
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
my $c3550 = new SNMP::Info::Layer3::C3550(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $c3550;
|
||||
|
||||
=item $c3550->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $c3550->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$c3550->session($newsession);
|
||||
=item SNMP::Info::CiscoStack
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBAL Values
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item $c3550->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
=item $c3550->model()
|
||||
(B<chassisModel>)
|
||||
See SNMP::Info::Layer3 for its own MIB requirements.
|
||||
|
||||
=item $c3550->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
See SNMP::Info::CiscoVTP for its own MIB requirements.
|
||||
|
||||
=item $c3550->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
See SNMP::Info::CiscoStack for its own MIB requirements.
|
||||
|
||||
=item $c3550->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
=back
|
||||
|
||||
=item $c3550->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
=head1 GLOBALS
|
||||
|
||||
=item $c3550->slots()
|
||||
(B<chassisNumSlots>)
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=item $c3550->fan()
|
||||
(B<chassisFanStatus>)
|
||||
=over
|
||||
|
||||
=item $c3550->vendor()
|
||||
|
||||
@@ -280,94 +198,33 @@ Sets or returns the SNMP::Session object
|
||||
|
||||
=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
|
||||
|
||||
=head2 Overrides
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=over
|
||||
=head2 Table Methods imported from SNMP::Info::Layer3
|
||||
|
||||
=item $c3550->i_type()
|
||||
See documentation in SNMP::Info::Layer3 for details.
|
||||
|
||||
Crosses p_port() with p_type() and returns the results.
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoVTP
|
||||
|
||||
Overrides with ifType if p_type() isn't available.
|
||||
See documentation in SNMP::Info::CiscoVTP for details.
|
||||
|
||||
=item $c3550->i_name()
|
||||
=head2 Table Methods imported from SNMP::Info::CiscoStack
|
||||
|
||||
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
|
||||
See documentation in SNMP::Info::CiscoStack for details.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
209
Info/Layer3/C6500.pm
Normal file
209
Info/Layer3/C6500.pm
Normal file
@@ -0,0 +1,209 @@
|
||||
# SNMP::Info::Layer3::C6500
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2003,2004 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.9;
|
||||
# $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';
|
||||
}
|
||||
|
||||
sub cisco_comm_indexing {
|
||||
1;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
158
Info/Layer3/Cisco.pm
Normal file
158
Info/Layer3/Cisco.pm
Normal file
@@ -0,0 +1,158 @@
|
||||
# SNMP::Info::Layer3::Cisco
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::Layer3::Cisco;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer3;
|
||||
use SNMP::Info::CiscoVTP;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer3::Cisco::ISA = qw/SNMP::Info::Layer3 SNMP::Info::CiscoVTP Exporter/;
|
||||
@SNMP::Info::Layer3::Cisco::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,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::Layer3::GLOBALS,
|
||||
%SNMP::Info::CiscoVTP::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer3::FUNCS,
|
||||
%SNMP::Info::CiscoVTP::FUNCS,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer3::MUNGE,
|
||||
%SNMP::Info::CiscoVTP::MUNGE,
|
||||
);
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::Cisco - Perl5 Interface to Generic L3 Cisco Device
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $cisco = 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 = $cisco->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Subclass for Generic Cisco Routers running IOS
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info::Layer3
|
||||
|
||||
=item SNMP::Info::CiscoVTP
|
||||
|
||||
=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.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $cisco->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.
|
||||
|
||||
|
||||
=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.
|
||||
|
||||
=cut
|
||||
347
Info/Layer3/Contivity.pm
Normal file
347
Info/Layer3/Contivity.pm
Normal file
@@ -0,0 +1,347 @@
|
||||
# SNMP::Info::Layer3::Contivity
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 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 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::Layer3::Contivity;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Entity;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
|
||||
|
||||
@SNMP::Info::Layer3::Contivity::ISA = qw/SNMP::Info SNMP::Info::Entity Exporter/;
|
||||
@SNMP::Info::Layer3::Contivity::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Entity::MIBS,
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Entity::GLOBALS,
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Entity::FUNCS,
|
||||
'i_name2' => 'ifName',
|
||||
# From RFC1213-MIB
|
||||
'at_index' => 'ipNetToMediaIfIndex',
|
||||
'at_paddr' => 'ipNetToMediaPhysAddress',
|
||||
'at_netaddr' => 'ipNetToMediaNetAddress',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Entity::MUNGE,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
sub layers {
|
||||
return '00000100';
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub model {
|
||||
my $contivity = shift;
|
||||
my $e_model = $contivity->e_model() || {};
|
||||
|
||||
my $model = $e_model->{1} || undef;
|
||||
|
||||
return $1 if (defined $model and $model =~ /(CES\d+)/i);
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'contivity';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $contivity = shift;
|
||||
my $descr = $contivity->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
if ($descr =~ m/V(\d+_\d+\.\d+)/i){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub mac {
|
||||
my $contivity = shift;
|
||||
my $i_mac = $contivity->i_mac();
|
||||
|
||||
# Return Interface MAC
|
||||
foreach my $entry (keys %$i_mac){
|
||||
my $sn = $i_mac->{$entry};
|
||||
next unless $sn;
|
||||
return $sn;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub serial {
|
||||
my $contivity = shift;
|
||||
my $e_serial = $contivity->e_serial() || {};
|
||||
|
||||
my $serial = $e_serial->{1} || undef;
|
||||
|
||||
return $1 if (defined $serial and $serial =~ /(\d+)/);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
sub interfaces {
|
||||
my $contivity = shift;
|
||||
my $description = $contivity->i_description();
|
||||
|
||||
my %interfaces = ();
|
||||
foreach my $iid (keys %$description){
|
||||
my $desc = $description->{$iid};
|
||||
# Skip everything except Ethernet interfaces
|
||||
next unless (defined $desc and $desc =~ /fe/i);
|
||||
|
||||
$interfaces{$iid} = $desc;
|
||||
}
|
||||
return \%interfaces;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $contivity = shift;
|
||||
my $i_name2 = $contivity->i_name2();
|
||||
|
||||
my %i_name;
|
||||
foreach my $iid (keys %$i_name2){
|
||||
my $name = $i_name2->{$iid};
|
||||
#Skip everything except Ethernet interfaces
|
||||
next unless (defined $name and $name =~ /fe/i);
|
||||
|
||||
$name = $1 if $name =~ /(fei\.\d+\.\d+)/;
|
||||
|
||||
$i_name{$iid} = $name;
|
||||
}
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub root_ip {
|
||||
my $contivity = shift;
|
||||
my $ip_table = $contivity->ip_table();
|
||||
|
||||
# Return First IP Address
|
||||
foreach my $entry (keys %$ip_table){
|
||||
my $router_ip = $ip_table->{$entry};
|
||||
print " SNMP::Layer3::Contivity::root_ip() using $router_ip\n" if $DEBUG;
|
||||
next unless $router_ip;
|
||||
return $router_ip if ($router_ip ne '0.0.0.0');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::Contivity - Perl5 Interface to Nortel Networks' Contivity
|
||||
Extranet Switches (CES).
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $contivity = 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 = $contivity->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Nortel Networks' Contivity Extranet Switch (CES).
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $contivity = new SNMP::Info::Layer3::Contivity(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Entity
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Entity for its own MIB requirements.
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $contivity->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $contivity->model()
|
||||
|
||||
Returns the chassis name.
|
||||
|
||||
(B<entPhysicalModelName.1>)
|
||||
|
||||
=item $contivity->os()
|
||||
|
||||
Returns 'CES'
|
||||
|
||||
=item $contivity->os_ver()
|
||||
|
||||
Returns the software version extracted from (B<sysDescr>).
|
||||
|
||||
=item $contivity->serial()
|
||||
|
||||
Returns the chassis serial number.
|
||||
|
||||
(B<entPhysicalSerialNum.1>)
|
||||
|
||||
=item $contivity->mac()
|
||||
|
||||
Returns the MAC address of the first Ethernet Interface.
|
||||
|
||||
=item $contivity->root_ip()
|
||||
|
||||
Returns the primary IP used to communicate with the router. Returns the first
|
||||
IP interface.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $contivity->layers()
|
||||
|
||||
Returns 00000100. Contivity does not support bridge MIB, so override reported
|
||||
layers.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Entity
|
||||
|
||||
See documentation in SNMP::Info::Entity 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 $contivity->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port. Skips loopback and
|
||||
tunnel interfaces.
|
||||
|
||||
=back
|
||||
|
||||
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $contivity->at_index()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
|
||||
=item $contivity->at_paddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
|
||||
=item $contivity->at_netaddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Entity
|
||||
|
||||
See documentation in SNMP::Info::Entity for details.
|
||||
|
||||
=cut
|
||||
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::Layer3::Foundry - SNMP Interface to Foundry devices
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::Layer3::Foundry;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -36,10 +38,11 @@ use strict;
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::FDP;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
|
||||
|
||||
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info SNMP::Info::Bridge Exporter/;
|
||||
@SNMP::Info::Layer3::Foundry::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::FDP Exporter/;
|
||||
@SNMP::Info::Layer3::Foundry::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
@@ -49,6 +52,7 @@ $INIT = 0;
|
||||
|
||||
%MIBS = ( %SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::FDP::MIBS,
|
||||
'FOUNDRY-SN-ROOT-MIB' => 'foundry',
|
||||
# IP-FORWARD-MIB
|
||||
# ETHERLIKE-MIB
|
||||
@@ -61,6 +65,7 @@ $INIT = 0;
|
||||
# Inherit the super class ones
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::FDP::GLOBALS,
|
||||
'mac' => 'ifPhysAddress.1',
|
||||
'chassis' => 'entPhysicalDescr.1',
|
||||
'serial' => 'snChasSerNum',
|
||||
@@ -78,6 +83,7 @@ $INIT = 0;
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::FDP::FUNCS,
|
||||
'i_name2' => 'ifName',
|
||||
# From RFC1213-MIB
|
||||
'at_index' => 'ipNetToMediaIfIndex',
|
||||
@@ -95,6 +101,7 @@ $INIT = 0;
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::FDP::MUNGE,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
@@ -199,6 +206,28 @@ sub model {
|
||||
return $model;
|
||||
}
|
||||
|
||||
sub os {
|
||||
my $foundry = shift;
|
||||
my $descr = $foundry->description();
|
||||
if ($descr =~ m/IronWare/i) {
|
||||
return 'IronWare';
|
||||
}
|
||||
|
||||
return 'foundry';
|
||||
}
|
||||
sub os_ver {
|
||||
my $foundry = shift;
|
||||
my $os_version = $foundry->os_version();
|
||||
return $os_version if defined $os_version;
|
||||
# Some older ones don't have this value,so we cull it from the description
|
||||
my $descr = $foundry->description();
|
||||
if ($descr =~ m/Version (\d\S*)/) {
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# $foundry->interfaces() - Map the Interfaces to their physical names
|
||||
sub interfaces {
|
||||
my $foundry = shift;
|
||||
@@ -222,16 +251,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry Network Devices
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module provides limited functionality from older Foundry devices.
|
||||
Specifically designed for a FI4802
|
||||
|
||||
Data comes RFC1213 and FOUNDRY-SN-ROOT-MIB
|
||||
|
||||
Inherits all methods from both SNMP::Info and SNMP::Info::Bridge
|
||||
SNMP::Info::Layer3::Foundry - Perl5 Interface to Foundry FastIron Network Devices
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -239,136 +259,168 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $foundry = new SNMP::Info::Layer3::Foundry(DestHost => 'switch' ,
|
||||
Community => 'public' );
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $foundry = new SNMP::Info(
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
# These arguments are passed directly on to SNMP::Session
|
||||
DestHost => 'myswitch',
|
||||
Community => 'public',
|
||||
Version => 1
|
||||
)
|
||||
or die "Can't connect to DestHost.\n";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
my $class = $foundry->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This subclass no longer supported.
|
||||
|
||||
This module provides limited functionality from older Foundry devices.
|
||||
|
||||
Specifically designed for a FI4802.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above. Turn off the AutoSpecify flag.
|
||||
|
||||
my $foundry = new SNMP::Info::Layer3::Foundry(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer3::Foundry()
|
||||
=item SNMP::Info
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $foundry = new SNMP::Info::Layer3::Foundry(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $foundry;
|
||||
|
||||
=item $foundry->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $foundry->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$foundry->session($newsession);
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBAL VALUES
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item FOUNDRY-SN-ROOT-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See classes listed above for their required MIBs.
|
||||
|
||||
=back
|
||||
|
||||
The Foundry MIBS can be downloaded from www.mibdepot.com and ??
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $foundry->model()
|
||||
|
||||
Returns model type. Checks $foundry->id() against the
|
||||
FOUNDRY-SN-ROOT-MIB and then parses out xxNNNN
|
||||
Returns model type. Checks $foundry->id() against the
|
||||
FOUNDRY-SN-ROOT-MIB and then parses out xxNNNN
|
||||
|
||||
=item $foundry->vendor()
|
||||
|
||||
Returns 'foundry' :)
|
||||
Returns 'foundry' :)
|
||||
|
||||
=item $foundry->mac()
|
||||
|
||||
Returns MAC Address of root port.
|
||||
Returns MAC Address of root port.
|
||||
|
||||
(B<ifPhysAddress.1>)
|
||||
(B<ifPhysAddress.1>)
|
||||
|
||||
=item $foundry->chassis()
|
||||
|
||||
Returns Chassis type.
|
||||
Returns Chassis type.
|
||||
|
||||
(B<entPhysicalDescr.1>)
|
||||
(B<entPhysicalDescr.1>)
|
||||
|
||||
=item $foundry->serial()
|
||||
|
||||
Returns serial number of device.
|
||||
Returns serial number of device.
|
||||
|
||||
(B<snChasSerNum>)
|
||||
(B<snChasSerNum>)
|
||||
|
||||
=item $foundry->temp()
|
||||
|
||||
Returns the chassis temperature
|
||||
Returns the chassis temperature
|
||||
|
||||
(B<snChasActualTemperature>)
|
||||
(B<snChasActualTemperature>)
|
||||
|
||||
=item $foundry->ps1_type()
|
||||
|
||||
Returns the Description for the power supply
|
||||
Returns the Description for the power supply
|
||||
|
||||
(B<snChasPwrSupplyDescription.1>)
|
||||
(B<snChasPwrSupplyDescription.1>)
|
||||
|
||||
=item $foundry->ps1_status()
|
||||
|
||||
Returns the status of the power supply.
|
||||
Returns the status of the power supply.
|
||||
|
||||
(B<snChasPwrSupplyOperStatus.1>)
|
||||
(B<snChasPwrSupplyOperStatus.1>)
|
||||
|
||||
=item $foundry->fan()
|
||||
|
||||
Returns the status of the chassis fan.
|
||||
Returns the status of the chassis fan.
|
||||
|
||||
(B<snChasFanOperStatus.1>)
|
||||
(B<snChasFanOperStatus.1>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge 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 $foundry->interfaces()
|
||||
|
||||
Returns reference to hash of interface names to iids.
|
||||
Returns reference to hash of interface names to iids.
|
||||
|
||||
Uses B<ifDescr>.
|
||||
Uses B<ifDescr>.
|
||||
|
||||
=item $foundry->i_name()
|
||||
|
||||
Returns reference to hash of interface names.
|
||||
Trys for B<ifAlias> and Defaults to B<ifName>
|
||||
Returns reference to hash of interface names.
|
||||
Trys for B<ifAlias> and Defaults to B<ifName>
|
||||
|
||||
=item $foundry->i_ignore()
|
||||
|
||||
Returns reference to hash of interfaces to be ignored.
|
||||
Returns reference to hash of interfaces to be ignored.
|
||||
|
||||
Ignores interfaces with descriptions of tunnel,loopback,null
|
||||
Ignores interfaces with descriptions of tunnel,loopback,null
|
||||
|
||||
=item $foundry->i_duplex()
|
||||
|
||||
Returns reference to hash of interface link duplex status.
|
||||
Returns reference to hash of interface link duplex status.
|
||||
|
||||
Crosses $foundry->sw_duplex() with $foundry->sw_index()
|
||||
Crosses $foundry->sw_duplex() with $foundry->sw_index()
|
||||
|
||||
=item $foundry->i_type()
|
||||
|
||||
Returns reference to hash of interface types.
|
||||
|
||||
Crosses $foundry->sw_type() with $foundry->sw_index()
|
||||
Returns reference to hash of interface types.
|
||||
|
||||
Crosses $foundry->sw_type() with $foundry->sw_index()
|
||||
|
||||
=item $foundry->i_speed()
|
||||
|
||||
Returns reference to hash of interface speeds .
|
||||
Returns reference to hash of interface speeds .
|
||||
|
||||
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
|
||||
does a little munging.
|
||||
Crosses $foundry->sw_speeD() with $foundry->sw_index() and
|
||||
does a little munging.
|
||||
|
||||
=back
|
||||
|
||||
@@ -378,21 +430,21 @@ Sets or returns the SNMP::Session object
|
||||
|
||||
=item $foundry->at_index()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
|
||||
=item $foundry->at_paddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
|
||||
=item $foundry->at_netaddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
|
||||
=back
|
||||
|
||||
@@ -402,28 +454,36 @@ Sets or returns the SNMP::Session object
|
||||
|
||||
=item $foundry->sw_index()
|
||||
|
||||
Returns reference to hash. Maps Table to Interface IID.
|
||||
Returns reference to hash. Maps Table to Interface IID.
|
||||
|
||||
(B<snSwPortIfIndex>)
|
||||
(B<snSwPortIfIndex>)
|
||||
|
||||
=item $foundry->sw_duplex()
|
||||
|
||||
Returns reference to hash. Current duplex status for switch ports.
|
||||
Returns reference to hash. Current duplex status for switch ports.
|
||||
|
||||
(B<snSwPortInfoChnMode>)
|
||||
(B<snSwPortInfoChnMode>)
|
||||
|
||||
=item $foundry->sw_type()
|
||||
|
||||
Returns reference to hash. Current Port Type .
|
||||
Returns reference to hash. Current Port Type .
|
||||
|
||||
(B<snSwPortInfoMediaType>)
|
||||
(B<snSwPortInfoMediaType>)
|
||||
|
||||
=item $foundry->sw_speed()
|
||||
|
||||
Returns reference to hash. Current Port Speed.
|
||||
Returns reference to hash. Current Port Speed.
|
||||
|
||||
(B<snSwPortInfoSpeed>)
|
||||
(B<snSwPortInfoSpeed>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=cut
|
||||
|
||||
653
Info/Layer3/Passport.pm
Normal file
653
Info/Layer3/Passport.pm
Normal file
@@ -0,0 +1,653 @@
|
||||
# SNMP::Info::Layer3::Passport
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 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 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::Layer3::Passport;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use SNMP::Info::Bridge;
|
||||
use SNMP::Info::SONMP;
|
||||
use SNMP::Info::RapidCity;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %FUNCS $INIT %MIBS %MUNGE/;
|
||||
|
||||
@SNMP::Info::Layer3::Passport::ISA = qw/SNMP::Info SNMP::Info::Bridge SNMP::Info::SONMP SNMP::Info::RapidCity Exporter/;
|
||||
@SNMP::Info::Layer3::Passport::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::MIBS,
|
||||
%SNMP::Info::Bridge::MIBS,
|
||||
%SNMP::Info::SONMP::MIBS,
|
||||
%SNMP::Info::RapidCity::MIBS,
|
||||
'OSPF-MIB' => 'ospfRouterId',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
%SNMP::Info::GLOBALS,
|
||||
%SNMP::Info::Bridge::GLOBALS,
|
||||
%SNMP::Info::SONMP::GLOBALS,
|
||||
%SNMP::Info::RapidCity::GLOBALS,
|
||||
'router_ip' => 'ospfRouterId'
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
%SNMP::Info::FUNCS,
|
||||
%SNMP::Info::Bridge::FUNCS,
|
||||
%SNMP::Info::SONMP::FUNCS,
|
||||
%SNMP::Info::RapidCity::FUNCS,
|
||||
'i_index2' => 'ifIndex',
|
||||
'i_mac2' => 'ifPhysAddress',
|
||||
'i_description2' => 'ifDescr',
|
||||
'i_name2' => 'ifName',
|
||||
'ip_index2' => 'ipAdEntIfIndex',
|
||||
# From RFC1213-MIB
|
||||
'at_index' => 'ipNetToMediaIfIndex',
|
||||
'at_paddr' => 'ipNetToMediaPhysAddress',
|
||||
'at_netaddr' => 'ipNetToMediaNetAddress',
|
||||
'i_name2' => 'ifName'
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
%SNMP::Info::MUNGE,
|
||||
%SNMP::Info::Bridge::MUNGE,
|
||||
%SNMP::Info::SONMP::MUNGE,
|
||||
%SNMP::Info::RapidCity::MUNGE,
|
||||
'i_mac2' => \&SNMP::Info::munge_mac,
|
||||
'at_paddr' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
sub model {
|
||||
my $passport = shift;
|
||||
my $desc = $passport->description();
|
||||
return undef unless defined $desc;
|
||||
|
||||
return '8603' if ($desc =~ /8603/);
|
||||
return '8606' if ($desc =~ /8606/);
|
||||
return '8610co' if ($desc =~ /8610co/);
|
||||
return '8610' if ($desc =~ /8610/);
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'nortel';
|
||||
}
|
||||
|
||||
sub os {
|
||||
return 'passport';
|
||||
}
|
||||
|
||||
sub os_ver {
|
||||
my $passport = shift;
|
||||
my $descr = $passport->description();
|
||||
return undef unless defined $descr;
|
||||
|
||||
if ($descr =~ m/(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub i_index {
|
||||
my $passport = shift;
|
||||
my $i_index = $passport->i_index2();
|
||||
my $vlan_index = $passport->rc_vlan_if();
|
||||
my $cpu_index = $passport->rc_cpu_ifindex();
|
||||
my $virt_ip = $passport->rc_virt_ip();
|
||||
|
||||
my %if_index;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
$if_index{$iid} = $index;
|
||||
}
|
||||
|
||||
# Get VLAN Virtual Router Interfaces
|
||||
foreach my $vid (keys %$vlan_index){
|
||||
my $v_index = $vlan_index->{$vid};
|
||||
next unless defined $v_index;
|
||||
next if $v_index == 0;
|
||||
|
||||
$if_index{$v_index} = $v_index;
|
||||
}
|
||||
|
||||
# Get CPU Ethernet Interfaces
|
||||
foreach my $cid (keys %$cpu_index){
|
||||
my $c_index = $cpu_index->{$cid};
|
||||
next unless defined $c_index;
|
||||
next if $c_index == 0;
|
||||
|
||||
$if_index{$c_index} = $c_index;
|
||||
}
|
||||
|
||||
# Check for Virtual Mgmt Interface
|
||||
unless ($virt_ip eq '0.0.0.0') {
|
||||
# Make up an index number, 1 is not reserved AFAIK
|
||||
$if_index{1} = 1;
|
||||
}
|
||||
|
||||
return \%if_index;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $passport = shift;
|
||||
my $i_index = $passport->i_index();
|
||||
my $vlan_id = $passport->rc_vlan_id();
|
||||
my $vlan_index = $passport->rc_vlan_if();
|
||||
my $model = $passport->model();
|
||||
|
||||
my %reverse_vlan = reverse %$vlan_index;
|
||||
|
||||
my %if;
|
||||
foreach my $iid (keys %$i_index){
|
||||
my $index = $i_index->{$iid};
|
||||
next unless defined $index;
|
||||
|
||||
if ($index == 1) {
|
||||
$if{$index} = 'CPU.Virtual';
|
||||
}
|
||||
|
||||
elsif (($index == 192) and ($model eq '8603')) {
|
||||
$if{$index} = 'CPU3';
|
||||
}
|
||||
|
||||
elsif ($index == 320) {
|
||||
$if{$index} = 'CPU5';
|
||||
}
|
||||
|
||||
elsif ($index == 384) {
|
||||
$if{$index} = 'CPU6';
|
||||
}
|
||||
|
||||
elsif ($index > 2000) {
|
||||
my $vlan_index = $reverse_vlan{$iid};
|
||||
my $v_id = $vlan_id->{$vlan_index};
|
||||
next unless defined $v_id;
|
||||
|
||||
my $v_port = 'V'."$v_id";
|
||||
$if{$index} = $v_port;
|
||||
}
|
||||
|
||||
else {
|
||||
my $port = ($index % 64) + 1;
|
||||
my $slot = int($index / 64);
|
||||
|
||||
my $slotport = "$slot.$port";
|
||||
$if{$iid} = $slotport;
|
||||
}
|
||||
|
||||
}
|
||||
return \%if;
|
||||
}
|
||||
|
||||
sub i_mac {
|
||||
my $passport = shift;
|
||||
my $i_mac = $passport->i_mac2();
|
||||
my $vlan_mac = $passport->rc_vlan_mac();
|
||||
my $vlan_index = $passport->rc_vlan_if();
|
||||
my $cpu_mac = $passport->rc_cpu_mac();
|
||||
my $chassis_base_mac = $passport->rc_base_mac();
|
||||
my $virt_ip = $passport->rc_virt_ip();
|
||||
|
||||
my %if_mac;
|
||||
foreach my $iid (keys %$i_mac){
|
||||
my $mac = $i_mac->{$iid};
|
||||
next unless defined $mac;
|
||||
|
||||
$if_mac{$iid} = $mac;
|
||||
}
|
||||
|
||||
# Get VLAN Virtual Router Interfaces
|
||||
foreach my $iid (keys %$vlan_mac){
|
||||
my $v_mac = $vlan_mac->{$iid};
|
||||
my $v_id = $vlan_index->{$iid};
|
||||
next unless defined $v_mac;
|
||||
|
||||
$if_mac{$v_id} = $v_mac;
|
||||
}
|
||||
|
||||
# Get CPU Ethernet Interfaces
|
||||
foreach my $iid (keys %$cpu_mac){
|
||||
my $mac = $cpu_mac->{$iid};
|
||||
next unless defined $mac;
|
||||
|
||||
$if_mac{$iid} = $mac;
|
||||
}
|
||||
|
||||
# Check for Virtual Mgmt Interface
|
||||
unless ($virt_ip eq '0.0.0.0'){
|
||||
my @virt_mac = split /:/, $chassis_base_mac;
|
||||
$virt_mac[0] = hex($virt_mac[0]);
|
||||
$virt_mac[1] = hex($virt_mac[1]);
|
||||
$virt_mac[2] = hex($virt_mac[2]);
|
||||
$virt_mac[3] = hex($virt_mac[3]);
|
||||
$virt_mac[4] = hex($virt_mac[4]) + 0x03;
|
||||
$virt_mac[5] = hex($virt_mac[5]) + 0xF8;
|
||||
|
||||
my $mac = join(':',map { sprintf "%02x",$_ } @virt_mac);
|
||||
|
||||
$if_mac{1} = $mac;
|
||||
}
|
||||
|
||||
return \%if_mac;
|
||||
}
|
||||
|
||||
sub i_description {
|
||||
my $passport = shift;
|
||||
my $i_descr = $passport->i_description2();
|
||||
my $v_descr = $passport->rc_vlan_name();
|
||||
my $vlan_index = $passport->rc_vlan_if();
|
||||
|
||||
my %descr;
|
||||
foreach my $iid (keys %$i_descr){
|
||||
my $if_descr = $i_descr->{$iid};
|
||||
next unless defined $if_descr;
|
||||
|
||||
$descr{$iid} = $if_descr;
|
||||
}
|
||||
|
||||
# Get VLAN Virtual Router Interfaces
|
||||
foreach my $vid (keys %$v_descr){
|
||||
my $vl_descr = $v_descr->{$vid};
|
||||
my $v_id = $vlan_index->{$vid};
|
||||
next unless defined $vl_descr;
|
||||
|
||||
$descr{$v_id} = $vl_descr;
|
||||
}
|
||||
return \%descr;
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $passport = shift;
|
||||
my $i_index = $passport->i_index();
|
||||
my $rc_alias = $passport->rc_alias();
|
||||
my $i_name2 = $passport->i_name2();
|
||||
my $v_name = $passport->rc_vlan_name();
|
||||
my $vlan_index = $passport->rc_vlan_if();
|
||||
my $model = $passport->model();
|
||||
|
||||
my %reverse_vlan = reverse %$vlan_index;
|
||||
|
||||
my %i_name;
|
||||
foreach my $iid (keys %$i_index){
|
||||
|
||||
if ($iid == 1) {
|
||||
$i_name{$iid} = 'CPU Virtual Management IP';
|
||||
}
|
||||
|
||||
elsif (($iid == 192) and ($model eq '8603')) {
|
||||
$i_name{$iid} = 'CPU 3 Ethernet Port';
|
||||
}
|
||||
|
||||
elsif ($iid == 320) {
|
||||
$i_name{$iid} = 'CPU 5 Ethernet Port';
|
||||
}
|
||||
|
||||
elsif ($iid == 384) {
|
||||
$i_name{$iid} = 'CPU 5 Ethernet Port';
|
||||
}
|
||||
|
||||
elsif ($iid > 2000) {
|
||||
my $vlan_index = $reverse_vlan{$iid};
|
||||
my $vlan_name = $v_name->{$vlan_index};
|
||||
next unless defined $vlan_name;
|
||||
|
||||
$i_name{$iid} = $vlan_name;
|
||||
}
|
||||
|
||||
else {
|
||||
my $name = $i_name2->{$iid};
|
||||
my $alias = $rc_alias->{$iid};
|
||||
$i_name{$iid} = (defined $alias and $alias !~ /^\s*$/) ?
|
||||
$alias :
|
||||
$name;
|
||||
}
|
||||
}
|
||||
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub ip_index {
|
||||
my $passport = shift;
|
||||
my $ip_index = $passport->ip_index2();
|
||||
my $cpu_ip = $passport->rc_cpu_ip();
|
||||
my $virt_ip = $passport->rc_virt_ip();
|
||||
|
||||
my %ip_index;
|
||||
foreach my $ip (keys %$ip_index){
|
||||
my $iid = $ip_index->{$ip};
|
||||
next unless defined $iid;
|
||||
|
||||
$ip_index{$ip} = $iid;
|
||||
}
|
||||
|
||||
# Get CPU Ethernet IP
|
||||
foreach my $cid (keys %$cpu_ip){
|
||||
my $c_ip = $cpu_ip->{$cid};
|
||||
next unless defined $c_ip;
|
||||
|
||||
$ip_index{$c_ip} = $cid;
|
||||
}
|
||||
|
||||
# Get Virtual Mgmt IP
|
||||
$ip_index{$virt_ip} = 1;
|
||||
|
||||
return \%ip_index;
|
||||
}
|
||||
|
||||
sub root_ip {
|
||||
my $passport = shift;
|
||||
my $rc_ip_addr = $passport->rc_ip_addr();
|
||||
my $rc_ip_type = $passport->rc_ip_type();
|
||||
my $virt_ip = $passport->rc_virt_ip();
|
||||
my $router_ip = $passport->router_ip();
|
||||
my $sonmp_topo_port = $passport->sonmp_topo_port();
|
||||
my $sonmp_topo_ip = $passport->sonmp_topo_ip();
|
||||
|
||||
# Return CLIP (CircuitLess IP)
|
||||
foreach my $iid (keys %$rc_ip_type){
|
||||
my $ip_type = $rc_ip_type->{$iid};
|
||||
next unless ((defined $ip_type) and ($ip_type =~ /circuitLess/i));
|
||||
my $ip = $rc_ip_addr->{$iid};
|
||||
next unless defined $ip;
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
# Return Management Virtual IP address
|
||||
return $virt_ip if ((defined $virt_ip) and ($virt_ip ne '0.0.0.0'));
|
||||
|
||||
# Return OSPF Router ID
|
||||
return $router_ip if ((defined $router_ip) and ($router_ip ne '0.0.0.0'));
|
||||
|
||||
# Otherwise Return SONMP Advertised IP Address
|
||||
foreach my $entry (keys %$sonmp_topo_port){
|
||||
my $port = $sonmp_topo_port->{$entry};
|
||||
next unless $port == 0;
|
||||
my $ip = $sonmp_topo_ip->{$entry};
|
||||
return $ip if ((defined $ip) and ($ip ne '0.0.0.0'));
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Required for SNMP::Info::SONMP
|
||||
sub index_factor {
|
||||
return 64;
|
||||
}
|
||||
|
||||
sub slot_offset {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub port_offset {
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer3::Passport - Perl5 Interface to Nortel Networks' Passport
|
||||
8600 Series Switches
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $passport = 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 = $passport->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Abstraction subclass for Nortel Networks' Passport 8600 Series Switches.
|
||||
|
||||
These devices run Passport OS but have some of the same charactersitics as the Baystack family.
|
||||
For example, extended interface information is gleened from RAPID-CITY.
|
||||
|
||||
For speed or debugging purposes you can call the subclass directly, but not after determining
|
||||
a more specific class using the method above.
|
||||
|
||||
my $passport = new SNMP::Info::Layer3::Passport(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
=over
|
||||
|
||||
=item SNMP::Info
|
||||
|
||||
=item SNMP::Info::Bridge
|
||||
|
||||
=item SNMP::Info::SONMP
|
||||
|
||||
=item SNMP::Info::RapidCity
|
||||
|
||||
=back
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item OSPF-MIB
|
||||
|
||||
=item Inherited Classes' MIBs
|
||||
|
||||
See SNMP::Info for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::Bridge for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::SONMP for its own MIB requirements.
|
||||
|
||||
See SNMP::Info::RapidCity for its own MIB requirements.
|
||||
|
||||
OSPF-MIB is included in the archive at ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $passport->model()
|
||||
|
||||
Returns the model extracted from B<sysDescr>
|
||||
|
||||
=item $passport->vendor()
|
||||
|
||||
Returns 'Nortel'
|
||||
|
||||
=item $passport->os()
|
||||
|
||||
Returns 'Passport'
|
||||
|
||||
=item $passport->os_ver()
|
||||
|
||||
Returns the software version extracted from B<sysDescr>
|
||||
|
||||
=item $passport->serial()
|
||||
|
||||
Returns (B<rcChasSerialNumber>)
|
||||
|
||||
=item $passport->root_ip()
|
||||
|
||||
Returns the primary IP used to communicate with the device. Returns the first
|
||||
found: CLIP (CircuitLess IP), Management Virtual IP (B<rcSysVirtualIpAddr>),
|
||||
OSPF Router ID (B<ospfRouterId>), SONMP Advertised IP Address.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $passport->index_factor()
|
||||
|
||||
Required by SNMP::Info::SONMP. Returns 64.
|
||||
|
||||
=item $passport->port_offset()
|
||||
|
||||
Required by SNMP::Info::SONMP. Returns 1.
|
||||
|
||||
=item $passport->slot_offset()
|
||||
|
||||
Required by SNMP::Info::SONMP. Returns 0.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Globals imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Globals imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=head2 Global Methods imported from SNMP::Info::RapidCity
|
||||
|
||||
See documentation in SNMP::Info::RapidCity 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 $passport->i_index()
|
||||
|
||||
Returns SNMP IID to Interface index. Extends (B<ifIndex>) by adding the index of
|
||||
the CPU virtual management IP (if present), each CPU Ethernet port, and each VLAN
|
||||
to ensure the virtual router ports are captured.
|
||||
|
||||
=item $passport->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port.
|
||||
|
||||
Slot and port numbers on the Passport switches are determined by the formula:
|
||||
port = (ifIndex % 64) + 1, slot = int(ifIndex / 64).
|
||||
|
||||
The physical port name is returned as slot.port. CPU Ethernet ports are prefixed
|
||||
with CPU and VLAN interfaces are returned as the VLAN ID prefixed with V.
|
||||
|
||||
=item $passport->i_mac()
|
||||
|
||||
MAC address of the interface. Note this is just the MAC of the port, not anything
|
||||
connected to it.
|
||||
|
||||
=item $passport->i_description()
|
||||
|
||||
Description of the interface. Usually a little longer single word name that is both
|
||||
human and machine friendly. Not always.
|
||||
|
||||
=item $passport->i_name()
|
||||
|
||||
Crosses rc_alias() (B<rcPortName>) with ifAlias() and returns the human set port
|
||||
name if exists.
|
||||
|
||||
=item $passport->ip_index()
|
||||
|
||||
Maps the IP Table to the IID. Extends (B<ipAdEntIfIndex>) by adding the index of
|
||||
the CPU virtual management IP (if present) and each CPU Ethernet port.
|
||||
|
||||
=back
|
||||
|
||||
=head2 RFC1213 Arp Cache Table (B<ipNetToMediaTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $passport->at_index()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to Interface IIDs
|
||||
|
||||
(B<ipNetToMediaIfIndex>)
|
||||
|
||||
=item $passport->at_paddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to MAC addresses.
|
||||
|
||||
(B<ipNetToMediaPhysAddress>)
|
||||
|
||||
=item $passport->at_netaddr()
|
||||
|
||||
Returns reference to hash. Maps ARP table entries to IPs
|
||||
|
||||
(B<ipNetToMediaNetAddress>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info
|
||||
|
||||
See documentation in SNMP::Info for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::Bridge
|
||||
|
||||
See documentation in SNMP::Info::Bridge for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::SONMP
|
||||
|
||||
See documentation in SNMP::Info::SONMP for details.
|
||||
|
||||
=head2 Table Methods imported from SNMP::Info::RapidCity
|
||||
|
||||
See documentation in SNMP::Info::RapidCity for details.
|
||||
|
||||
=cut
|
||||
89
Info/MAU.pm
89
Info/MAU.pm
@@ -1,6 +1,8 @@
|
||||
# SNMP::Info::MAU - Media Access Unit - RFC2668
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker changes from version 0.8 and beyond.
|
||||
#
|
||||
# Copyright (c) 2002,2003 Regents of the University of California
|
||||
# All rights reserved.
|
||||
#
|
||||
@@ -28,7 +30,7 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package SNMP::Info::MAU;
|
||||
$VERSION = 0.2;
|
||||
$VERSION = 0.9;
|
||||
# $Id$
|
||||
|
||||
use strict;
|
||||
@@ -109,15 +111,7 @@ __END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::MAU - Perl5 Interface to SNMP Medium Access Unit (MAU) MIB (RFC2668)
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
MAU-MIB is used by Layer 2 devices like HP Switches . The MAU table
|
||||
contains link and duplex info for the port itself and the device
|
||||
connected to that port.
|
||||
|
||||
Inherits all methods from SNMP::Info
|
||||
SNMP::Info::MAU - Perl5 Interface to Medium Access Unit (MAU) MIB (RFC2668) via SNMP
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -125,46 +119,47 @@ Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $mau = new SNMP::Info::MAU( DestHost => 'myswitch',
|
||||
Community => 'public');
|
||||
my $mau = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'hpswitch',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
my $class = $mau->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::MAU is a sublcass of SNMP::Info that supplies access to the
|
||||
MAU-MIB (RFC2668). This MIB is sometimes implemented on Layer 2 network devices like HP Switches.
|
||||
MAU = Media Access Unit.
|
||||
|
||||
The MAU table contains link and duplex info for the port itself and the device
|
||||
connected to that port.
|
||||
|
||||
Normally you use or create a subclass of SNMP::Info that inherits this one. Do not use directly.
|
||||
|
||||
For debugging purposes call the class directly as you would SNMP::Info
|
||||
|
||||
my $mau = new SNMP::Info::MAU(...);
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::MAU()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $mau = new SNMP::Info::MAU(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $mau;
|
||||
|
||||
=item $mau->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $mau->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$mau->session($newsession);
|
||||
|
||||
=item $mau->all(), $mau->load_all()
|
||||
|
||||
Queries each of the methods listed in %FUNCS and returns a hash reference.
|
||||
|
||||
$mau->all() will call $mau->load_all() once and then return cahced valued.
|
||||
Use $mau->load_all() to reload from the device.
|
||||
=item MAU-MIB
|
||||
|
||||
=back
|
||||
|
||||
=head1 MAU Global Configuration Values
|
||||
=head1 GLOBALS
|
||||
|
||||
These are methods that return scalar value from SNMP
|
||||
|
||||
=over
|
||||
|
||||
@@ -172,7 +167,12 @@ Use $mau->load_all() to reload from the device.
|
||||
|
||||
=back
|
||||
|
||||
=head1 MAU INTERFACE TABLE ENTRIES
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 MAU INTERFACE TABLE ENTRIES
|
||||
|
||||
=over
|
||||
|
||||
@@ -272,4 +272,5 @@ capabilities of the device on the other end.
|
||||
high. Currently bits 10,12,15,17,19.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
406
Info/NortelStack.pm
Normal file
406
Info/NortelStack.pm
Normal file
@@ -0,0 +1,406 @@
|
||||
# SNMP::Info::NortelStack
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::NortelStack;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
|
||||
@SNMP::Info::NortelStack::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::NortelStack::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
|
||||
# Debug
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
# Five data structures required by SNMP::Info
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
# S5-ROOT-MIB and S5-TCS-MIB required by the MIBs below
|
||||
'S5-AGENT-MIB' => 's5AgMyGrpIndx',
|
||||
'S5-CHASSIS-MIB' => 's5ChasType',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
# From S5-AGENT-MIB
|
||||
'ns_ag_ver' => 's5AgInfoVer',
|
||||
'ns_op_mode' => 's5AgSysCurrentOperationalMode',
|
||||
'ns_auto_pvid' => 's5AgSysAutoPvid',
|
||||
'tftp_host' => 's5AgSysTftpServerAddress',
|
||||
'tftp_file' => 's5AgSysBinaryConfigFilename',
|
||||
'tftp_action' => 's5AgInfoFileAction',
|
||||
'tftp_result' => 's5AgInfoFileStatus',
|
||||
'vlan' => 's5AgSysManagementVlanId',
|
||||
# From S5-CHASSIS-MIB
|
||||
'serial' => 's5ChasSerNum',
|
||||
'ns_cfg_chg' => 's5ChasGblConfChngs',
|
||||
'ns_cfg_time' => 's5ChasGblConfLstChng',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
# From S5-AGENT-MIB::s5AgMyIfTable
|
||||
'i_cfg_file' => 's5AgMyIfCfgFname',
|
||||
'i_cfg_host' => 's5AgMyIfLdSvrAddr',
|
||||
# From S5-CHASSIS-MIB::s5ChasComTable
|
||||
'ns_com_grp_idx' => 's5ChasComGrpIndx',
|
||||
'ns_com_ns_com_idx'=> 's5ChasComIndx',
|
||||
'ns_com_sub_idx' => 's5ChasComSubIndx',
|
||||
'ns_com_type' => 's5ChasComType',
|
||||
'ns_com_descr' => 's5ChasComDescr',
|
||||
'ns_com_ver' => 's5ChasComVer',
|
||||
'ns_com_serial' => 's5ChasComSerNum',
|
||||
# From S5-CHASSIS-MIB::s5ChasStoreTable
|
||||
'ns_store_grp_idx' => 's5ChasStoreGrpIndx',
|
||||
'ns_store_ns_com_idx' => 's5ChasStoreComIndx',
|
||||
'ns_store_sub_idx' => 's5ChasStoreSubIndx',
|
||||
'ns_store_idx' => 's5ChasStoreIndx',
|
||||
'ns_store_type' => 's5ChasStoreType',
|
||||
'ns_store_size' => 's5ChasStoreCurSize',
|
||||
'ns_store_ver' => 's5ChasStoreCntntVer',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
|
||||
);
|
||||
|
||||
sub os_ver {
|
||||
my $bayhub = shift;
|
||||
my $ver = $bayhub->ns_ag_ver();
|
||||
return undef unless defined $ver;
|
||||
|
||||
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/){
|
||||
return $1;
|
||||
}
|
||||
if ($ver =~ m/V(\d+\.\d+\.\d+)/i){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub os_bin {
|
||||
my $bayhub = shift;
|
||||
my $ver = $bayhub->ns_ag_ver();
|
||||
return undef unless defined $ver;
|
||||
|
||||
if ($ver =~ m/(\d+\.\d+\.\d+\.\d+)/i){
|
||||
return $1;
|
||||
}
|
||||
if ($ver =~ m/V(\d+\.\d+.\d+)/i){
|
||||
return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::NortelStack - Perl5 Interface to Nortel Stack information using SNMP
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $stack = 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 = $stack->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::NortelStack is a subclass of SNMP::Info that provides an interface
|
||||
to C<S5-AGENT-MIB> and C<S5-CHASSIS-MIB>. These MIBs are used across the
|
||||
Nortel BayStack family, as well as, older Nortel devices such as the Centillion
|
||||
family of ATM switches.
|
||||
|
||||
Use or create in a subclass of SNMP::Info. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item S5-AGENT-MIB
|
||||
|
||||
=item S5-CHASSIS-MIB
|
||||
|
||||
=item S5-ROOT-MIB and S5-TCS-MIB are required by the other MIBs.
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status.
|
||||
|
||||
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
|
||||
Select by product, Java Device Manager, Software. Download the latest version.
|
||||
After installation, all mibs are located under the install directory under mibs
|
||||
and the repspective product line.
|
||||
|
||||
Note: Recommend versions (located in JDM\mibs\bps2000\v3100.zip)
|
||||
S5-AGENT-MIB s5age154.mib
|
||||
S5-CHASSIS-MIB s5cha135.mib
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $baystack->serial()
|
||||
|
||||
Returns (B<s5ChasSerNum>)
|
||||
|
||||
=item $stack->os_ver()
|
||||
|
||||
Returns the software version extracted from (B<s5AgInfoVer>)
|
||||
|
||||
=item $stack->os_bin()
|
||||
|
||||
Returns the firmware version extracted from (B<s5AgInfoVer>)
|
||||
|
||||
=item $stack->ns_ag_ver()
|
||||
|
||||
Returns the version of the agent in the form 'major.minor.maintenance[letters]'.
|
||||
|
||||
(B<s5AgInfoVer>)
|
||||
|
||||
=item $stack->ns_op_mode()
|
||||
|
||||
Returns the stacking mode.
|
||||
|
||||
(B<s5AgSysCurrentOperationalMode>)
|
||||
|
||||
=item $stack->tftp_action()
|
||||
|
||||
This object is used to download or upload a config file or an image file.
|
||||
|
||||
(B<s5AgInfoFileAction>)
|
||||
|
||||
=item $stack->tftp_result()
|
||||
|
||||
Returns the status of the latest action as shown by $stack->tftp_action().
|
||||
|
||||
(B<s5AgInfoFileStatus>)
|
||||
|
||||
=item $stack->ns_auto_pvid()
|
||||
|
||||
Returns the value indicating whether adding a port as a member of a VLAN
|
||||
automatically results in its PVID being set to be the same as that VLAN ID.
|
||||
|
||||
(B<s5AgSysAutoPvid>)
|
||||
|
||||
=item $stack->tftp_file()
|
||||
|
||||
Name of the binary configuration file that will be downloaded/uploaded when
|
||||
the $stack->tftp_action() object is set.
|
||||
|
||||
(B<s5AgSysBinaryConfigFilename>)
|
||||
|
||||
=item $stack->tftp_host()
|
||||
|
||||
The IP address of the TFTP server for all TFTP operations.
|
||||
|
||||
(B<s5AgSysTftpServerAddress>)
|
||||
|
||||
=item $stack->vlan()
|
||||
|
||||
Returns the VLAN ID of the system's management VLAN.
|
||||
|
||||
(B<s5AgSysManagementVlanId>)
|
||||
|
||||
=item $stack->ch_ser()
|
||||
|
||||
Returns the serial number of the chassis.
|
||||
|
||||
(B<s5ChasSerNum>)
|
||||
|
||||
=item $stack->ns_cfg_chg()
|
||||
|
||||
Returns the total number of configuration changes (other than attachment changes,
|
||||
or physical additions or removals) in the chassis that have been detected since
|
||||
cold/warm start.
|
||||
|
||||
(B<s5ChasGblConfChngs>)
|
||||
|
||||
=item $stack->ns_cfg_time()
|
||||
|
||||
Returns the value of sysUpTime when the last configuration change (other than
|
||||
attachment changes, or physical additions or removals) in the chassis was
|
||||
detected.
|
||||
|
||||
(B<s5ChasGblConfLstChng>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Agent Interface Table (s5AgMyIfTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->i_cfg_file()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Name of the file
|
||||
|
||||
(B<s5AgMyIfCfgFname>)
|
||||
|
||||
=item $stack->i_cfg_host()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: IP address of the load server
|
||||
|
||||
(B<s5AgMyIfLdSvrAddr>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Chassis Components Table (s5ChasComTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->ns_com_grp_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the chassis level
|
||||
group which contains this component.
|
||||
|
||||
(B<s5ChasComGrpIndx>)
|
||||
|
||||
=item $stack->ns_com_ns_com_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the component in
|
||||
the group. For modules in the 'board' group, this is the slot number.
|
||||
|
||||
(B<s5ChasComIndx>)
|
||||
|
||||
=item $stack->ns_com_sub_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the sub-component
|
||||
in the component.
|
||||
|
||||
(B<s5ChasComSubIndx>)
|
||||
|
||||
=item $stack->ns_com_type()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Type
|
||||
|
||||
(B<s5ChasComType>)
|
||||
|
||||
=item $stack->ns_com_descr()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Description
|
||||
|
||||
(B<s5ChasComDescr>)
|
||||
|
||||
=item $stack->ns_com_ver()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Version
|
||||
|
||||
(B<s5ChasComVer>)
|
||||
|
||||
=item $stack->ns_com_serial()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Serial Number
|
||||
|
||||
(B<s5ChasComSerNum>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Storage Area Table (s5ChasStoreTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $stack->ns_store_grp_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the chassis level
|
||||
group.
|
||||
|
||||
(B<s5ChasStoreGrpIndx>)
|
||||
|
||||
=item $stack->ns_store_ns_com_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the group.
|
||||
|
||||
(B<s5ChasStoreComIndx>)
|
||||
|
||||
=item $stack->ns_store_sub_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the sub-component.
|
||||
|
||||
(B<s5ChasStoreSubIndx>)
|
||||
|
||||
=item $stack->ns_store_idx()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Index of the storage area.
|
||||
|
||||
(B<s5ChasStoreIndx>)
|
||||
|
||||
=item $stack->ns_store_type()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Type
|
||||
|
||||
(B<s5ChasStoreType>)
|
||||
|
||||
=item $stack->ns_store_size()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Size
|
||||
|
||||
(B<s5ChasStoreCurSize>)
|
||||
|
||||
=item $stack->ns_store_ver()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value: Version
|
||||
|
||||
(B<s5ChasStoreCntntVer>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
708
Info/RapidCity.pm
Normal file
708
Info/RapidCity.pm
Normal file
@@ -0,0 +1,708 @@
|
||||
# SNMP::Info::RapidCity
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::RapidCity;
|
||||
$VERSION = 0.9;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use Carp;
|
||||
|
||||
@SNMP::Info::RapidCity::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::RapidCity::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
|
||||
# Debug
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
# Five data structures required by SNMP::Info
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
'RAPID-CITY' => 'rapidCity',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'serial' => 'rcChasSerialNumber',
|
||||
'chassis' => 'rcChasType',
|
||||
'slots' => 'rcChasNumSlots',
|
||||
'tftp_host' => 'rcTftpHost',
|
||||
'tftp_file' => 'rcTftpFile',
|
||||
'tftp_action' => 'rcTftpAction',
|
||||
'tftp_result' => 'rcTftpResult',
|
||||
'rc_ch_rev' => 'rcChasHardwareRevision',
|
||||
'rc_base_mac' => 'rc2kChassisBaseMacAddr',
|
||||
'rc_virt_ip' => 'rcSysVirtualIpAddr',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
# From RAPID-CITY::rcPortTable
|
||||
'rc_index' => 'rcPortIndex',
|
||||
'rc_duplex' => 'rcPortOperDuplex',
|
||||
'rc_duplex_admin' => 'rcPortAdminDuplex',
|
||||
'rc_speed_admin' => 'rcPortAdminSpeed',
|
||||
'rc_auto' => 'rcPortAutoNegotiate',
|
||||
'rc_alias' => 'rcPortName',
|
||||
# From RAPID-CITY::rc2kCpuEthernetPortTable
|
||||
'rc_cpu_ifindex' => 'rc2kCpuEthernetPortIfIndex',
|
||||
'rc_cpu_admin' => 'rc2kCpuEthernetPortAdminStatus',
|
||||
'rc_cpu_oper' => 'rc2kCpuEthernetPortOperStatus',
|
||||
'rc_cpu_ip' => 'rc2kCpuEthernetPortAddr',
|
||||
'rc_cpu_auto' => 'rc2kCpuEthernetPortAutoNegotiate',
|
||||
'rc_cpu_duplex_admin' => 'rc2kCpuEthernetPortAdminDuplex',
|
||||
'rc_cpu_duplex' => 'rc2kCpuEthernetPortOperDuplex',
|
||||
'rc_cpu_speed_admin' => 'rc2kCpuEthernetPortAdminSpeed',
|
||||
'rc_cpu_speed_oper' => 'rc2kCpuEthernetPortOperSpeed',
|
||||
'rc_cpu_mac' => 'rc2kCpuEthernetPortMgmtMacAddr',
|
||||
# From RAPID-CITY::rcVlanPortTable
|
||||
'rc_i_vlan_if' => 'rcVlanPortIndex',
|
||||
'rc_i_vlan_num' => 'rcVlanPortNumVlanIds',
|
||||
'rc_i_vlan' => 'rcVlanPortVlanIds',
|
||||
'rc_i_vlan_type' => 'rcVlanPortType',
|
||||
'rc_i_vlan_pvid' => 'rcVlanPortDefaultVlanId',
|
||||
'rc_i_vlan_tag' => 'rcVlanPortPerformTagging',
|
||||
# From RAPID-CITY::rcVlanTable
|
||||
'rc_vlan_id' => 'rcVlanId',
|
||||
'rc_vlan_name' => 'rcVlanName',
|
||||
'rc_vlan_color' => 'rcVlanColor',
|
||||
'rc_vlan_if' => 'rcVlanIfIndex',
|
||||
'rc_vlan_stg' => 'rcVlanStgId',
|
||||
'rc_vlan_type' => 'rcVlanType',
|
||||
'rc_vlan_members' => 'rcVlanPortMembers',
|
||||
'rc_vlan_mac' => 'rcVlanMacAddress',
|
||||
# From RAPID-CITY::rcIpAddrTable
|
||||
'rc_ip_index' => 'rcIpAdEntIfIndex',
|
||||
'rc_ip_addr' => 'rcIpAdEntAddr',
|
||||
'rc_ip_type' => 'rcIpAdEntIfType',
|
||||
# From RAPID-CITY::rcChasFanTable
|
||||
'rc_fan_op' => 'rcChasFanOperStatus',
|
||||
# From RAPID-CITY::rcChasPowerSupplyTable
|
||||
'rc_ps_op' => 'rcChasPowerSupplyOperStatus',
|
||||
# From RAPID-CITY::rcChasPowerSupplyDetailTable
|
||||
'rc_ps_type' => 'rcChasPowerSupplyDetailType',
|
||||
'rc_ps_serial' => 'rcChasPowerSupplyDetailSerialNumber',
|
||||
'rc_ps_rev' => 'rcChasPowerSupplyDetailHardwareRevision',
|
||||
'rc_ps_part' => 'rcChasPowerSupplyDetailPartNumber',
|
||||
'rc_ps_detail' => 'rcChasPowerSupplyDetailDescription',
|
||||
# From RAPID-CITY::rcCardTable
|
||||
'rc_c_type' => 'rcCardType',
|
||||
'rc_c_serial' => 'rcCardSerialNumber',
|
||||
'rc_c_rev' => 'rcCardHardwareRevision',
|
||||
'rc_c_part' => 'rcCardPartNumber',
|
||||
# From RAPID-CITY::rc2kCardTable
|
||||
'rc2k_c_ftype' => 'rc2kCardFrontType',
|
||||
'rc2k_c_fdesc' => 'rc2kCardFrontDescription',
|
||||
'rc2k_c_fserial' => 'rc2kCardFrontSerialNum',
|
||||
'rc2k_c_frev' => 'rc2kCardFrontHwVersion',
|
||||
'rc2k_c_fpart' => 'rc2kCardFrontPartNumber',
|
||||
'rc2k_c_fdate' => 'rc2kCardFrontDateCode',
|
||||
'rc2k_c_fdev' => 'rc2kCardFrontDeviations',
|
||||
'rc2k_c_btype' => 'rc2kCardBackType',
|
||||
'rc2k_c_bdesc' => 'rc2kCardBackDescription',
|
||||
'rc2k_c_bserial' => 'rc2kCardBackSerialNum',
|
||||
'rc2k_c_brev' => 'rc2kCardBackHwVersion',
|
||||
'rc2k_c_bpart' => 'rc2kCardBackPartNumber',
|
||||
'rc2k_c_bdate' => 'rc2kCardBackDateCode',
|
||||
'rc2k_c_bdev' => 'rc2kCardBackDeviations',
|
||||
# From RAPID-CITY::rc2kMdaCardTable
|
||||
'rc2k_mda_type' => 'rc2kMdaCardType',
|
||||
'rc2k_mda_desc' => 'rc2kMdaCardDescription',
|
||||
'rc2k_mda_serial' => 'rc2kMdaCardSerialNum',
|
||||
'rc2k_mda_rev' => 'rc2kMdaCardHwVersion',
|
||||
'rc2k_mda_part' => 'rc2kMdaCardPartNumber',
|
||||
'rc2k_mda_date' => 'rc2kMdaCardDateCode',
|
||||
'rc2k_mda_dev' => 'rc2kMdaCardDeviations',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'rc_base_mac' => \&SNMP::Info::munge_mac,
|
||||
'rc_vlan_mac' => \&SNMP::Info::munge_mac,
|
||||
'rc_cpu_mac' => \&SNMP::Info::munge_mac,
|
||||
);
|
||||
|
||||
|
||||
sub i_duplex {
|
||||
my $rapidcity = shift;
|
||||
|
||||
my $interfaces = $rapidcity->interfaces();
|
||||
my $rc_index = $rapidcity->rc_index();
|
||||
my $rc_duplex = $rapidcity->rc_duplex();
|
||||
my $rc_cpu_duplex = $rapidcity->rc_cpu_duplex();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $duplex = $rc_duplex->{$if};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /half/i;
|
||||
$duplex = 'full' if $duplex =~ /full/i;
|
||||
$i_duplex{$if}=$duplex;
|
||||
}
|
||||
|
||||
# Get CPU Ethernet Interfaces for 8600 Series
|
||||
foreach my $iid (keys %$rc_cpu_duplex){
|
||||
my $c_duplex = $rc_cpu_duplex->{$iid};
|
||||
next unless defined $c_duplex;
|
||||
|
||||
$i_duplex{$iid} = $c_duplex;
|
||||
}
|
||||
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $rapidcity = shift;
|
||||
|
||||
my $interfaces = $rapidcity->interfaces();
|
||||
my $rc_index = $rapidcity->rc_index();
|
||||
my $rc_duplex_admin = $rapidcity->rc_duplex_admin();
|
||||
my $rc_auto = $rapidcity->rc_auto();
|
||||
my $rc_cpu_auto = $rapidcity->rc_cpu_auto();
|
||||
my $rc_cpu_duplex_admin = $rapidcity->rc_cpu_duplex_admin();
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $duplex = $rc_duplex_admin->{$if};
|
||||
next unless defined $duplex;
|
||||
my $auto = $rc_auto->{$if}||'false';
|
||||
|
||||
my $string = 'other';
|
||||
$string = 'half' if ($duplex =~ /half/i and $auto =~ /false/i);
|
||||
$string = 'full' if ($duplex =~ /full/i and $auto =~ /false/i);
|
||||
$string = 'auto' if $auto =~ /true/i;
|
||||
|
||||
$i_duplex_admin{$if}=$string;
|
||||
}
|
||||
|
||||
# Get CPU Ethernet Interfaces for 8600 Series
|
||||
foreach my $iid (keys %$rc_cpu_duplex_admin){
|
||||
my $c_duplex = $rc_cpu_duplex_admin->{$iid};
|
||||
next unless defined $c_duplex;
|
||||
my $c_auto = $rc_cpu_auto->{$iid};
|
||||
|
||||
my $string = 'other';
|
||||
$string = 'half' if ($c_duplex =~ /half/i and $c_auto =~ /false/i);
|
||||
$string = 'full' if ($c_duplex =~ /full/i and $c_auto =~ /false/i);
|
||||
$string = 'auto' if $c_auto =~ /true/i;
|
||||
|
||||
$i_duplex_admin{$iid} = $string;
|
||||
}
|
||||
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_vlan {
|
||||
my $rapidcity = shift;
|
||||
|
||||
my $rc_vlans = $rapidcity->rc_i_vlan();
|
||||
my $rc_vlan_id = $rapidcity->rc_vlan_id();
|
||||
my $rc_vlan_if = $rapidcity->rc_vlan_if();
|
||||
|
||||
my %i_vlan;
|
||||
foreach my $if (keys %$rc_vlans){
|
||||
my $rc_vlanid = $rc_vlans->{$if};
|
||||
next unless defined $rc_vlanid;
|
||||
my @vlanids = map { sprintf "%02x",$_ } unpack('C*',$rc_vlanid);
|
||||
|
||||
my @vlans = ();
|
||||
|
||||
while($#vlanids > 0) {
|
||||
my $h = join('', splice(@vlanids,0,2));
|
||||
push(@vlans, hex($h));
|
||||
}
|
||||
my $vlans = join (',', @vlans);
|
||||
$i_vlan{$if}=$vlans;
|
||||
}
|
||||
foreach my $if (keys %$rc_vlan_if){
|
||||
my $vlan_if = $rc_vlan_if->{$if};
|
||||
next unless defined $vlan_if;
|
||||
my $vlan = $rc_vlan_id->{$if};
|
||||
|
||||
$i_vlan{$vlan_if}=$vlan;
|
||||
}
|
||||
return \%i_vlan;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::Layer2::RapidCity - SNMP Interface to Nortel Networks' RapidCity MIB
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
# Let SNMP::Info determine the correct subclass for you.
|
||||
my $rapidcity = 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 = $rapidcity->class();
|
||||
print "SNMP::Info determined this device to fall under subclass : $class\n";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::RapidCity is a subclass of SNMP::Info that provides an interface
|
||||
to the C<RAPID-CITY> MIB. This MIB is used across the Nortel Networks' Passport
|
||||
LAN, as well as, the BayStack and Acclear families.
|
||||
|
||||
Use or create in a subclass of SNMP::Info. Do not use directly.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item RAPID-CITY
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status.
|
||||
|
||||
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
|
||||
Select by product, Java Device Manager, Software. Download the latest version.
|
||||
After installation, all mibs are located under the install directory under mibs
|
||||
and the repspective product line.
|
||||
|
||||
Note: Required version of RAPID-CITY, rapid_city.mib, must be from the Passport
|
||||
8600 version 3.3 or higher (located in JDM\mibs\passport8k\).
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->chassis_base_mac()
|
||||
|
||||
(B<rc2kChassisBaseMacAddr>)
|
||||
|
||||
=item $rapidcity->ch_serial()
|
||||
|
||||
(B<rcChasSerialNumber>)
|
||||
|
||||
=item $rapidcity->rc_ch_rev()
|
||||
|
||||
(B<rcChasHardwareRevision>)
|
||||
|
||||
=item $rapidcity->chassis()
|
||||
|
||||
(B<rcChasType>)
|
||||
|
||||
=item $rapidcity->slots()
|
||||
|
||||
(B<rcChasNumSlots>)
|
||||
|
||||
=item $rapidcity->rc_virt_ip()
|
||||
|
||||
(B<rcSysVirtualIpAddr>)
|
||||
|
||||
=item $rapidcity->tftp_host()
|
||||
|
||||
(B<rcTftpHost>)
|
||||
|
||||
=item $rapidcity->tftp_file()
|
||||
|
||||
(B<rcTftpFile>)
|
||||
|
||||
=item $rapidcity->tftp_action()
|
||||
|
||||
(B<rcTftpAction>)
|
||||
|
||||
=item $rapidcity->tftp_result()
|
||||
|
||||
(B<rcTftpResult>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->i_duplex()
|
||||
|
||||
Returns reference to map of IIDs to current link duplex.
|
||||
|
||||
=item $rapidcity->i_duplex_admin()
|
||||
|
||||
Returns reference to hash of IIDs to admin duplex setting.
|
||||
|
||||
=item $rapidcity->i_vlan()
|
||||
|
||||
Returns a mapping between ifIndex and the VLAN.
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY Port Table (B<rcPortTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_index()
|
||||
|
||||
(B<rcPortIndex>)
|
||||
|
||||
=item $rapidcity->rc_duplex()
|
||||
|
||||
(B<rcPortOperDuplex>)
|
||||
|
||||
=item $rapidcity->rc_duplex_admin()
|
||||
|
||||
(B<rcPortAdminDuplex>)
|
||||
|
||||
=item $rapidcity->rc_speed_admin()
|
||||
|
||||
(B<rcPortAdminSpeed>)
|
||||
|
||||
=item $rapidcity->rc_auto()
|
||||
|
||||
(B<rcPortAutoNegotiate>)
|
||||
|
||||
=item $rapidcity->rc_alias()
|
||||
|
||||
(B<rcPortName>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY CPU Ethernet Port Table (B<rc2kCpuEthernetPortTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_cpu_ifindex()
|
||||
|
||||
(B<rc2kCpuEthernetPortIfIndex>)
|
||||
|
||||
=item $rapidcity->rc_cpu_admin()
|
||||
|
||||
(B<rc2kCpuEthernetPortAdminStatus>)
|
||||
|
||||
=item $rapidcity->rc_cpu_oper()
|
||||
|
||||
(B<rc2kCpuEthernetPortOperStatus>)
|
||||
|
||||
=item $rapidcity->rc_cpu_ip()
|
||||
|
||||
(B<rc2kCpuEthernetPortAddr>)
|
||||
|
||||
=item $rapidcity->rc_cpu_auto()
|
||||
|
||||
(B<rc2kCpuEthernetPortAutoNegotiate>)
|
||||
|
||||
=item $rapidcity->rc_cpu_duplex_admin()
|
||||
|
||||
(B<rc2kCpuEthernetPortAdminDuplex>)
|
||||
|
||||
=item $rapidcity->rc_cpu_duplex()
|
||||
|
||||
(B<rc2kCpuEthernetPortOperDuplex>)
|
||||
|
||||
=item $rapidcity->rc_cpu_speed_admin()
|
||||
|
||||
(B<rc2kCpuEthernetPortAdminSpeed>)
|
||||
|
||||
=item $rapidcity->rc_cpu_speed_oper()
|
||||
|
||||
(B<rc2kCpuEthernetPortOperSpeed>)
|
||||
|
||||
=item $rapidcity->rc_cpu_mac()
|
||||
|
||||
(B<rc2kCpuEthernetPortMgmtMacAddr>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY VLAN Port Table (B<rcVlanPortTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_i_vlan_if()
|
||||
|
||||
(B<rcVlanPortIndex>)
|
||||
|
||||
=item $rapidcity->rc_i_vlan_num()
|
||||
|
||||
(B<rcVlanPortNumVlanIds>)
|
||||
|
||||
=item $rapidcity->rc_i_vlan()
|
||||
|
||||
(B<rcVlanPortVlanIds>)
|
||||
|
||||
=item $rapidcity->rc_i_vlan_type()
|
||||
|
||||
(B<rcVlanPortType>)
|
||||
|
||||
=item $rapidcity->rc_i_vlan_pvid()
|
||||
|
||||
(B<rcVlanPortDefaultVlanId>)
|
||||
|
||||
=item $rapidcity->rc_i_vlan_tag()
|
||||
|
||||
(B<rcVlanPortPerformTagging>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY VLAN Table (B<rcVlanTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_vlan_id()
|
||||
|
||||
(B<rcVlanId>)
|
||||
|
||||
=item $rapidcity->rc_vlan_name()
|
||||
|
||||
(B<rcVlanName>)
|
||||
|
||||
=item $rapidcity->rc_vlan_color()
|
||||
|
||||
(B<rcVlanColor>)
|
||||
|
||||
=item $rapidcity->rc_vlan_if()
|
||||
|
||||
(B<rcVlanIfIndex>)
|
||||
|
||||
=item $rapidcity->rc_vlan_stg()
|
||||
|
||||
(B<rcVlanStgId>)
|
||||
|
||||
=item $rapidcity->rc_vlan_type()
|
||||
|
||||
(B<rcVlanType>)
|
||||
|
||||
=item $rapidcity->rc_vlan_members()
|
||||
|
||||
(B<rcVlanPortMembers>)
|
||||
|
||||
=item $rapidcity->rc_vlan_mac()
|
||||
|
||||
(B<rcVlanMacAddress>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY IP Address Table (B<rcIpAddrTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_ip_index()
|
||||
|
||||
(B<rcIpAdEntIfIndex>)
|
||||
|
||||
=item $rapidcity->rc_ip_addr()
|
||||
|
||||
(B<rcIpAdEntAddr>)
|
||||
|
||||
=item $rapidcity->rc_ip_type()
|
||||
|
||||
(B<rcIpAdEntIfType>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY Chassis Fan Table (B<rcChasFanTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_fan_op()
|
||||
|
||||
(B<rcChasFanOperStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY Power Supply Table (B<rcChasPowerSupplyTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_ps_op()
|
||||
|
||||
(B<rcChasPowerSupplyOperStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY Power Supply Detail Table (B<rcChasPowerSupplyDetailTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_ps_type()
|
||||
|
||||
(B<rcChasPowerSupplyDetailType>)
|
||||
|
||||
=item $rapidcity->rc_ps_serial()
|
||||
|
||||
(B<rcChasPowerSupplyDetailSerialNumber>)
|
||||
|
||||
=item $rapidcity->rc_ps_rev()
|
||||
|
||||
(B<rcChasPowerSupplyDetailHardwareRevision>)
|
||||
|
||||
=item $rapidcity->rc_ps_part()
|
||||
|
||||
(B<rcChasPowerSupplyDetailPartNumber>)
|
||||
|
||||
=item $rapidcity->rc_ps_detail()
|
||||
|
||||
(B<rcChasPowerSupplyDetailDescription>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY Card Table (B<rcCardTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc_c_type()
|
||||
|
||||
(B<rcCardType>)
|
||||
|
||||
=item $rapidcity->rc_c_serial()
|
||||
|
||||
(B<rcCardSerialNumber>)
|
||||
|
||||
=item $rapidcity->rc_c_rev()
|
||||
|
||||
(B<rcCardHardwareRevision>)
|
||||
|
||||
=item $rapidcity->rc_c_part()
|
||||
|
||||
(B<rcCardPartNumber>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY 2k Card Table (B<rc2kCardTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc2k_c_ftype()
|
||||
|
||||
(B<rc2kCardFrontType>)
|
||||
|
||||
=item $rapidcity->rc2k_c_fdesc()
|
||||
|
||||
(B<rc2kCardFrontDescription>)
|
||||
|
||||
=item $rapidcity->rc2k_c_fserial()
|
||||
|
||||
(B<rc2kCardFrontSerialNum>)
|
||||
|
||||
=item $rapidcity->rc2k_c_frev()
|
||||
|
||||
(B<rc2kCardFrontHwVersion>)
|
||||
|
||||
=item $rapidcity->rc2k_c_fpart()
|
||||
|
||||
(B<rc2kCardFrontPartNumber>)
|
||||
|
||||
=item $rapidcity->rc2k_c_fdate()
|
||||
|
||||
(B<rc2kCardFrontDateCode>)
|
||||
|
||||
=item $rapidcity->rc2k_c_fdev()
|
||||
|
||||
(B<rc2kCardFrontDeviations>)
|
||||
|
||||
=item $rapidcity->rc2k_c_btype()
|
||||
|
||||
(B<rc2kCardBackType>)
|
||||
|
||||
=item $rapidcity->rc2k_c_bdesc()
|
||||
|
||||
(B<rc2kCardBackDescription>)
|
||||
|
||||
=item $rapidcity->rc2k_c_bserial()
|
||||
|
||||
(B<rc2kCardBackSerialNum>)
|
||||
|
||||
=item $rapidcity->rc2k_c_brev()
|
||||
|
||||
(B<rc2kCardBackHwVersion>)
|
||||
|
||||
=item $rapidcity->rc2k_c_bpart()
|
||||
|
||||
(B<rc2kCardBackPartNumber>)
|
||||
|
||||
=item $rapidcity->rc2k_c_bdate()
|
||||
|
||||
(B<rc2kCardBackDateCode>)
|
||||
|
||||
=item $rapidcity->rc2k_c_bdev()
|
||||
|
||||
(B<rc2kCardBackDeviations>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 RAPID-CITY MDA Card Table (B<rc2kMdaCardTable>)
|
||||
|
||||
=over
|
||||
|
||||
=item $rapidcity->rc2k_mda_type()
|
||||
|
||||
(B<rc2kMdaCardType>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_desc()
|
||||
|
||||
(B<rc2kMdaCardDescription>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_serial()
|
||||
|
||||
(B<rc2kMdaCardSerialNum>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_rev()
|
||||
|
||||
(B<rc2kMdaCardHwVersion>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_part()
|
||||
|
||||
(B<rc2kMdaCardPartNumber>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_date()
|
||||
|
||||
(B<rc2kMdaCardDateCode>)
|
||||
|
||||
=item $rapidcity->rc2k_mda_dev()
|
||||
|
||||
(B<rc2kMdaCardDeviations>)
|
||||
|
||||
=cut
|
||||
506
Info/SONMP.pm
Normal file
506
Info/SONMP.pm
Normal file
@@ -0,0 +1,506 @@
|
||||
# SNMP::Info::SONMP
|
||||
# Eric Miller <eric@jeneric.org>
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (c) 2004 Max Baker
|
||||
#
|
||||
# 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::SONMP;
|
||||
$VERSION = 0.9;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info;
|
||||
use Carp;
|
||||
|
||||
@SNMP::Info::SONMP::ISA = qw/SNMP::Info Exporter/;
|
||||
@SNMP::Info::SONMP::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %FUNCS %GLOBALS %MIBS %MUNGE $INIT/;
|
||||
# Debug
|
||||
$DEBUG=0;
|
||||
$SNMP::debugging=$DEBUG;
|
||||
|
||||
# Five data structures required by SNMP::Info
|
||||
$INIT = 0;
|
||||
|
||||
%MIBS = (
|
||||
'SYNOPTICS-ROOT-MIB' => 'synoptics',
|
||||
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop',
|
||||
);
|
||||
|
||||
%GLOBALS = (
|
||||
'cdp_id' => 's5EnMsTopIpAddr',
|
||||
'cdp_run' => 's5EnMsTopStatus',
|
||||
);
|
||||
|
||||
%FUNCS = (
|
||||
# From S5-ETH-MULTISEG-TOPOLOGY-MIB::TopNmmTable
|
||||
'sonmp_topo_slot' => 's5EnMsTopNmmSlot',
|
||||
'sonmp_topo_port' => 's5EnMsTopNmmPort',
|
||||
'sonmp_topo_ip' => 's5EnMsTopNmmIpAddr',
|
||||
'sonmp_topo_seg' => 's5EnMsTopNmmSegId',
|
||||
'sonmp_topo_mac' => 's5EnMsTopNmmMacAddr',
|
||||
'sonmp_topo_platform' => 's5EnMsTopNmmChassisType',
|
||||
'sonmp_topo_localseg' => 's5EnMsTopNmmLocalSeg',
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
'sonmp_topo_mac' => \&SNMP::Info::munge_mac
|
||||
);
|
||||
|
||||
sub index_factor {
|
||||
return 32;
|
||||
}
|
||||
|
||||
sub slot_offset {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub port_offset {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub hasCDP {
|
||||
my $sonmp = shift;
|
||||
return $sonmp->cdp_run();
|
||||
}
|
||||
|
||||
|
||||
sub c_if {
|
||||
my $sonmp = shift;
|
||||
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
|
||||
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
|
||||
my $index_factor = $sonmp->index_factor();
|
||||
my $slot_offset = $sonmp->slot_offset();
|
||||
my $port_offset = $sonmp->port_offset();
|
||||
my $model = $sonmp->model();
|
||||
|
||||
my %c_if;
|
||||
foreach my $entry (keys %$sonmp_topo_port){
|
||||
my $port = $sonmp_topo_port->{$entry};
|
||||
next unless defined $port;
|
||||
next if $port == 0;
|
||||
my $slot = $sonmp_topo_slot->{$entry}||0;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $slot;
|
||||
if (! ($comidx % 5)) {
|
||||
$slot = ($slot / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset);
|
||||
|
||||
$c_if{"$index.1"} = $index;
|
||||
}
|
||||
return \%c_if;
|
||||
}
|
||||
|
||||
sub c_ip {
|
||||
my $sonmp = shift;
|
||||
my $sonmp_topo_ip = $sonmp->sonmp_topo_ip();
|
||||
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
|
||||
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
|
||||
my $ip = $sonmp->cdp_id();
|
||||
my $index_factor = $sonmp->index_factor();
|
||||
my $slot_offset = $sonmp->slot_offset();
|
||||
my $port_offset = $sonmp->port_offset();
|
||||
my $model = $sonmp->model();
|
||||
|
||||
|
||||
# Count the number of devices seen on each port.
|
||||
# more than one device seen means connected to a non-sonmp
|
||||
# device, but other sonmp devices are squawking further away.
|
||||
my %ip_port;
|
||||
foreach my $entry (keys %$sonmp_topo_ip){
|
||||
my $port = $sonmp_topo_port->{$entry};
|
||||
next unless defined $port;
|
||||
next if ($port =~ /^[\d\.]+$/ and $port == 0);
|
||||
my $slot = $sonmp_topo_slot->{$entry}||0;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $slot;
|
||||
if (! ($comidx % 5)) {
|
||||
$slot = ($slot / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset);
|
||||
|
||||
my $ip = $sonmp_topo_ip->{$entry};
|
||||
push(@{$ip_port{$index}},$ip);
|
||||
}
|
||||
|
||||
my %c_ip;
|
||||
foreach my $port (keys %ip_port){
|
||||
my $ips = $ip_port{$port};
|
||||
if (scalar @$ips == 1) {
|
||||
$c_ip{"$port.1"} = $ips->[0];
|
||||
} else {
|
||||
$c_ip{"$port.1"} = $ips;
|
||||
}
|
||||
}
|
||||
return \%c_ip;
|
||||
}
|
||||
|
||||
sub c_port {
|
||||
my $sonmp = shift;
|
||||
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
|
||||
my $sonmp_topo_seg = $sonmp->sonmp_topo_seg();
|
||||
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
|
||||
my $index_factor = $sonmp->index_factor();
|
||||
my $slot_offset = $sonmp->slot_offset();
|
||||
my $port_offset = $sonmp->port_offset();
|
||||
my $model = $sonmp->model();
|
||||
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform();
|
||||
|
||||
my %c_port;
|
||||
foreach my $entry (keys %$sonmp_topo_seg){
|
||||
my $port = $sonmp_topo_port->{$entry};
|
||||
next unless defined $port;
|
||||
next if $port == 0;
|
||||
my $slot = $sonmp_topo_slot->{$entry};
|
||||
$slot = 0 unless defined $slot;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $slot;
|
||||
if (! ($comidx % 5)) {
|
||||
$slot = ($slot / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset);
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
next if defined $c_port{"$index.1"};
|
||||
|
||||
my $seg = $sonmp_topo_seg->{$entry};
|
||||
my $platform = $sonmp_topo_platform->{$entry};
|
||||
# AP-222x Series does not adhere to port numbering
|
||||
if ($platform =~ /AccessPoint/i) {
|
||||
$c_port{"$index.1"} = 'dp0';
|
||||
}
|
||||
# BayHubs send the lower three bytes of the MAC not the slot/port
|
||||
elsif ($seg > 4000) {
|
||||
$c_port{"$index.1"} = 'unknown';
|
||||
}
|
||||
else {
|
||||
# Segment id is (256 * remote slot_num) + (remote_port)
|
||||
my $remote_port = $seg % 256;
|
||||
my $remote_slot = int($seg / 256);
|
||||
|
||||
$c_port{"$index.1"} = "$remote_slot.$remote_port";
|
||||
}
|
||||
}
|
||||
return \%c_port;
|
||||
}
|
||||
|
||||
sub c_platform {
|
||||
my $sonmp = shift;
|
||||
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
|
||||
my $sonmp_topo_slot = $sonmp->sonmp_topo_slot();
|
||||
my $sonmp_topo_platform = $sonmp->sonmp_topo_platform();
|
||||
my $index_factor = $sonmp->index_factor();
|
||||
my $slot_offset = $sonmp->slot_offset();
|
||||
my $port_offset = $sonmp->port_offset();
|
||||
my $model = $sonmp->model();
|
||||
|
||||
my %c_platform;
|
||||
foreach my $entry (keys %$sonmp_topo_platform){
|
||||
my $port = $sonmp_topo_port->{$entry}||0;
|
||||
next if $port == 0;
|
||||
my $slot = $sonmp_topo_slot->{$entry};
|
||||
$slot = 0 unless defined $slot;
|
||||
|
||||
if ($model eq 'Baystack Hub') {
|
||||
my $comidx = $slot;
|
||||
if (! ($comidx % 5)) {
|
||||
$slot = ($slot / 5);
|
||||
} elsif ($comidx =~ /[16]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 25;
|
||||
} elsif ($comidx =~ /[27]$/) {
|
||||
$slot = int($slot/5);
|
||||
$port = 26;
|
||||
}
|
||||
}
|
||||
|
||||
my $index = (($slot-$slot_offset)*$index_factor) + ($port-$port_offset);
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
next if defined $c_platform{"$index.1"};
|
||||
|
||||
my $platform = $sonmp_topo_platform->{$entry};
|
||||
|
||||
$c_platform{"$index.1"} = $platform;
|
||||
}
|
||||
return \%c_platform;
|
||||
}
|
||||
|
||||
sub mac {
|
||||
my $sonmp = shift;
|
||||
my $sonmp_topo_port = $sonmp->sonmp_topo_port();
|
||||
my $sonmp_topo_mac = $sonmp->sonmp_topo_mac();
|
||||
|
||||
foreach my $entry (keys %$sonmp_topo_port){
|
||||
my $port = $sonmp_topo_port->{$entry};
|
||||
next unless $port == 0;
|
||||
my $mac = $sonmp_topo_mac->{$entry};
|
||||
return $mac;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
SNMP::Info::SONMP - Perl5 Interface to SynOptics Network Management Protocol (SONMP) using SNMP
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>),
|
||||
Eric Miller (C<eric@jeneric.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $sonmp = new SNMP::Info (
|
||||
AutoSpecify => 1,
|
||||
Debug => 1,
|
||||
DestHost => 'router',
|
||||
Community => 'public',
|
||||
Version => 2
|
||||
);
|
||||
|
||||
my $class = $sonmp->class();
|
||||
print " Using device sub class : $class\n";
|
||||
|
||||
$hascdp = $sonmp->hasCDP() ? 'yes' : 'no';
|
||||
|
||||
# Print out a map of device ports with CDP neighbors:
|
||||
my $interfaces = $sonmp->interfaces();
|
||||
my $c_if = $sonmp->c_if();
|
||||
my $c_ip = $sonmp->c_ip();
|
||||
my $c_port = $sonmp->c_port();
|
||||
|
||||
foreach my $cdp_key (keys %$c_ip){
|
||||
my $iid = $c_if->{$cdp_key};
|
||||
my $port = $interfaces->{$iid};
|
||||
my $neighbor = $c_ip->{$cdp_key};
|
||||
my $neighbor_port = $c_port->{$cdp_key};
|
||||
print "Port : $port connected to $neighbor / $neighbor_port\n";
|
||||
}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
SNMP::Info::SONMP is a subclass of SNMP::Info that provides an object oriented
|
||||
interface to the SynOptics Network Management Protocol (SONMP) information
|
||||
through SNMP.
|
||||
|
||||
SONMP is a Layer 2 protocol that supplies topology information of devices that also speak SONMP,
|
||||
mostly switches and hubs. SONMP is implemented in SynOptics, Bay, and Nortel Networks devices.
|
||||
SONMP has been rebranded by Bay then Nortel Networks and is know by several different
|
||||
names.
|
||||
|
||||
Create or use a device subclass that inherits this class. Do not use directly.
|
||||
|
||||
Each device implements a subset of the global and cache entries.
|
||||
Check the return value to see if that data is held by the device.
|
||||
|
||||
=head2 Inherited Classes
|
||||
|
||||
None.
|
||||
|
||||
=head2 Required MIBs
|
||||
|
||||
=over
|
||||
|
||||
=item SYNOPTICS-ROOT-MIB
|
||||
|
||||
=item S5-ETH-MULTISEG-TOPOLOGY-MIB
|
||||
|
||||
=back
|
||||
|
||||
MIBs can be found on the CD that came with your product.
|
||||
|
||||
Or, they can be downloaded directly from Nortel Networks regardless of support
|
||||
contract status.
|
||||
|
||||
Go to http://www.nortelnetworks.com Techninal Support, Browse Technical Support,
|
||||
Select by product, Java Device Manager, Software. Download the latest version.
|
||||
After installation, all mibs are located under the install directory under mibs
|
||||
and the repspective product line.
|
||||
|
||||
Note: Required version of SYNOPTICS-ROOT-MIB, must be version 199 or higher,
|
||||
for example synro199.mib.
|
||||
|
||||
=head1 GLOBAL METHODS
|
||||
|
||||
These are methods that return scalar values from SNMP
|
||||
|
||||
=over
|
||||
|
||||
=item $sonmp->index_factor()
|
||||
|
||||
Returns a number representing the number of ports reserved per slot or switch
|
||||
within the device MIB. Defaults to 32.
|
||||
|
||||
=item $sonmp->slot_offset()
|
||||
|
||||
Returns the offset if slot numbering does not start at 0. Defaults to 1.
|
||||
|
||||
=item $sonmp->port_offset()
|
||||
|
||||
Returns the offset if port numbering does not start at 0. Defaults to 0.
|
||||
|
||||
=item $cdp->hasCDP()
|
||||
|
||||
Is CDP is active in this device?
|
||||
|
||||
=item $sonmp->cdp_id()
|
||||
|
||||
Returns the IP that the device is sending out for its Nmm topology info.
|
||||
|
||||
(B<s5EnMsTopIpAddr>)
|
||||
|
||||
=item $sonmp->cdp_run()
|
||||
|
||||
Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
|
||||
|
||||
(B<s5EnMsTopStatus>)
|
||||
|
||||
=item $sonmp->mac()
|
||||
|
||||
Returns MAC of the advertised IP address of the device.
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE METHODS
|
||||
|
||||
These are methods that return tables of information in the form of a reference
|
||||
to a hash.
|
||||
|
||||
=head2 Layer2 Topology info (s5EnMsTopNmmTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $sonmp->sonmp_topo_slot()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:slot number
|
||||
|
||||
(B<s5EnMsTopNmmSlot>)
|
||||
|
||||
=item $sonmp->sonmp_topo_port()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Port Number (interface iid)
|
||||
|
||||
(B<s5EnMsTopNmmPort>)
|
||||
|
||||
=item $sonmp->sonmp_topo_ip()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote IP address of entry
|
||||
|
||||
(B<s5EnMsTopNmmIpAddr>)
|
||||
|
||||
=item $sonmp->sonmp_topo_seg()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote Segment ID
|
||||
|
||||
(B<s5EnMsTopNmmSegId>)
|
||||
|
||||
=item $sonmp->sonmp_topo_mac
|
||||
|
||||
(B<s5EnMsTopNmmMacAddr>)
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote MAC address
|
||||
|
||||
=item $sonmp->sonmp_topo_platform
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote Device Type
|
||||
|
||||
(B<s5EnMsTopNmmChassisType>)
|
||||
|
||||
=item $sonmp->sonmp_topo_localseg
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() is local
|
||||
|
||||
(B<s5EnMsTopNmmLocalSeg>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Psuedo CDP information
|
||||
|
||||
All entries with port=0 are local and ignored.
|
||||
|
||||
=over
|
||||
|
||||
=item $sonmp->c_if()
|
||||
|
||||
Returns reference to hash. Key: ifIndex.1 Value: port (iid)
|
||||
|
||||
=item $sonmp->c_ip()
|
||||
|
||||
Returns referenece to hash. Key: ifIndex.1
|
||||
|
||||
The value of each hash entry can either be a scalar or an array.
|
||||
A scalar value is most likely a direct neighbor to that port.
|
||||
It is possible that there is a non-SONMP device in between this device and the remote device.
|
||||
|
||||
An array value represents a list of seen devices. The only time you will get an array
|
||||
of neighbors, is if there is a non-SONMP device in between two or more devices.
|
||||
|
||||
Use the data from the Layer2 Topology Table below to dig deeper.
|
||||
|
||||
=item $sonmp->c_port()
|
||||
|
||||
Returns reference to hash. Key: ifIndex.1 Value: remote port
|
||||
|
||||
=item $sonmp->c_platform()
|
||||
|
||||
Returns reference to hash. Key: ifIndex.1 Value: Remote Device Type
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
34
MANIFEST
34
MANIFEST
@@ -1,24 +1,52 @@
|
||||
ChangeLog
|
||||
COPYRIGHT
|
||||
ChangeLog
|
||||
DeviceMatrix.txt
|
||||
Info.pm
|
||||
Info/Bridge.pm
|
||||
Info/CDP.pm
|
||||
Info/CiscoStack.pm
|
||||
Info/CiscoStats.pm
|
||||
Info/CiscoVTP.pm
|
||||
Info/Entity.pm
|
||||
Info/EtherLike.pm
|
||||
Info/FDP.pm
|
||||
Info/Layer1.pm
|
||||
Info/Layer1/Allied.pm
|
||||
Info/Layer1/Asante.pm
|
||||
Info/Layer1/Bayhub.pm
|
||||
Info/Layer2.pm
|
||||
Info/Layer2/Aironet.pm
|
||||
Info/Layer2/Allied.pm
|
||||
Info/Layer2/Bay.pm
|
||||
Info/Layer2/Baystack.pm
|
||||
Info/Layer2/C1900.pm
|
||||
Info/Layer2/C2900.pm
|
||||
Info/Layer2/Catalyst.pm
|
||||
Info/Layer2/Centillion.pm
|
||||
Info/Layer2/HP.pm
|
||||
Info/Layer2/NAP222x.pm
|
||||
Info/Layer2/Orinoco.pm
|
||||
Info/Layer2/ZyXEL_DSLAM.pm
|
||||
Info/Layer3.pm
|
||||
Info/Layer3/Aironet.pm
|
||||
Info/Layer3/Foundry.pm
|
||||
Info/Layer3/AlteonAD.pm
|
||||
Info/Layer3/BayRS.pm
|
||||
Info/Layer3/C3550.pm
|
||||
Info/Layer3/C6500.pm
|
||||
Info/Layer3/Cisco.pm
|
||||
Info/Layer3/Contivity.pm
|
||||
Info/Layer3/Foundry.pm
|
||||
Info/Layer3/Passport.pm
|
||||
Info/MAU.pm
|
||||
Info/NortelStack.pm
|
||||
Info/RapidCity.pm
|
||||
Info/SONMP.pm
|
||||
MANIFEST
|
||||
Makefile.PL
|
||||
README
|
||||
test.pl
|
||||
t/DeviceMatrix.html
|
||||
t/DeviceMatrix.png
|
||||
t/lucon.ttf
|
||||
t/make_dev_matrix.pl
|
||||
t/prereq.t
|
||||
t/test_class.pl
|
||||
|
||||
10
Makefile.PL
10
Makefile.PL
@@ -5,7 +5,12 @@ use ExtUtils::MakeMaker;
|
||||
WriteMakefile(
|
||||
'NAME' => 'SNMP::Info',
|
||||
'VERSION_FROM' => 'Info.pm',
|
||||
'PREREQ_PM' => {'SNMP' => '4'},
|
||||
'PREREQ_PM' => {
|
||||
'Math::BigInt' => 0
|
||||
# SNMP not available on CPAN .
|
||||
# Install with net-snmp.sourceforge.net
|
||||
# 'SNMP' => '4'
|
||||
},
|
||||
($] >= 5.005 ?
|
||||
(ABSTRACT_FROM => 'Info.pm',
|
||||
AUTHOR => 'Max Baker <max@warped.org>')
|
||||
@@ -16,5 +21,6 @@ WriteMakefile(
|
||||
|
||||
sub MY::postamble { "
|
||||
.PHONY: readme
|
||||
readme:
|
||||
readme: README
|
||||
README: Info.pm
|
||||
pod2text -l Info.pm > README" }
|
||||
|
||||
321
t/make_dev_matrix.pl
Executable file
321
t/make_dev_matrix.pl
Executable file
@@ -0,0 +1,321 @@
|
||||
#!/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 ($@) {
|
||||
print "GraphViz::Data::Structure not installed. $@\n";
|
||||
} else {
|
||||
my %graph = ();
|
||||
foreach my $vendor (sort sort_nocase keys %$matrix){
|
||||
$graph{$vendor} = {};
|
||||
foreach my $family (sort sort_nocase keys %{$matrix->{$vendor}->{families}} ){
|
||||
my @models;
|
||||
foreach my $mod (keys %{$matrix->{$vendor}->{families}->{$family}->{models}}){
|
||||
push(@models,split(/\s*,\s*/,$mod));
|
||||
}
|
||||
if (scalar @models){
|
||||
$graph{$vendor}->{$family}=\@models;
|
||||
} else {
|
||||
$graph{$vendor}->{$family}=[];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
my $now = scalar localtime;
|
||||
my $gvds = GraphViz::Data::Structure->new(\%graph,Orientation=>'vertical',
|
||||
Colors=> 'Deep',
|
||||
graph => {label=>"SNMP::Info and Netdisco Supported Devices \n $now",'fontpath'=>'/usr/local/netdisco','fontname'=>'lucon',concentrate=>'true','overlap'=>'false',spline=>'true',bgcolor=>'wheat'},
|
||||
node => {fontname=>'lucon'},
|
||||
);
|
||||
$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 %ignore = map { $_ => 1 } @_;
|
||||
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;
|
||||
}
|
||||
|
||||
if (exists $ignore{$cmd}){
|
||||
print "Ignoring $cmd\n";
|
||||
}
|
||||
# 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>
|
||||
A value of <B>-</B> signifies the information is not specified and can
|
||||
be assumed working.
|
||||
<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";
|
||||
}
|
||||
81
t/prereq.t
Executable file
81
t/prereq.t
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/local/bin/perl -w
|
||||
# prereq.t - Test file for prerequesites for SNMP::Info
|
||||
# $Id$
|
||||
|
||||
use Test::More tests=> 3;
|
||||
|
||||
# Check for SNMP Module
|
||||
my $have_snmp=0;
|
||||
|
||||
eval {
|
||||
require SNMP;
|
||||
};
|
||||
|
||||
if ($@){
|
||||
print STDERR <<'end_snmp';
|
||||
|
||||
Net-SNMP not found. Net-SNMP installs the perl modules
|
||||
SNMP and SNMP::Session. As of version 4.2.1 and greater the Perl
|
||||
modules are no longer distributed on CPAN, as they are specific to different
|
||||
versions of SNMP.
|
||||
|
||||
Install Net-SNMP from http://net-snmp.sourceforge.net and make sure you run
|
||||
configure with the --with-perl-modules switch!
|
||||
|
||||
Note to Redhat Users: Redhat, in its infinite wisdom, does not install the
|
||||
Perl modules as part of their 8.0 RPMS. Please uninstall them and install the
|
||||
newest version by hand.
|
||||
|
||||
|
||||
|
||||
end_snmp
|
||||
ok(0,'Net-SNMP not installed, or missing Perl modules.');
|
||||
} else {
|
||||
$have_snmp=1;
|
||||
ok(1,'Net-SNMP installed');
|
||||
}
|
||||
|
||||
# Check for version
|
||||
SKIP: {
|
||||
skip('SNMP not installed, no further testing',2) unless $have_snmp;
|
||||
|
||||
my $VERSION = $SNMP::VERSION;
|
||||
ok(defined $VERSION ? 1 : 1, "found version for SNMP");
|
||||
|
||||
my ($ver_maj,$ver_min,$ver_rev) = split(/\./,$VERSION);
|
||||
|
||||
ok ($ver_maj >= 4, 'Net-SNMP ver 4 or higher');
|
||||
|
||||
if ($ver_maj == 4 and $ver_min == 2 and $ver_rev == 0){
|
||||
print STDERR << "end_420";
|
||||
|
||||
SNMP module version 4.2.0 found. Please triple check that you have
|
||||
version 4.2.0 of Net-SNMP installed, and that you did not accidently install
|
||||
the SNMP module found on CPAN. All newer versions are bundled with
|
||||
Net-SNMP, and are not available on CPAN. Please find them at
|
||||
http://net-snmp.sourceforge.net . Make sure you run configure with the
|
||||
--with-perl-modules switch.
|
||||
|
||||
end_420
|
||||
}
|
||||
|
||||
if( $ver_maj == 5 and $ver_min == 0 and $ver_rev == 1 ){
|
||||
print STDERR << "end_501";
|
||||
|
||||
|
||||
Perl module of Net-SNMP 5.0.1 is buggy. Please upgrade.
|
||||
|
||||
|
||||
end_501
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print STDERR << "end_mibs";
|
||||
|
||||
|
||||
Make sure you download and install the MIBS needed for SNMP::Info.
|
||||
See Man page or perldoc for SNMP::Info.
|
||||
|
||||
end_mibs
|
||||
# vim:syntax=perl
|
||||
160
t/test_class.pl
Executable file
160
t/test_class.pl
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/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 @Dump/;
|
||||
|
||||
# Default Values
|
||||
$Class = '';
|
||||
$Dev = '';
|
||||
$Comm = '';
|
||||
$Ver = 2;
|
||||
@Dump = ();
|
||||
|
||||
GetOptions ('c|class=s' => \$Class,
|
||||
'd|dev=s' => \$Dev,
|
||||
's|comm=s' => \$Comm,
|
||||
'v|ver=i' => \$Ver,
|
||||
'h|help' => \&usage,
|
||||
'p|print=s' => \@Dump,
|
||||
);
|
||||
|
||||
&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";
|
||||
|
||||
print "Dumping : ",join(',',@Dump),"\n" if scalar @Dump;
|
||||
|
||||
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){
|
||||
die "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
|
||||
i_lastchange/;
|
||||
|
||||
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);
|
||||
if (grep(/^$method$/,@Dump)) {
|
||||
foreach my $iid (keys %$results){
|
||||
print " $iid : $results->{$iid}\n";
|
||||
}
|
||||
}
|
||||
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
|
||||
-p --print i_blah
|
||||
-p --print i_blah2
|
||||
|
||||
end_usage
|
||||
exit;
|
||||
}
|
||||
18
test.pl
18
test.pl
@@ -1,18 +0,0 @@
|
||||
# SNMP::Info - test.pl
|
||||
# $Id$
|
||||
#
|
||||
# Before `make install' is performed this script should be runnable with
|
||||
# `make test'. After `make install' it should work as `perl test.pl'
|
||||
#
|
||||
|
||||
use Test;
|
||||
BEGIN { plan tests => 1 };
|
||||
|
||||
use SNMP::Info;
|
||||
ok(1);
|
||||
|
||||
# If we made it this far, we're ok.
|
||||
#########################
|
||||
|
||||
# No tests yet.
|
||||
print "No test's implemented yet. \n";
|
||||
Reference in New Issue
Block a user