#475 fix discover plugins do not respect ignore* config

This commit is contained in:
Oliver Gorwits
2019-01-02 22:36:59 +00:00
parent de27866077
commit ccb0f0c78a
7 changed files with 80 additions and 8 deletions

View File

@@ -32,6 +32,10 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
};
}
# cache the device ports to save hitting the database for many single rows
my $device_ports = vars->{'device_ports'}
|| { map {($_->port => $_)} $device->ports->all };
my $interfaces = $snmp->interfaces;
my $p_ifindex = $snmp->peth_port_ifindex;
my $p_admin = $snmp->peth_port_admin;
@@ -42,11 +46,16 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
# build device port power info suitable for DBIC
my @portpower;
foreach my $entry (keys %$p_ifindex) {
my $port = $interfaces->{ $p_ifindex->{$entry} };
next unless $port;
# WRT #475 this is SAFE because we check against known ports below
my $port = $interfaces->{ $p_ifindex->{$entry} } or next;
if (!defined $device_ports->{$port}) {
info sprintf ' [%s] power - local port %s not in database!',
$device->ip, $port;
next;
}
my ($module) = split m/\./, $entry;
push @portpower, {
port => $port,
module => $module,