From c28bbd572817aaea72c25b6f5eed04b06c8095d9 Mon Sep 17 00:00:00 2001 From: Jeroen van Ingen <> Date: Mon, 26 Jul 2010 11:32:48 +0000 Subject: [PATCH] Changes to Info.pm to support devices that don't return sysServices.0 --- Info.pm | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Info.pm b/Info.pm index 765e3371..9c16acd6 100644 --- a/Info.pm +++ b/Info.pm @@ -1165,13 +1165,22 @@ sub device_type { my $objtype = "SNMP::Info"; - my $layers = $info->layers(); - - # if we dont have sysServices, we dont have anything else either probably. - return unless ( defined $layers and length($layers) ); + my $layers = $info->layers() || '00000000'; my $desc = $info->description() || 'undef'; $desc =~ s/[\r\n\l]+/ /g; + + # Some devices don't implement sysServices, but do return a description. + # In that case, log a warning and continue. + if ( !$layers ) { + if ($desc ne 'undef') { + carp("Device doesn't implement sysServices but did return sysDescr. Might give unexpected results.\n") if $info->debug(); + } else { + # No sysServices, no sysDescr + return undef; + } + } + my $id = $info->id() || 'undef'; # Hash for generic fallback to a device class if unable to determine using @@ -1195,7 +1204,7 @@ sub device_type { 6486 => 'SNMP::Info::Layer3::AlcatelLucent', 6527 => 'SNMP::Info::Layer3::Timetra', 8072 => 'SNMP::Info::Layer3::NetSNMP', - 12325 => 'SNMP::Info::Layer3::Pf', + 12325 => 'SNMP::Info::Layer3::Pf', 30065 => 'SNMP::Info::Layer3::Arista', ); @@ -1433,6 +1442,14 @@ sub device_type { $objtype = 'SNMP::Info::Layer3::CiscoFWSM' if ( $desc =~ /Cisco Firewall Services Module/i ); + # Generic device classification based upon sysObjectID + if ( defined($id) ) { + if ( defined $l3sysoidmap{$id} ) { + $objtype = $l3sysoidmap{$id}; + } elsif ( defined $l2sysoidmap{$id}) { + $objtype = $l2sysoidmap{$id}; + } + } } return $objtype;