#888 add 1.0.8802.1.1 and 1.3.111.2.802 to the SNMP browser

This commit is contained in:
Oliver Gorwits
2022-08-03 13:03:55 +01:00
parent b40c30606e
commit fd42aff447
4 changed files with 13 additions and 12 deletions

View File

@@ -424,13 +424,13 @@ Pass a device in C<-d> to display them:
=head2 snapshot =head2 snapshot
Performs an snmp walk from L<.1.3.6.1> on the device and builds a data Performs snmp walks from C<.1.3.6.1>, C<1.0.8802.1.1>, and C<1.3.111.2.802> on
structure which SNMP::Info can use to mimic the device. The structure is the device and builds a data structure which SNMP::Info can use to mimic the
saved into the L<device_snapshot> database table. device. The structure is saved into the C<device_snapshot> 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<NETDISCO_HOME/logs/snapshots/IP> base64 encoded data will also be saved to L<NETDISCO_HOME/logs/snapshots/IP>
(where L<IP> is the canonical IP of the device passed). Netdisco will load (where C<IP> is the canonical IP of the device passed). Netdisco will load
this for any pseudo device with the same canonical IP. this for any pseudo device with the same canonical IP.
~/bin/netdisco-do snapshot -d 192.0.2.1 -p yes ~/bin/netdisco-do snapshot -d 192.0.2.1 -p yes

View File

@@ -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 $recurse = ((param('recurse') and param('recurse') eq 'on') ? 0 : 1);
my $base = param('base'); 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); 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; return to_json [] unless $found;
$found = $found->oid; $found = $found->oid;
$found =~ s/^\.1\.3\.6\.1\.?//; $found =~ s/^\.1\.?//;
my @results = ('.1.3.6.1'); my @results = ('.1');
foreach my $part (split m/\./, $found) { foreach my $part (split m/\./, $found) {
my $last = $results[-1]; my $last = $results[-1];
@@ -98,7 +98,7 @@ ajax '/ajax/content/device/:ip/snmpnode/:oid' => require_login sub {
or send_error('Bad Device', 404); or send_error('Bad Device', 404);
my $oid = param('oid'); 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') my $object = schema('netdisco')->resultset('DeviceBrowser')
->with_snmp_object($device->ip)->find({ 'snmp_object.oid' => $oid }) ->with_snmp_object($device->ip)->find({ 'snmp_object.oid' => $oid })

View File

@@ -63,7 +63,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
value => do { my $m = $oidmap{$_}; encode_base64( nfreeze( [$snmp->$m] ) ); }, value => do { my $m = $oidmap{$_}; encode_base64( nfreeze( [$snmp->$m] ) ); },
}} sort {sortable_oid($a) cmp sortable_oid($b)} }} sort {sortable_oid($a) cmp sortable_oid($b)}
grep {not $seenoid{$_}++} grep {not $seenoid{$_}++}
grep {m/^\.1\.3\.6\.1/} grep {m/^\.1/}
map {s/^_//; $_} map {s/^_//; $_}
keys %cache; keys %cache;
@@ -271,9 +271,10 @@ sub walker {
($vars) = $sess->bulkwalk( 0, $repeaters, $var ); ($vars) = $sess->bulkwalk( 0, $repeaters, $var );
if ( $sess->{ErrorNum} ) { if ( $sess->{ErrorNum} ) {
debug "snapshot $device BULKWALK " . $sess->{ErrorStr}; debug "snapshot $device BULKWALK " . $sess->{ErrorStr};
debug "snapshot $device disabling BULKWALK"; debug "snapshot $device disabling BULKWALK and trying again...";
$vars = []; $vars = [];
$bulkwalk = 0; $bulkwalk = 0;
$snmp->{BulkWalk} = 0;
delete $sess->{ErrorNum}; delete $sess->{ErrorNum};
delete $sess->{ErrorStr}; delete $sess->{ErrorStr};
} }

View File

@@ -84,7 +84,7 @@
'data' : { 'data' : {
'url' : function (node) { 'url' : function (node) {
return ('[% uri_base | none %]/ajax/data/device/[% device %]/snmptree/' 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');
} }
} }
}, },