Compare commits

..

11 Commits

Author SHA1 Message Date
cvs2svn
ea7eb9c71f This commit was manufactured by cvs2svn to create tag 'ver_0_3'.
Sprout from master 2003-03-06 21:56:22 UTC Max Baker 'ver_03'
Delete:
    t/prereq.t
2003-03-06 21:56:23 +00:00
Max Baker
e4e039e2e1 ver_03 2003-03-06 21:56:22 +00:00
Max Baker
6dac5dffb3 new 2003-03-06 21:47:37 +00:00
Max Baker
ddeb705f13 ver_03 2003-03-06 21:41:07 +00:00
Max Baker
b86cf86fa6 ver_03 2003-03-06 21:12:46 +00:00
Max Baker
0cd3ba27c0 removed snmp requirement 2003-03-06 21:02:56 +00:00
Max Baker
fe6157f900 changed to t/* 2003-03-06 21:01:44 +00:00
Max Baker
b4c1bf0900 error check 2003-03-05 19:29:22 +00:00
Max Baker
7f2e79c634 error check in serial() 2003-03-05 19:29:07 +00:00
Max Baker
947c8679c8 Added check in _global() for NOSUCHOBJECT response from SNMP 2003-03-04 20:18:19 +00:00
Max Baker
919906516d Speedup in device_type() and more debugging info for GET operations and new() 2003-02-21 18:23:08 +00:00
22 changed files with 238 additions and 399 deletions

View File

@@ -1,6 +1,19 @@
SNMP::Info - Perl5 OO Interface to Network Devices and SNMP MIBs
ChangeLog $Id$
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@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@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

55
Info.pm
View File

@@ -7,7 +7,7 @@
# See COPYRIGHT below
package SNMP::Info;
$VERSION = 0.2;
$VERSION = 0.3;
use strict;
use Exporter;
@@ -27,7 +27,7 @@ SNMP::Info - Perl5 Interface to Network devices through SNMP.
=head1 VERSION
SNMP::Info - Version 0.1
SNMP::Info - Version 0.3
=head1 AUTHOR
@@ -82,7 +82,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Find out the Duplex status for the ports
my $interfaces = $more_specific_device->interfaces();
my $i_duplex = $more_specific_device->i_duplex();
# Get CDP Neighbor info
my $c_ip = $more_specific_device->c_ip();
my $c_port = $more_specific_device->c_port();
foreach my $iid (keys %$interfaces){
my $duplex = $i_duplex->{$iid};
@@ -90,8 +94,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Print out physical port name, not snmp iid
my $port = $interfaces->{$iid};
print "$port : $duplex\n";
my $neighbor_ip = $c_ip->{$iid};
my $neighbor_port = $c_port->{$iid};
print "$port: Duplex $duplex\n";
print " Neighbor : $neighbor_ip \@ $neighbor_port\n";
}
=head1 REQUIREMENTS
@@ -209,6 +217,8 @@ back to the developers at snmp@warped.org for inclusion in the next version.
=item SNMP::Info::Layer3::Foundry
=item SNMP::Info::Layer3::C3550
=back
=head2 Details
@@ -314,6 +324,9 @@ Required MIBs:
AWCVX-MIB - Aironet Specific MIB values
IEEE802dot11-MIB - IEEE 802.11 Specific MIB (currently draft)
=item * SNMP::Info::Layer3::C3550 - Cisco Catalyst 3550 Layer2/3 Switch
=item * SNMP::Info::Layer3::Foundry - Older Foundry Networks Devices Support
Inherits SNMP::Info::Bridge
@@ -377,6 +390,8 @@ sub new {
unless (defined $sess){
# How do i get error messages back from SNMP?
#print $SNMP::ErrorStr;
print "SNMP::Info::new() $sess->{ErrorStr}\n"
if ($DEBUG and $sess->{ErrorStr});
return undef;
}
@@ -444,11 +459,11 @@ sub device_type {
my $objtype = "SNMP::Info";
my $layers = $info->layers();
my $desc = $info->description();
# if we dont have sysServices, we dont have anything else either probably.
return undef unless (defined $layers and length($layers));
my $desc = $info->description();
# Layer 3 Supported
# (usually has layer2 as well, so we check for 3 first)
if ($info->has_layer(3)) {
@@ -1140,6 +1155,20 @@ sub _global{
$DEBUG and print "SNMP::Info::_global $attr : $oid\n";
my $val = $sess->get($oid);
if ($sess->{ErrorStr} ){
$DEBUG and print "SNMP::Info::_global($attr) $sess->{ErrorStr}\n";
return undef;
}
if (defined $val and $val eq 'NOSUCHOBJECT'){
$DEBUG and print "SNMP::Info::_global($attr) NOSUCHOBJECT\n";
return undef;
}
if (defined $val and $val eq 'NOSUCHINSTANCE'){
$DEBUG and print "SNMP::Info::_global($attr) NOSUCHINSTANCE\n";
return undef;
}
# Get the callback hash for data munging
my $munge = $self->munge();
@@ -1190,6 +1219,9 @@ sub _set {
my $rv = $sess->set($oid,$val);
print "SNMP::Info::_set $attr$iid $sess->{ErrorStr}\n"
if ($DEBUG and $sess->{ErrorStr});
return $rv;
}
@@ -1275,6 +1307,15 @@ sub _load_attr {
next;
}
if ($val eq 'NOSUCHOBJECT'){
$DEBUG and print "SNMP::Info::_load_atr: $attr : NOSUCHOBJECT\n" ;
next;
}
if ($val eq 'NOSUCHINSTANCE'){
$DEBUG and print "SNMP::Info::_load_atr: $attr : NOSUCHINSTANCE\n" ;
next;
}
# Data Munging
# Checks for an entry in %munge and runs the subroutine
if (defined $munge->{$attr}){

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Bridge;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::CDP;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -73,11 +73,20 @@ $INIT = 0;
);
%MUNGE = (
'c_capabilities' => \&SNMP::Info::munge_octet2hex,
'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 hasCDP {
my $cdp = shift;
@@ -103,8 +112,11 @@ 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.
SNMP::Info::CDP is a subclass of SNMP::Info that provides an object oriented
interface to CDP information through SNMP.
CDP is a Layer 2 protocol that supplies topology information of devices that also speak CDP,
mostly switches and routers.
=head1 AUTHOR
@@ -112,38 +124,19 @@ Max Baker (C<max@warped.org>)
=head1 SYNOPSIS
my $cdp = new SNMP::Info::CDP( DestHost => 'router' ,
Community => 'public' );
my $info = new SNMP::Info ( DestHost => 'router',
Community => 'public'
);
my $type = $info->device_type();
my $cdp = new $type ( DestHost => 'router',
Community => 'public);
$hascdp = $cdp->hasCDP() ? 'yes' : 'no';
@neighbor_ips = values( %{$cdp->ip()} );
@neighbor_ips = values( %{$cdp->c_ip()} );
=head1 CREATING AN OBJECT
=over
=item new SNMP::Info::CDP()
Arguments passed to new() are passed on to SNMP::Session::new()
my $cdp = new SNMP::Info::CDP(
DestHost => $host,
Community => 'public'
)
die "Couldn't connect.\n" unless defined $cdp;
=item $cdp->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $cdp->session();
# Set
my $newsession = new SNMP::Session(...);
$cdp->session($newsession);
=back
See L<SNMP::Info> for all inherited methods.
=head2 Your Device May Vary
@@ -230,9 +223,33 @@ Returns remote platform id
=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>)

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::EtherLike;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -68,9 +68,10 @@ SNMP::Info::EtherLike - Perl5 Interface to SNMP ETHERLIKE-MIB
=head1 DESCRIPTION
ETHERLIKE-MIB is used by some Layer 3 Devices such as Cisco routers.
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.
Inherits all methods from SNMP::Info
Use SNMP::Info directly, or create a subclass that inherits this one.
=head1 AUTHOR
@@ -100,17 +101,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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);
=back
=head1 GLOBALS

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -170,8 +170,6 @@ SNMP::Info::Layer1 - Perl5 Interface to Layer1 network devices.
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
@@ -207,17 +205,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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);
=back
=head1 GLOBALS

View File

@@ -1,7 +1,7 @@
# SNMP::Info::Layer1::Allied
# Max Baker <max@warped.org>
#
# Copyright (c) 2002, Regents of the University of California
# 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 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Allied;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -152,17 +152,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
die "Couldn't connect.\n" unless defined $allied;
=item $allied->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $allied->session();
# Set
my $newsession = new SNMP::Session(...);
$allied->session($newsession);
=back
=head1 GLOBALS

View File

@@ -1,7 +1,7 @@
# SNMP::Info::Layer1::Asante
# Max Baker <max@warped.org>
#
# Copyright (c) 2002, Regents of the University of California
# 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 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer1::Asante;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -195,17 +195,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
die "Couldn't connect.\n" unless defined $asante;
=item $asante->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $asante->session();
# Set
my $newsession = new SNMP::Session(...);
$asante->session($newsession);
=back
=head1 GLOBALS

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -211,17 +211,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
die "Couldn't connect.\n" unless defined $l2;
=item $l2->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $l2->session();
# Set
my $newsession = new SNMP::Session(...);
$l2->session($newsession);
=back
=head1 GLOBALS

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Bay;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -276,17 +276,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C1900;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -192,17 +192,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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

View File

@@ -1,7 +1,7 @@
# SNMP::Info::Layer2::C2900
# Max Baker <max@warped.org>
#
# Copyright (c) 2002, Regents of the University of California
# 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 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::C2900;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -174,17 +174,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::Catalyst;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -183,6 +183,7 @@ sub i_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;
@@ -288,17 +289,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer2::HP;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -69,17 +69,17 @@ $INIT = 0;
%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_hwver' => 'entPhysicalHardwareRev',
'e_map' => 'entAliasMappingIdentifier',
'e_model' => 'entPhysicalModelName',
'e_name' => 'entPhysicalName',
'e_parent' => 'entPhysicalContainedIn',
'e_serial' => 'entPhysicalSerialNum',
'e_swver' => 'entPhysicalSoftwareRev',
'e_type' => 'entPhysicalVendorType',
# RFC1271
'l_descr' => 'logDescription'
@@ -131,6 +131,7 @@ sub serial {
# procurve 2xxx have this
my $serial = $hp->serial1();
return undef unless defined $serial;
# 4xxx dont
return undef if $serial =~ /nosuchobject/i;
@@ -336,26 +337,6 @@ 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;
#
#}
1;
__END__
@@ -390,6 +371,8 @@ Max Baker (C<max@warped.org>)
my $hp = new SNMP::Info::Layer2::HP(DestHost => 'router' ,
Community => 'public' );
See SNMP::Info and SNMP::Info::Layer2 for all the inherited methods.
=head1 CREATING AN OBJECT
=over
@@ -406,176 +389,126 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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->log()
=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>)
Returns all the log entries from the switch's log that are not Link up or down messages.
=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->serial()
=item $hp->ps2_status()
(B<chassisPs2Status>)
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
=head1 HP Table Values
=head2 Module table
=head2 Entity Table
=over
=item $hp->m_type(), $hp->load_m_type()
(B<moduleType>)
=item $hp->e_class()
=item $hp->m_model(), $hp->load_m_model()
(B<moduleModel>)
(C<entPhysicalClass>)
=item $hp->m_serial(), $hp->load_m_serial()
(B<moduleSerialNumber>)
=item $hp->e_descr()
=item $hp->m_status(), $hp->load_m_status()
(B<moduleStatus>)
(C<entPhysicalClass>)
=item $hp->m_name(), $hp->load_m_name()
(B<moduleName>)
=item $hp->e_fwver()
=item $hp->m_ports(), $hp->load_m_ports()
(B<moduleNumPorts>)
(C<entPhysicalFirmwareRev>)
=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->e_hwver()
(B<modulePortStatus>)
(C<entPhysicalHardwareRev>)
=item $hp->m_ports_hwver(), $hp->load_m_ports_hwver()
(B<moduleHwVersion>)
=item $hp->e_map()
=item $hp->m_ports_fwver(), $hp->load_m_ports_fwver()
(B<moduleFwVersion>)
(C<entAliasMappingIdentifier>)
=item $hp->m_ports_swver(), $hp->load_m_ports_swver()
(B<moduleSwVersion>)
=item $hp->e_model()
=item $hp->m_ports_ip(), $hp->load_m_ports_ip()
(B<moduleIPAddress>)
(C<entPhysicalModelName>)
=item $hp->m_ports_sub1(), $hp->load_m_ports_sub1()
(B<moduleSubType>)
=item $hp->e_name()
=item $hp->m_ports_sub2(), $hp->load_m_ports_sub2()
(B<moduleSubType2>)
(C<entPhysicalName>)
=item $hp->e_parent()
(C<entPhysicalContainedIn>)
=item $hp->e_port()
Maps EntityTable entries to the Interface Table (IfTable) using
$hp->e_map()
=item $hp->e_serial()
(C<entPhysicalSerialNum>)
=item $hp->e_swver()
(C<entPhysicalSoftwareRev>)
=item $hp->e_type()
(C<entPhysicalVendorType>)
=back
=head2 Port Entry Table
=head2 Overriden Methods from SNMP::Info::Layer2
=over
=item $hp->p_name(), $hp->load_p_name()
(B<portName>)
=item $hp->interfaces()
=item $hp->p_type(), $hp->load_p_type()
(B<portType>)
=item $hp->i_duplex()
=item $hp->p_status(), $hp->load_p_status()
(B<portOperStatus>)
Maps $hp->mau_index() with $hp->mau_link(). Methods inherited from
SNMP::Info::MAU.
=item $hp->p_status2(), $hp->load_p_status2()
(B<portAdditionalStatus>)
=item $hp->i_duplex_admin()
=item $hp->p_speed(), $hp->load_p_speed()
(B<portAdminSpeed>)
Maps $hp->mau_index() with $hp->mau_auto(), $hp->mau_autostat(),
$hp->typeadmin(), and $mau_autosent(). Methods inherited from
SNMP::Info::MAU.
=item $hp->p_duplex(), $hp->load_p_duplex()
(B<portDuplex>)
=item $hp->i_name()
=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>)
Crosses i_name() with $hp->e_name() using $hp->e_port() and i_alias()
=item $hp->i_type()
Crosses i_type() with $hp->e_descr() using $hp->e_port()
=back

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -273,17 +273,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
die "Couldn't connect.\n" unless defined $l3;
=item $l3->session()
Sets or returns the SNMP::Session object
# Get
my $sess = $l3->session();
# Set
my $newsession = new SNMP::Session(...);
$l3->session($newsession);
=back
=head1 GLOBALS

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Aironet;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -221,17 +221,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
die "Couldn't connect.\n" unless defined $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);
=back
=head1 Globals

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::C3550;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -217,6 +217,9 @@ Max Baker (C<max@warped.org>)
my $c3550 = new SNMP::Info::Layer3::C3550(DestHost => 'router' ,
Community => 'public' );
See L<SNMP::Info> and L<SNMP::Info::Layer3> for all the inherited methods.
=head1 CREATING AN OBJECT
=over
@@ -233,17 +236,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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);
=back
=head1 GLOBAL Values

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::Layer3::Foundry;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -242,6 +242,8 @@ Max Baker (C<max@warped.org>)
my $foundry = new SNMP::Info::Layer3::Foundry(DestHost => 'switch' ,
Community => 'public' );
See L<SNMP::Info> and L<SNMP::Info::Layer3> for all inherited methods.
=head1 CREATING AN OBJECT
=over
@@ -258,17 +260,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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);
=back
=head1 GLOBAL VALUES

View File

@@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package SNMP::Info::MAU;
$VERSION = 0.2;
$VERSION = 0.3;
# $Id$
use strict;
@@ -144,24 +144,6 @@ Arguments passed to new() are passed on to SNMP::Session::new()
)
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.
=back
=head1 MAU Global Configuration Values

View File

@@ -5,7 +5,8 @@ use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'SNMP::Info',
'VERSION_FROM' => 'Info.pm',
'PREREQ_PM' => {'SNMP' => '4'},
# SNMP not available on CPAN -- not installable by CPAN
# 'PREREQ_PM' => {'SNMP' => '4'},
($] >= 5.005 ?
(ABSTRACT_FROM => 'Info.pm',
AUTHOR => 'Max Baker <max@warped.org>')

16
README
View File

@@ -4,7 +4,7 @@ NAME
VERSION
SNMP::Info - Version 0.2
SNMP::Info - Version 0.3
AUTHOR
@@ -61,7 +61,11 @@ SYNOPSIS
# Find out the Duplex status for the ports
my $interfaces = $more_specific_device->interfaces();
my $i_duplex = $more_specific_device->i_duplex();
# Get CDP Neighbor info
my $c_ip = $more_specific_device->c_ip();
my $c_port = $more_specific_device->c_port();
foreach my $iid (keys %$interfaces){
my $duplex = $i_duplex->{$iid};
@@ -69,8 +73,12 @@ SYNOPSIS
# Print out physical port name, not snmp iid
my $port = $interfaces->{$iid};
print "$port : $duplex\n";
my $neighbor_ip = $c_ip->{$iid};
my $neighbor_port = $c_port->{$iid};
print "$port: Duplex $duplex\n";
print " Neighbor : $neighbor_ip \@ $neighbor_port\n";
}
REQUIREMENTS

18
test.pl
View File

@@ -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";