Send netdisco-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/netdisco-users
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of netdisco-users digest..."
Today's Topics:

   1. Add serial number from servers and workstations to Netdisco's
      devices (Carsten Emde)
--- Begin Message ---
Hi,

The Perl SNMP library provides a general mechanism for retrieving the serial 
number of servers and workstations via the "SNMP::Info::Layer3::NetSNMP" class, 
rather than using the manufacturers' own OIDs as it is normally the case with 
switches. Specifically, the string from the OID ‘entPhysicalDescr’ is searched 
for the pattern “/serial#?:\s*([a-z0-9]+)/i” (see 
perl5/lib/perl5/SNMP/Info/Entity.pm around line 131); if this pattern is found, 
the match is used as serial number. This would work perfectly well if the 
developers of the Perl SNMP library and those of Netdisco had agreed on the 
name of the function to retrieve the serial number obtained in this way. In the 
library, this is “e_serial” while Netdisco always uses “serial” The below patch 
resolves this discrepancy. This patch is successfully used in a server 
installation where replacement servers were sometimes deployed to temporarily 
replace faulty hardware. The goal is to be able to track the hardware using the 
serial number, and there is indeed a dedicated field for this in the Neighbors 
map popup. However, without this patch, that field remains empty. For some 
servers and workstations, additional steps may be required to ensure that the 
OID “entPhysicalDescr” returns a valid and parseable version string, for 
example, by using the “pass” directive in the snmpd configuration.

Index: Netdisco/Worker/Plugin/Discover/Properties.pm
===================================================================
--- Netdisco.orig/Worker/Plugin/Discover/Properties.pm
+++ Netdisco/Worker/Plugin/Discover/Properties.pm
@@ -73,7 +73,14 @@ register_worker({ phase => 'early', driv
   );
 
   foreach my $property (keys %utf8_properties) {
-      my $val = $snmp->$property;
+      my $useproperty;
+      if ($property eq 'serial' && $snmp->class eq 
'SNMP::Info::Layer3::NetSNMP') {
+          $useproperty = 'e_serial';
+      }
+      else {
+          $useproperty = $property;
+      }
+      my $val = $snmp->$useproperty;
       $val = [values %$val]->[0] if ref $val eq 'HASH';
       ($val = Encode::decode('UTF-8', ($val || ''))) =~ s/\s+$//;
       $val = undef if $val and $val =~ m/^HASH\(/;

Thanks,
carsten



--- End Message ---
_______________________________________________
Netdisco mailing list - Digest Mode
[email protected]
https://lists.sourceforge.net/lists/listinfo/netdisco-users

Reply via email to