Initial Import. Ver 0.1
This commit is contained in:
428
Info/Layer2/Bay.pm
Normal file
428
Info/Layer2/Bay.pm
Normal file
@@ -0,0 +1,428 @@
|
||||
#
|
||||
# Copyright (c) 2002, 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.
|
||||
# SNMP::Info::Layer2::Bay
|
||||
# Max Baker <max@warped.org>
|
||||
|
||||
package SNMP::Info::Layer2::Bay;
|
||||
$VERSION = 0.1;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
|
||||
@SNMP::Info::Layer2::Bay::ISA = qw/SNMP::Info::Layer2 Exporter/;
|
||||
@SNMP::Info::Layer2::Bay::EXPORT_OK = qw//;
|
||||
|
||||
use vars qw/$VERSION %FUNCS %GLOBALS %MIBS %MUNGE $AUTOLOAD $INIT $DEBUG/;
|
||||
|
||||
# Set for No CDP
|
||||
%GLOBALS = ( %SNMP::Info::Layer2::GLOBALS,
|
||||
'cdp_id' => 's5EnMsTopIpAddr',
|
||||
'cdp_run' => 's5EnMsTopStatus',
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
'imac2' => 'ifPhysAddress',
|
||||
# S5-ETH-MULTISEG-TOPOLOGY-MIB::s5EnMsTopNmmTable
|
||||
'bay_topo_slot' => 's5EnMsTopNmmSlot',
|
||||
'bay_topo_port' => 's5EnMsTopNmmPort',
|
||||
'bay_topo_ip' => 's5EnMsTopNmmIpAddr',
|
||||
'bay_topo_seg' => 's5EnMsTopNmmSegId',
|
||||
'bay_topo_mac' => 's5EnMsTopNmmMacAddr',
|
||||
'bay_topo_platform' => 's5EnMsTopNmmChassisType',
|
||||
'bay_topo_localseg' => 's5EnMsTopNmmLocalSeg',
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
'SYNOPTICS-ROOT-MIB' => 'synoptics',
|
||||
'S5-ETH-MULTISEG-TOPOLOGY-MIB' => 's5EnMsTop'
|
||||
);
|
||||
|
||||
delete $MIBS{'CISCO-CDP-MIB'};
|
||||
# 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';
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
'i_mac2' => \&SNMP::Info::munge_mac ,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
# or nortel, or synopsis?
|
||||
return 'bay';
|
||||
}
|
||||
|
||||
sub i_ignore {
|
||||
my $bay = shift;
|
||||
my $descr = $bay->description();
|
||||
|
||||
my $i_type = $bay->i_type();
|
||||
|
||||
my %i_ignore;
|
||||
foreach my $if (keys %$i_type){
|
||||
my $type = $i_type->{$if};
|
||||
$i_ignore{$if}++ if $type =~ /(loopback|propvirtual|cpu)/i;
|
||||
}
|
||||
|
||||
return \%i_ignore;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $bay = shift;
|
||||
my $i_index = $bay->i_index();
|
||||
|
||||
return $i_index;
|
||||
}
|
||||
|
||||
sub i_mac {
|
||||
my $bay = shift;
|
||||
my $i_mac = $bay->i_mac2();
|
||||
|
||||
# Bay 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};
|
||||
delete $i_mac->{$iid} if $mac eq '00:00:00:00:00:00';
|
||||
}
|
||||
return $i_mac;
|
||||
}
|
||||
|
||||
|
||||
sub model {
|
||||
my $bay = shift;
|
||||
my $id = $bay->id();
|
||||
my $model = &SNMP::translateObj($id);
|
||||
$model =~ s/^sreg-//i;
|
||||
|
||||
my $descr = $bay->description();
|
||||
|
||||
return '303' if ($descr =~ /\D303\D/);
|
||||
return '304' if ($descr =~ /\D304\D/);
|
||||
return $model;
|
||||
}
|
||||
|
||||
# Hack in some CDP type stuff
|
||||
|
||||
sub c_if {
|
||||
my $bay = shift;
|
||||
my $bay_topo_port = $bay->bay_topo_port();
|
||||
|
||||
my %c_if;
|
||||
foreach my $entry (keys %$bay_topo_port){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next if $port == 0;
|
||||
$c_if{"$port.1"} = $port;
|
||||
}
|
||||
return \%c_if;
|
||||
}
|
||||
|
||||
sub c_ip {
|
||||
my $bay = shift;
|
||||
my $bay_topo_ip = $bay->bay_topo_ip();
|
||||
my $bay_topo_port = $bay->bay_topo_port();
|
||||
my $ip = $bay->cdp_ip();
|
||||
|
||||
# Count the number of devices seen on each port.
|
||||
# more than one device seen means connected to a non-bay
|
||||
# device, but other bay devices are squawking further away.
|
||||
my %ip_port;
|
||||
foreach my $entry (keys %$bay_topo_ip){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next if $port == 0;
|
||||
my $ip = $bay_topo_ip->{$entry};
|
||||
push(@{$ip_port{$port}},$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 $bay = shift;
|
||||
my $bay_topo_port = $bay->bay_topo_port();
|
||||
my $bay_topo_seg = $bay->bay_topo_seg();
|
||||
|
||||
my %c_port;
|
||||
foreach my $entry (keys %$bay_topo_seg){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next if $port == 0;
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
next if defined $c_port{"$port.1"};
|
||||
|
||||
my $seg = $bay_topo_seg->{$entry};
|
||||
|
||||
# Segment id is (256 * remote slot_num) + (remote_port)
|
||||
my $remote_port = $seg % 256;
|
||||
|
||||
$c_port{"$port.1"} = $remote_port;
|
||||
}
|
||||
|
||||
return \%c_port;
|
||||
}
|
||||
|
||||
sub c_platform {
|
||||
my $bay = shift;
|
||||
my $bay_topo_port = $bay->bay_topo_port();
|
||||
my $bay_topo_platform = $bay->bay_topo_platform();
|
||||
|
||||
|
||||
my %c_platform;
|
||||
foreach my $entry (keys %$bay_topo_platform){
|
||||
my $port = $bay_topo_port->{$entry};
|
||||
next if $port == 0;
|
||||
|
||||
# For fake remotes (multiple IPs for a c_ip), use first found
|
||||
next if defined $c_platform{"$port.1"};
|
||||
|
||||
my $platform = $bay_topo_platform->{$entry};
|
||||
|
||||
$c_platform{"$port.1"} = $platform;
|
||||
}
|
||||
|
||||
return \%c_platform;
|
||||
}
|
||||
|
||||
|
||||
__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.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $bay = new SNMP::Info::Layer2::Bay(DestHost => 'mybayswitch' ,
|
||||
Community => 'public' );
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
|
||||
=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);
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $bay->vendor()
|
||||
|
||||
Returns 'bay' :)
|
||||
|
||||
=item $bay->model()
|
||||
|
||||
Cross references $bay->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 $bay->cdp_id()
|
||||
|
||||
Returns the IP that the device is sending out for its Nmm topology info.
|
||||
|
||||
(B<s5EnMsTopIpAddr>)
|
||||
|
||||
=item $bay->cdp_run()
|
||||
|
||||
Returns if the S5-ETH-MULTISEG-TOPOLOGY info is on for this device.
|
||||
|
||||
(B<s5EnMsTopStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $bay->interfaces()
|
||||
|
||||
Returns reference to map of IIDs to physical ports.
|
||||
|
||||
Currently simply returns the B<ifIndex>
|
||||
|
||||
=item $bay->i_ignore()
|
||||
|
||||
Returns reference to hash of IIDs to ignore.
|
||||
|
||||
Simply calls the SNMP::Info::Layer2::i_ignore() fn for this.
|
||||
|
||||
=item $bay->i_mac()
|
||||
|
||||
Returns the B<ifPhysAddress> table entries.
|
||||
|
||||
Removes all entries matching '00:00:00:00:00:00' -- Certain
|
||||
older revisions of Bay 303 and 304 firmware report all zeros
|
||||
for each port mac.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Psuedo CDP information
|
||||
|
||||
All entries with port=0 are local and ignored.
|
||||
|
||||
=over
|
||||
|
||||
=item $bay->c_if()
|
||||
|
||||
Returns referenece to hash. Key: port.1 Value: port (iid)
|
||||
|
||||
=item $bay->c_ip()
|
||||
|
||||
Returns referenece to hash. Key: port.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-bay 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 nieghbors, is if there is a non-bay device in between two or more devices.
|
||||
|
||||
Use the data from the Layer2 Topology Table below to dig deeper.
|
||||
|
||||
=item $bay->port()
|
||||
|
||||
Returns reference to hash. Key: port.1 Value: port
|
||||
|
||||
=item $bay->platform()
|
||||
|
||||
Returns reference to hash. Key: port.1 Value: Remote Device Type
|
||||
|
||||
=back
|
||||
|
||||
=head2 Layer2 Topology info (s5EnMsTopNmmTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $bay->bay_topo_slot()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:slot number
|
||||
|
||||
(B<s5EnMsTopNmmSlot>)
|
||||
|
||||
=item $bay->bay_topo_port()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Port Number (interface iid)
|
||||
|
||||
(B<s5EnMsTopNmmPort>)
|
||||
|
||||
=item $bay->bay_topo_ip()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote IP address of entry
|
||||
|
||||
(B<s5EnMsTopNmmIpAddr>)
|
||||
|
||||
=item $bay->bay_topo_seg()
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote Segment ID
|
||||
|
||||
(B<s5EnMsTopNmmSegId>)
|
||||
|
||||
=item $bay->bay_topo_mac
|
||||
(B<s5EnMsTopNmmMacAddr>)
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote MAC address
|
||||
|
||||
=item $bay->bay_topo_platform
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Remote Device Type
|
||||
|
||||
(B<s5EnMsTopNmmChassisType>)
|
||||
|
||||
=item $bay->bay_topo_localseg
|
||||
|
||||
Returns reference to hash. Key: Table entry, Value:Boolean, if bay_topo_seg() is local
|
||||
|
||||
(B<s5EnMsTopNmmLocalSeg>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
293
Info/Layer2/C1900.pm
Normal file
293
Info/Layer2/C1900.pm
Normal file
@@ -0,0 +1,293 @@
|
||||
# SNMP::Info::Layer2::C1900
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, 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::C1900;
|
||||
$VERSION = 0.1;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
|
||||
@SNMP::Info::Layer2::C1900::ISA = qw/SNMP::Info::Layer2 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
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
'i_type2' => 'ifType',
|
||||
# ESSWITCH-MIB
|
||||
'c1900_p_index' => 'swPortIndex',
|
||||
'c1900_p_ifindex' => 'swPortIfIndex',
|
||||
'c1900_p_duplex' => 'swPortDuplexStatus',
|
||||
'c1900_p_duplex_admin' => 'swPortFullDuplex',
|
||||
'c1900_p_name' => 'swPortName',
|
||||
'c1900_p_up_admin' => 'swPortAdminStatus',
|
||||
'c1900_p_type' => 'swPortMediaCapability',
|
||||
'c1900_p_media' => 'swPortConnectorType',
|
||||
);
|
||||
|
||||
%MIBS = (
|
||||
%SNMP::Info::Layer2::MIBS,
|
||||
# Also known as the ESSWITCH-MIB
|
||||
'STAND-ALONE-ETHERNET-SWITCH-MIB' => 'series2000'
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $c1900 = shift;
|
||||
|
||||
my $interfaces = $c1900->interfaces();
|
||||
my $c1900_p_index = $c1900->c1900_p_index();
|
||||
my $c1900_p_duplex = $c1900->c1900_p_duplex();
|
||||
|
||||
|
||||
my %reverse_1900 = reverse %$c1900_p_index;
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port_1900 = $reverse_1900{$if};
|
||||
next unless defined $port_1900;
|
||||
my $duplex = $c1900_p_duplex->{$port_1900};
|
||||
next 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 $c1900 = shift;
|
||||
|
||||
my $interfaces = $c1900->interfaces();
|
||||
my $c1900_p_index = $c1900->c1900_p_index();
|
||||
my $c1900_p_admin = $c1900->c1900_p_duplex_admin();
|
||||
|
||||
|
||||
my %reverse_1900 = reverse %$c1900_p_index;
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port_1900 = $reverse_1900{$if};
|
||||
next unless defined $port_1900;
|
||||
my $duplex = $c1900_p_admin->{$port_1900};
|
||||
next unless defined $duplex;
|
||||
|
||||
$duplex = 'half' if $duplex =~ /disabled/i;
|
||||
$duplex = 'full' if $duplex =~ /flow control/i;
|
||||
$duplex = 'full' if $duplex =~ /enabled/i;
|
||||
$duplex = 'auto' if $duplex =~ /auto/i;
|
||||
$i_duplex_admin{$if}=$duplex;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
sub i_type {
|
||||
my $c1900 = shift;
|
||||
|
||||
my $i_type = $c1900->i_type2();
|
||||
my $c1900_p_index = $c1900->c1900_p_index();
|
||||
my $c1900_p_type = $c1900->c1900_p_type();
|
||||
my $c1900_p_media = $c1900->c1900_p_media();
|
||||
|
||||
foreach my $p_iid (keys %$c1900_p_index){
|
||||
my $port = $c1900_p_index->{$p_iid};
|
||||
my $type = $c1900_p_type->{$p_iid};
|
||||
my $media = $c1900_p_media->{$p_iid};
|
||||
|
||||
next unless defined $port;
|
||||
next unless defined $type;
|
||||
next unless defined $media;
|
||||
|
||||
$i_type->{$port} = "$type $media";
|
||||
}
|
||||
|
||||
return $i_type;
|
||||
}
|
||||
__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
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $c1900 = new SNMP::Info::Layer2::C1900(DestHost => 'mycat1900' ,
|
||||
Community => 'public' );
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::C1900()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $c1900 = new SNMP::Info::Layer2::C1900(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $c1900;
|
||||
|
||||
=item $c1900->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $c1900->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$c1900->session($newsession);
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $c1900->vendor()
|
||||
|
||||
Returns 'cisco' :)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $c1900->i_duplex()
|
||||
|
||||
Returns reference to map of IIDs to current link duplex
|
||||
|
||||
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex;
|
||||
|
||||
=item $c1900->i_duplex_admin()
|
||||
|
||||
Returns reference to hash of IIDs to admin duplex setting
|
||||
|
||||
Crosses $c1900->c1900_p_index() with $c1900->c1900_p_duplex_admin;
|
||||
|
||||
=item $c1900->i_type()
|
||||
|
||||
Returns reference to hash of IID to port type
|
||||
|
||||
Takes the default ifType and overrides it with
|
||||
|
||||
c1900_p_type() and c1900_p_media() if they exist.
|
||||
|
||||
=back
|
||||
|
||||
=head2 STAND-ALONE-ETHERNET-SWITCH-MIB Switch Port Table Entries:
|
||||
|
||||
=over
|
||||
|
||||
=item $c1900->c1900_p_index()
|
||||
|
||||
Maps the Switch Port Table to the IID
|
||||
|
||||
B<swPortIfIndex>
|
||||
|
||||
=item $c1900->c1900_p_duplex()
|
||||
|
||||
Gives Port Duplex Info
|
||||
|
||||
B<swPortDuplexStatus>
|
||||
|
||||
=item $c1900->c1900_p_duplex_admin()
|
||||
|
||||
Gives admin setting for Duplex Info
|
||||
|
||||
B<swPortFullDuplex>
|
||||
|
||||
=item $c1900->c1900_p_name()
|
||||
|
||||
Gives human set name for port
|
||||
|
||||
B<swPortName>
|
||||
|
||||
=item $c1900->c1900_p_up_admin()
|
||||
|
||||
Gives Admin status of port enabled.
|
||||
|
||||
B<swPortAdminStatus>
|
||||
|
||||
=item $c1900->c1900_p_type()
|
||||
|
||||
Gives Type of port, ie. "general-ethernet"
|
||||
|
||||
B<swPortMediaCapability>
|
||||
|
||||
=item $c1900->c1900_p_media()
|
||||
|
||||
Gives the media of the port , ie "fiber-sc"
|
||||
|
||||
B<swPortConnectorType>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
264
Info/Layer2/C2900.pm
Normal file
264
Info/Layer2/C2900.pm
Normal file
@@ -0,0 +1,264 @@
|
||||
# SNMP::Info::Layer2::C2900
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, 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::C2900;
|
||||
$VERSION = 0.1;
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
|
||||
@SNMP::Info::Layer2::C2900::ISA = qw/SNMP::Info::Layer2 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
|
||||
);
|
||||
|
||||
%FUNCS = (%SNMP::Info::Layer2::FUNCS,
|
||||
# C2900PortEntry
|
||||
'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'
|
||||
);
|
||||
|
||||
%MUNGE = (%SNMP::Info::Layer2::MUNGE,
|
||||
);
|
||||
|
||||
sub vendor {
|
||||
return 'cisco';
|
||||
}
|
||||
|
||||
sub i_duplex {
|
||||
my $c2900 = shift;
|
||||
|
||||
my $interfaces = $c2900->interfaces();
|
||||
my $c2900_p_index = $c2900->c2900_p_index();
|
||||
my $c2900_p_duplex = $c2900->c2900_p_duplex();
|
||||
|
||||
|
||||
my %reverse_2900 = reverse %$c2900_p_index;
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port_2900 = $reverse_2900{$if};
|
||||
next unless defined $port_2900;
|
||||
my $duplex = $c2900_p_duplex->{$port_2900};
|
||||
next 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 $c2900 = shift;
|
||||
|
||||
my $interfaces = $c2900->interfaces();
|
||||
my $c2900_p_index = $c2900->c2900_p_index();
|
||||
my $c2900_p_admin = $c2900->c2900_p_duplex_admin();
|
||||
|
||||
|
||||
my %reverse_2900 = reverse %$c2900_p_index;
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $if (keys %$interfaces){
|
||||
my $port_2900 = $reverse_2900{$if};
|
||||
next unless defined $port_2900;
|
||||
my $duplex = $c2900_p_admin->{$port_2900};
|
||||
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{$if}=$duplex;
|
||||
}
|
||||
return \%i_duplex_admin;
|
||||
}
|
||||
|
||||
# Use i_descritption for port key, cuz i_name can be manually entered.
|
||||
sub interfaces {
|
||||
my $c2900 = shift;
|
||||
my $interfaces = $c2900->i_index();
|
||||
my $i_descr = $c2900->i_description();
|
||||
|
||||
my %if;
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $port = $i_descr->{$iid};
|
||||
next unless defined $port;
|
||||
|
||||
$port =~ s/\./\//g if( $port =~ /\d+\.\d+$/);
|
||||
$port =~ s/[^\d\/,()\w]+//gi;
|
||||
|
||||
$if{$iid} = $port;
|
||||
}
|
||||
|
||||
return \%if
|
||||
}
|
||||
|
||||
__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.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $c2900 = new SNMP::Info::Layer2::C2900(DestHost => 'mycat2900' ,
|
||||
Community => 'public' );
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::C2900()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
my $c2900 = new SNMP::Info::Layer2::C2900(
|
||||
DestHost => $host,
|
||||
Community => 'public',
|
||||
Version => 3,...
|
||||
)
|
||||
die "Couldn't connect.\n" unless defined $c2900;
|
||||
|
||||
=item $c2900->session()
|
||||
|
||||
Sets or returns the SNMP::Session object
|
||||
|
||||
# Get
|
||||
my $sess = $c2900->session();
|
||||
|
||||
# Set
|
||||
my $newsession = new SNMP::Session(...);
|
||||
$c2900->session($newsession);
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBALS
|
||||
|
||||
=over
|
||||
|
||||
=item $c2900->vendor()
|
||||
|
||||
Returns 'cisco' :)
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $c2900->interfaces()
|
||||
|
||||
Returns reference to the map between IID and physical Port.
|
||||
|
||||
On the 2900 devices i_name isn't reliable, so we override to just the description.
|
||||
|
||||
Next all dots are changed for forward slashes so that the physical port name
|
||||
is the same as the broadcasted CDP port name.
|
||||
(Ethernet0.1 -> Ethernet0/1)
|
||||
|
||||
Also, any weird characters are removed, as I saw a few pop up.
|
||||
|
||||
=item $c2900->i_duplex()
|
||||
|
||||
Returns reference to map of IIDs to current link duplex
|
||||
|
||||
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex;
|
||||
|
||||
=item $c2900->i_duplex_admin()
|
||||
|
||||
Returns reference to hash of IIDs to admin duplex setting
|
||||
|
||||
Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin;
|
||||
|
||||
|
||||
=back
|
||||
|
||||
=head2 C2900-MIB Port Entry Table
|
||||
|
||||
=over
|
||||
|
||||
=item $c2900->c2900_p_index()
|
||||
|
||||
Maps the Switch Port Table to the IID
|
||||
|
||||
B<c2900PortIfIndex>
|
||||
|
||||
=item $c2900->c2900_p_duplex()
|
||||
|
||||
Gives Port Duplex Info
|
||||
|
||||
B<c2900PortDuplexStatus>
|
||||
|
||||
=item $c2900->c2900_p_duplex_admin()
|
||||
|
||||
Gives admin setting for Duplex Info
|
||||
|
||||
B<c2900PortDuplexState>
|
||||
|
||||
|
||||
=item $c2900->c2900_p_speed_admin()
|
||||
|
||||
Gives Admin speed of port
|
||||
|
||||
B<c2900PortAdminSpeed>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
508
Info/Layer2/Catalyst.pm
Normal file
508
Info/Layer2/Catalyst.pm
Normal file
@@ -0,0 +1,508 @@
|
||||
# SNMP::Info::Layer2::Catalyst
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, 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::Catalyst;
|
||||
$VERSION = 0.1;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
|
||||
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/;
|
||||
@SNMP::Info::Layer2::Catalyst::EXPORT_OK = qw//;
|
||||
|
||||
$DEBUG=0;
|
||||
|
||||
# See SNMP::Info for the details of these data structures and
|
||||
# the interworkings.
|
||||
$INIT = 0;
|
||||
|
||||
%MYMIBS = (
|
||||
'CISCO-STACK-MIB' => 'moduleType',
|
||||
'CISCO-VTP-MIB' => 'vtpVlanIndex'
|
||||
);
|
||||
|
||||
%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',
|
||||
);
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer2::FUNCS,
|
||||
%MYFUNCS
|
||||
);
|
||||
|
||||
%MYMUNGE = (
|
||||
'm_ports_status' => \&munge_port_status,
|
||||
'p_duplex_admin' => \&SNMP::Info::munge_bits,
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%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);
|
||||
}
|
||||
|
||||
# Overidden Methods
|
||||
|
||||
# i_physical sets a hash entry as true if the iid is a physical port
|
||||
sub i_physical {
|
||||
my $cat = shift;
|
||||
|
||||
my $p_port = $cat->p_port();
|
||||
|
||||
my %i_physical;
|
||||
foreach my $port (keys %$p_port) {
|
||||
my $iid = $p_port->{$port};
|
||||
$i_physical{$iid} = 1;
|
||||
}
|
||||
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';
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $cat = new SNMP::Info::Layer2::Catalyst(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::Catalyst()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
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);
|
||||
|
||||
=back
|
||||
|
||||
=head1 GLOBAL Values
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->netmask()
|
||||
(B<sysNetMask>)
|
||||
|
||||
=item $cat->broadcast()
|
||||
(B<sysBroadcast>)
|
||||
|
||||
=item $cat->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
|
||||
=item $cat->model()
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $cat->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
|
||||
=item $cat->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
|
||||
=item $cat->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
|
||||
=item $cat->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
|
||||
=item $cat->slots()
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=item $cat->fan()
|
||||
(B<chassisFanStatus>)
|
||||
|
||||
=item $cat->vendor()
|
||||
|
||||
Returns 'cisco'
|
||||
|
||||
=back
|
||||
|
||||
=head1 TABLE ENTRIES
|
||||
|
||||
=head2 Overrides
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->interfaces()
|
||||
|
||||
Crosses p_port() with i_index() to get physical names.
|
||||
|
||||
=item $cat->i_physical()
|
||||
|
||||
Returns a map to IID for ports that are physical ports, not vlans, etc.
|
||||
|
||||
=item $cat->i_type()
|
||||
|
||||
Crosses p_port() with p_type() and returns the results.
|
||||
|
||||
Overrides with ifType if p_type() isn't available.
|
||||
|
||||
=item $cat->i_name()
|
||||
|
||||
Crosses p_name with p_port and returns results.
|
||||
|
||||
=item $cat->i_duplex()
|
||||
|
||||
Crosses p_duplex with p_port and returns results.
|
||||
|
||||
=item $cat->i_duplex_admin()
|
||||
|
||||
Crosses p_duplex_admin with p_port.
|
||||
|
||||
Munges bit_string returned from p_duplex_admin to get duplex settings.
|
||||
|
||||
=back
|
||||
|
||||
=head2 Module table
|
||||
|
||||
This table holds configuration information for each of the blades installed in
|
||||
the Catalyst device.
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->m_type()
|
||||
(B<moduleType>)
|
||||
|
||||
=item $cat->m_model()
|
||||
(B<moduleModel>)
|
||||
|
||||
=item $cat->m_serial()
|
||||
(B<moduleSerialNumber>)
|
||||
|
||||
=item $cat->m_status()
|
||||
(B<moduleStatus>)
|
||||
|
||||
=item $cat->m_name()
|
||||
(B<moduleName>)
|
||||
|
||||
=item $cat->m_ports()
|
||||
(B<moduleNumPorts>)
|
||||
|
||||
=item $cat->m_ports_status()
|
||||
Returns a list of space separated status strings for the ports.
|
||||
To see the status of port 4 :
|
||||
@ports_status = split(' ', $cat->m_ports_status() );
|
||||
$port4 = $ports_status[3];
|
||||
|
||||
(B<modulePortStatus>)
|
||||
|
||||
=item $cat->m_ports_hwver()
|
||||
(B<moduleHwVersion>)
|
||||
|
||||
=item $cat->m_ports_fwver()
|
||||
(B<moduleFwVersion>)
|
||||
|
||||
=item $cat->m_ports_swver()
|
||||
(B<moduleSwVersion>)
|
||||
|
||||
=item $cat->m_ports_ip()
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $cat->m_ports_sub1()
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $cat->m_ports_sub2()
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Modules - Router Blades
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->m_ip()
|
||||
(B<moduleIPAddress>)
|
||||
|
||||
=item $cat->m_sub1()
|
||||
(B<moduleSubType>)
|
||||
|
||||
=item $cat->m_sub2()
|
||||
(B<moduleSubType2>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table (CISCO-STACK-MIB::portTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->p_name()
|
||||
(B<portName>)
|
||||
|
||||
=item $cat->p_type()
|
||||
(B<portType>)
|
||||
|
||||
=item $cat->p_status()
|
||||
(B<portOperStatus>)
|
||||
|
||||
=item $cat->p_status2()
|
||||
(B<portAdditionalStatus>)
|
||||
|
||||
=item $cat->p_speed()
|
||||
(B<portAdminSpeed>)
|
||||
|
||||
=item $cat->p_duplex()
|
||||
(B<portDuplex>)
|
||||
|
||||
=item $cat->p_port()
|
||||
(B<portIfIndex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Capability Table (CISCO-STACK-MIB::portCpbTable)
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->p_speed_admin()
|
||||
(B<portCpbSpeed>)
|
||||
|
||||
=item $cat->p_duplex_admin()
|
||||
(B<portCpbDuplex>)
|
||||
|
||||
=back
|
||||
|
||||
=head2 VLAN Entry Table
|
||||
|
||||
See ftp://ftp.cisco.com/pub/mibs/supportlists/wsc5000/wsc5000-communityIndexing.html
|
||||
for a good treaty of how to connect to the VLANs
|
||||
|
||||
|
||||
=over
|
||||
|
||||
=item $cat->v_state()
|
||||
(B<vtpVlanState>)
|
||||
|
||||
=item $cat->v_type()
|
||||
(B<vtpVlanType>)
|
||||
|
||||
=item $cat->v_name()
|
||||
(B<vtpVlanName>)
|
||||
|
||||
=item $cat->v_mtu()
|
||||
(B<vtpVlanMtu>)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
547
Info/Layer2/HP.pm
Normal file
547
Info/Layer2/HP.pm
Normal file
@@ -0,0 +1,547 @@
|
||||
# SNMP::Info::Layer2::HP - SNMP Interface to HP ProCurve Switches
|
||||
# Max Baker <max@warped.org>
|
||||
#
|
||||
# Copyright (c) 2002, 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::HP;
|
||||
$VERSION = 0.1;
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use SNMP::Info::Layer2;
|
||||
use SNMP::Info::MAU;
|
||||
|
||||
use vars qw/$VERSION $DEBUG %GLOBALS %MIBS %FUNCS %PORTSTAT
|
||||
%MYGLOBALS %MYMIBS %MYFUNCS %MYMUNGE %MUNGE $INIT/ ;
|
||||
@SNMP::Info::Layer2::HP::ISA = qw/SNMP::Info::Layer2 SNMP::Info::MAU 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.
|
||||
$INIT = 0;
|
||||
|
||||
%MYMIBS = ( 'ENTITY-MIB' => 'entPhysicalSerialNum',
|
||||
'RFC1271-MIB' => 'logDescription',
|
||||
'HP-ICF-OID' => 'hpSwitch4000',
|
||||
);
|
||||
|
||||
%MIBS = ( %SNMP::Info::Layer2::MIBS,
|
||||
%SNMP::Info::MAU::MIBS,
|
||||
%MYMIBS );
|
||||
|
||||
%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'
|
||||
|
||||
);
|
||||
%FUNCS = (
|
||||
%SNMP::Info::Layer2::FUNCS,
|
||||
%SNMP::Info::MAU::FUNCS,
|
||||
%MYFUNCS
|
||||
);
|
||||
|
||||
%MYMUNGE = (
|
||||
);
|
||||
|
||||
%MUNGE = (
|
||||
# Inherit all the built in munging
|
||||
%SNMP::Info::Layer2::MUNGE,
|
||||
%SNMP::Info::MAU::MUNGE,
|
||||
%MYMUNGE
|
||||
);
|
||||
|
||||
|
||||
# Method Overrides
|
||||
|
||||
# Some have the serial num in entity mib, some dont.
|
||||
sub serial {
|
||||
my $hp = shift;
|
||||
|
||||
# procurve 2xxx have this
|
||||
my $serial = $hp->serial1();
|
||||
|
||||
# 4xxx dont
|
||||
return undef if $serial =~ /nosuchobject/i;
|
||||
|
||||
return $serial;
|
||||
}
|
||||
|
||||
sub interfaces {
|
||||
my $hp = shift;
|
||||
my $interfaces = $hp->i_index();
|
||||
my $i_descr = $hp->i_description();
|
||||
|
||||
my %if;
|
||||
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);
|
||||
}
|
||||
|
||||
return \%if
|
||||
|
||||
}
|
||||
|
||||
# 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();
|
||||
my $e_port = $hp->e_port();
|
||||
|
||||
# Grab default values to pass through
|
||||
my $i_type = $hp->i_type2();
|
||||
|
||||
# Now Stuff in the entity-table values
|
||||
foreach my $port (keys %$e_descr){
|
||||
my $iid = $e_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $type = $e_descr->{$port};
|
||||
$type =~ s/^HP ?//;
|
||||
$i_type->{$iid} = $type;
|
||||
}
|
||||
|
||||
return $i_type;
|
||||
|
||||
}
|
||||
|
||||
sub i_name {
|
||||
my $hp = shift;
|
||||
my $i_alias = $hp->i_alias();
|
||||
my $e_name = $hp->e_name();
|
||||
my $e_port = $hp->e_port();
|
||||
|
||||
my %i_name;
|
||||
|
||||
foreach my $port (keys %$e_name){
|
||||
my $iid = $e_port->{$port};
|
||||
next unless defined $iid;
|
||||
my $alias = $i_alias->{$iid};
|
||||
next unless defined $iid;
|
||||
$i_name{$iid} = $e_name->{$port};
|
||||
|
||||
# Check for alias
|
||||
$i_name{$iid} = $alias if (defined $alias and length($alias));
|
||||
}
|
||||
|
||||
return \%i_name;
|
||||
}
|
||||
|
||||
sub vendor {
|
||||
return 'hp';
|
||||
}
|
||||
|
||||
sub log {
|
||||
my $hp=shift;
|
||||
|
||||
my $log = $hp->l_descr();
|
||||
|
||||
my $logstring = undef;
|
||||
|
||||
foreach my $val (values %$log){
|
||||
next if $val =~ /^Link\s+(Up|Down)/;
|
||||
$logstring .= "$val\n";
|
||||
}
|
||||
|
||||
return $logstring;
|
||||
}
|
||||
|
||||
sub slots {
|
||||
my $hp=shift;
|
||||
|
||||
my $e_name = $hp->e_name();
|
||||
|
||||
return undef unless defined $e_name;
|
||||
|
||||
my $slots;
|
||||
foreach my $slot (keys %$e_name) {
|
||||
$slots++ if $e_name->{$slot} =~ /slot/i;
|
||||
}
|
||||
|
||||
return $slots;
|
||||
}
|
||||
|
||||
#sub fan {
|
||||
# my $hp = shift;
|
||||
#
|
||||
# my %ents = reverse %{$hp->e_name()};
|
||||
#
|
||||
# my $fan = $ents{'Fan'};
|
||||
#
|
||||
#}
|
||||
|
||||
sub i_duplex {
|
||||
my $hp = shift;
|
||||
|
||||
my $mau_index = $hp->mau_index();
|
||||
my $mau_link = $hp->mau_link();
|
||||
|
||||
my %i_duplex;
|
||||
foreach my $mau_port (keys %$mau_link){
|
||||
my $iid = $mau_index->{$mau_port};
|
||||
next unless defined $iid;
|
||||
|
||||
my $linkoid = $mau_link->{$mau_port};
|
||||
my $link = &SNMP::translateObj($linkoid);
|
||||
next unless defined $link;
|
||||
|
||||
my $duplex = undef;
|
||||
|
||||
if ($link =~ /fd$/i) {
|
||||
$duplex = 'full';
|
||||
} elsif ($link =~ /hd$/i){
|
||||
$duplex = 'half';
|
||||
}
|
||||
|
||||
$i_duplex{$iid} = $duplex if defined $duplex;
|
||||
}
|
||||
return \%i_duplex;
|
||||
}
|
||||
|
||||
|
||||
sub i_duplex_admin {
|
||||
my $hp = shift;
|
||||
|
||||
my $interfaces = $hp->interfaces();
|
||||
my $mau_index = $hp->mau_index();
|
||||
my $mau_auto = $hp->mau_auto();
|
||||
my $mau_autostat = $hp->mau_autostat();
|
||||
my $mau_typeadmin = $hp->mau_type_admin();
|
||||
my $mau_autosent = $hp->mau_autosent();
|
||||
|
||||
my %mau_reverse = reverse %$mau_index;
|
||||
|
||||
my %i_duplex_admin;
|
||||
foreach my $iid (keys %$interfaces){
|
||||
my $mau_index = $mau_reverse{$iid};
|
||||
next unless defined $mau_index;
|
||||
|
||||
my $autostat = $mau_autostat->{$mau_index};
|
||||
|
||||
# HP25xx has this value
|
||||
if (defined $autostat and $autostat =~ /enabled/i){
|
||||
$i_duplex_admin{$iid} = 'auto';
|
||||
next;
|
||||
}
|
||||
|
||||
my $type = $mau_autosent->{$mau_index};
|
||||
|
||||
next unless defined $type;
|
||||
|
||||
if ($type == 0) {
|
||||
$i_duplex_admin{$iid} = 'none';
|
||||
next;
|
||||
}
|
||||
|
||||
my $full = $hp->_isfullduplex($type);
|
||||
my $half = $hp->_ishalfduplex($type);
|
||||
|
||||
if ($full and !$half){
|
||||
$i_duplex_admin{$iid} = 'full';
|
||||
} elsif ($half) {
|
||||
$i_duplex_admin{$iid} = 'half';
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
#
|
||||
#}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
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
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Max Baker (C<max@warped.org>)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $hp = new SNMP::Info::Layer2::HP(DestHost => 'router' ,
|
||||
Community => 'public' );
|
||||
|
||||
=head1 CREATING AN OBJECT
|
||||
|
||||
=over
|
||||
|
||||
=item new SNMP::Info::Layer2::HP()
|
||||
|
||||
Arguments passed to new() are passed on to SNMP::Session::new()
|
||||
|
||||
|
||||
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.
|
||||
|
||||
=back
|
||||
|
||||
=head1 HP Global Configuration Values
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->name()
|
||||
(B<sysName>)
|
||||
|
||||
=item $hp->ip()
|
||||
(B<sysIpAddr>)
|
||||
|
||||
=item $hp->netmask()
|
||||
(B<sysNetMask>)
|
||||
|
||||
=item $hp->broadcast()
|
||||
(B<sysBroadcast>)
|
||||
|
||||
=item $hp->location()
|
||||
(B<sysLocation>)
|
||||
|
||||
=item $hp->contact()
|
||||
(B<sysContact>)
|
||||
|
||||
=item $hp->description()
|
||||
(B<sysDescr>)
|
||||
|
||||
=item $hp->layers()
|
||||
(B<sysServices>)
|
||||
|
||||
=item $hp->serial()
|
||||
(B<chassisSerialNumberString>)
|
||||
|
||||
=item $hp->model()
|
||||
(B<chassisModel>)
|
||||
|
||||
=item $hp->ps1_type()
|
||||
(B<chassisPs1Type>)
|
||||
|
||||
=item $hp->ps2_type()
|
||||
(B<chassisPs2Type>)
|
||||
|
||||
=item $hp->ps1_status()
|
||||
(B<chassisPs1Status>)
|
||||
|
||||
=item $hp->ps2_status()
|
||||
(B<chassisPs2Status>)
|
||||
|
||||
=item $hp->slots()
|
||||
(B<chassisNumSlots>)
|
||||
|
||||
=item $hp->fan()
|
||||
(B<chassisFanStatus>)
|
||||
|
||||
=back
|
||||
|
||||
=head1 CATALYST TABLE ENTRIES
|
||||
|
||||
=head2 Module table
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->m_type(), $hp->load_m_type()
|
||||
(B<moduleType>)
|
||||
|
||||
=item $hp->m_model(), $hp->load_m_model()
|
||||
(B<moduleModel>)
|
||||
|
||||
=item $hp->m_serial(), $hp->load_m_serial()
|
||||
(B<moduleSerialNumber>)
|
||||
|
||||
=item $hp->m_status(), $hp->load_m_status()
|
||||
(B<moduleStatus>)
|
||||
|
||||
=item $hp->m_name(), $hp->load_m_name()
|
||||
(B<moduleName>)
|
||||
|
||||
=item $hp->m_ports(), $hp->load_m_ports()
|
||||
(B<moduleNumPorts>)
|
||||
|
||||
=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];
|
||||
|
||||
(B<modulePortStatus>)
|
||||
|
||||
=item $hp->m_ports_hwver(), $hp->load_m_ports_hwver()
|
||||
(B<moduleHwVersion>)
|
||||
|
||||
=item $hp->m_ports_fwver(), $hp->load_m_ports_fwver()
|
||||
(B<moduleFwVersion>)
|
||||
|
||||
=item $hp->m_ports_swver(), $hp->load_m_ports_swver()
|
||||
(B<moduleSwVersion>)
|
||||
|
||||
=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>)
|
||||
|
||||
|
||||
=back
|
||||
|
||||
=head2 Port Entry Table
|
||||
|
||||
=over
|
||||
|
||||
=item $hp->p_name(), $hp->load_p_name()
|
||||
(B<portName>)
|
||||
|
||||
=item $hp->p_type(), $hp->load_p_type()
|
||||
(B<portType>)
|
||||
|
||||
=item $hp->p_status(), $hp->load_p_status()
|
||||
(B<portOperStatus>)
|
||||
|
||||
=item $hp->p_status2(), $hp->load_p_status2()
|
||||
(B<portAdditionalStatus>)
|
||||
|
||||
=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
|
||||
Reference in New Issue
Block a user