From fd42aff447a982713e60ae63ba623cb49f2ac3c2 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 3 Aug 2022 13:03:55 +0100 Subject: [PATCH] #888 add 1.0.8802.1.1 and 1.3.111.2.802 to the SNMP browser --- bin/netdisco-do | 10 +++++----- lib/App/Netdisco/Web/Plugin/Device/SNMP.pm | 8 ++++---- lib/App/Netdisco/Worker/Plugin/Snapshot.pm | 5 +++-- share/views/ajax/device/snmp.tt | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bin/netdisco-do b/bin/netdisco-do index 19190d04..949f6c18 100755 --- a/bin/netdisco-do +++ b/bin/netdisco-do @@ -424,13 +424,13 @@ Pass a device in C<-d> to display them: =head2 snapshot -Performs an snmp walk from L<.1.3.6.1> on the device and builds a data -structure which SNMP::Info can use to mimic the device. The structure is -saved into the L database table. +Performs snmp walks from C<.1.3.6.1>, C<1.0.8802.1.1>, and C<1.3.111.2.802> on +the device and builds a data structure which SNMP::Info can use to mimic the +device. The structure is saved into the C database table. -Optionally, pass a value to the L<-p> parameter (mnemonic: persist) and the +Optionally, pass a value to the C<-p> parameter (mnemonic: persist) and the base64 encoded data will also be saved to L -(where L is the canonical IP of the device passed). Netdisco will load +(where C is the canonical IP of the device passed). Netdisco will load this for any pseudo device with the same canonical IP. ~/bin/netdisco-do snapshot -d 192.0.2.1 -p yes diff --git a/lib/App/Netdisco/Web/Plugin/Device/SNMP.pm b/lib/App/Netdisco/Web/Plugin/Device/SNMP.pm index 2b1a3efe..83af45f4 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/SNMP.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/SNMP.pm @@ -33,7 +33,7 @@ ajax '/ajax/data/device/:ip/snmptree/:base' => require_login sub { my $recurse = ((param('recurse') and param('recurse') eq 'on') ? 0 : 1); my $base = param('base'); - $base =~ m/^\.1\.3\.6\.1(\.\d+)*$/ or send_error('Bad OID Base', 404); + $base =~ m/^\.1(\.\d+)*$/ or send_error('Bad OID Base', 404); my $items = _get_snmp_data($device->ip, $base, $recurse); @@ -80,8 +80,8 @@ ajax '/ajax/data/device/:ip/snmpnodesearch' => require_login sub { return to_json [] unless $found; $found = $found->oid; - $found =~ s/^\.1\.3\.6\.1\.?//; - my @results = ('.1.3.6.1'); + $found =~ s/^\.1\.?//; + my @results = ('.1'); foreach my $part (split m/\./, $found) { my $last = $results[-1]; @@ -98,7 +98,7 @@ ajax '/ajax/content/device/:ip/snmpnode/:oid' => require_login sub { or send_error('Bad Device', 404); my $oid = param('oid'); - $oid =~ m/^\.1\.3\.6\.1(\.\d+)*$/ or send_error('Bad OID', 404); + $oid =~ m/^\.1(\.\d+)*$/ or send_error('Bad OID', 404); my $object = schema('netdisco')->resultset('DeviceBrowser') ->with_snmp_object($device->ip)->find({ 'snmp_object.oid' => $oid }) diff --git a/lib/App/Netdisco/Worker/Plugin/Snapshot.pm b/lib/App/Netdisco/Worker/Plugin/Snapshot.pm index 7357d2fa..e6e0cde3 100644 --- a/lib/App/Netdisco/Worker/Plugin/Snapshot.pm +++ b/lib/App/Netdisco/Worker/Plugin/Snapshot.pm @@ -63,7 +63,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { value => do { my $m = $oidmap{$_}; encode_base64( nfreeze( [$snmp->$m] ) ); }, }} sort {sortable_oid($a) cmp sortable_oid($b)} grep {not $seenoid{$_}++} - grep {m/^\.1\.3\.6\.1/} + grep {m/^\.1/} map {s/^_//; $_} keys %cache; @@ -271,9 +271,10 @@ sub walker { ($vars) = $sess->bulkwalk( 0, $repeaters, $var ); if ( $sess->{ErrorNum} ) { debug "snapshot $device BULKWALK " . $sess->{ErrorStr}; - debug "snapshot $device disabling BULKWALK"; + debug "snapshot $device disabling BULKWALK and trying again..."; $vars = []; $bulkwalk = 0; + $snmp->{BulkWalk} = 0; delete $sess->{ErrorNum}; delete $sess->{ErrorStr}; } diff --git a/share/views/ajax/device/snmp.tt b/share/views/ajax/device/snmp.tt index 125328d0..bc44fdca 100644 --- a/share/views/ajax/device/snmp.tt +++ b/share/views/ajax/device/snmp.tt @@ -84,7 +84,7 @@ 'data' : { 'url' : function (node) { return ('[% uri_base | none %]/ajax/data/device/[% device %]/snmptree/' - + (node.id === '#' ? '.1.3.6.1' : node.id) + '?recurse=on'); + + (node.id === '#' ? '.1' : node.id) + '?recurse=on'); } } },