try to safeguard some snmp leaf gather failures
This commit is contained in:
@@ -5,7 +5,7 @@ use App::Netdisco::Worker::Plugin;
|
|||||||
use aliased 'App::Netdisco::Worker::Status';
|
use aliased 'App::Netdisco::Worker::Status';
|
||||||
|
|
||||||
use App::Netdisco::Transport::SNMP ();
|
use App::Netdisco::Transport::SNMP ();
|
||||||
use App::Netdisco::Util::Permission 'check_acl_no';
|
use App::Netdisco::Util::Permission qw/check_acl_no check_acl_only/;
|
||||||
use App::Netdisco::Util::FastResolver 'hostnames_resolve_async';
|
use App::Netdisco::Util::FastResolver 'hostnames_resolve_async';
|
||||||
use App::Netdisco::Util::Device 'get_device';
|
use App::Netdisco::Util::Device 'get_device';
|
||||||
use App::Netdisco::Util::DNS 'hostname_from_ip';
|
use App::Netdisco::Util::DNS 'hostname_from_ip';
|
||||||
@@ -57,6 +57,19 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
|
|||||||
|
|
||||||
$device->set_column( last_discover => \'now()' );
|
$device->set_column( last_discover => \'now()' );
|
||||||
|
|
||||||
|
# protection for failed SNMP gather
|
||||||
|
if ($device->in_storage) {
|
||||||
|
my $ip = $device->ip;
|
||||||
|
my $protect = setting('snmp_field_protection')->{'device'} || {};
|
||||||
|
my %dirty = $device->get_dirty_columns;
|
||||||
|
foreach my $field (keys %dirty) {
|
||||||
|
next unless check_acl_only($ip, ($protect->{$field} || []));
|
||||||
|
if (exists $dirty{$field} and not $dirty{$field}) {
|
||||||
|
return $job->cancel("discover cancelled: $ip failed to return valid $field");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
schema('netdisco')->txn_do(sub {
|
schema('netdisco')->txn_do(sub {
|
||||||
$device->update_or_insert(undef, {for => 'update'});
|
$device->update_or_insert(undef, {for => 'update'});
|
||||||
return Status->done("Ended discover for $device");
|
return Status->done("Ended discover for $device");
|
||||||
|
|||||||
@@ -231,6 +231,9 @@ snmpver: 3
|
|||||||
snmptimeout: 3000000
|
snmptimeout: 3000000
|
||||||
snmpretries: 2
|
snmpretries: 2
|
||||||
snmp_remoteport: {}
|
snmp_remoteport: {}
|
||||||
|
snmp_field_protection:
|
||||||
|
device:
|
||||||
|
serial: ['any']
|
||||||
devices_no: []
|
devices_no: []
|
||||||
devices_only: []
|
devices_only: []
|
||||||
discover_no: []
|
discover_no: []
|
||||||
|
|||||||
Reference in New Issue
Block a user