From c24e63ec4c819b0b7b0aa41d941cf2ea737a3efa Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 10 Jun 2014 13:12:08 +0100 Subject: [PATCH] Return serial number for Cisco 3850 from entPhysicalSerialNum --- ChangeLog | 8 ++++++++ Info/Layer2/CiscoSB.pm | 12 ++++-------- Info/Layer3/C6500.pm | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index d44e385e..b2188e52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,14 @@ version 3.15 () * Offline mode and Cache export/priming. + [ENHANCEMENTS] + + * Return serial number for Cisco 3850 from entPhysicalSerialNum + + [BUG FIXES] + + * Cisco SB serial number probably did not work + version 3.14 (2014-06-07) [ENHANCEMENTS] diff --git a/Info/Layer2/CiscoSB.pm b/Info/Layer2/CiscoSB.pm index 72932cba..584f4a03 100644 --- a/Info/Layer2/CiscoSB.pm +++ b/Info/Layer2/CiscoSB.pm @@ -98,21 +98,17 @@ sub vendor { return 'cisco'; } -# Walk the entPhysicalSerialNum table and return both the first serial -# number found as well as the index of that entry. +# Walk the entPhysicalSerialNum table and return the first serial found sub serial { my $ciscosb = shift; - my $serial = undef; my $e_serial = $ciscosb->e_serial(); # Find entity table entry for this unit - foreach my $e ( keys %$e_serial ) { - if (defined ($e_serial->{$e}) and $e_serial->{$e} !~ /^\s*$/) { - $index = $e; - last; + foreach my $e ( sort keys %$e_serial ) { + if (defined $e_serial->{$e} and $e_serial->{$e} !~ /^\s*$/) { + return $e_serial->{$e}; } } - return $e_serial->{$index} if defined $index; } sub os_ver { diff --git a/Info/Layer3/C6500.pm b/Info/Layer3/C6500.pm index 65812290..d3e08872 100644 --- a/Info/Layer3/C6500.pm +++ b/Info/Layer3/C6500.pm @@ -134,6 +134,23 @@ sub vendor { sub cisco_comm_indexing { return 1; } +sub serial { + my $c6500 = shift; + + my $serial = $c6500->SUPER::serial(); + return $serial if defined $serial and $serial; + + # now grab the table only if SUPER cannot find it + my $e_serial = $c6500->e_serial(); + + # Find entity table entry for this unit + foreach my $e ( sort keys %$e_serial ) { + if (defined $e_serial->{$e} and $e_serial->{$e} !~ /^\s*$/) { + return $e_serial->{$e}; + } + } +} + # Newer versions use the ETHERLIKE-MIB to report operational duplex. sub i_duplex { @@ -389,6 +406,10 @@ Returns the Switch status: multiNode or standalone. Return 1 if the switch (C) is in multimode (VSS). +=item $c6500->serial() + +Returns serial number of unit (falls back to C). + =back =head2 Global Methods imported from SNMP::Info::CiscoVTP