From 202d02a64aaa8da7ddaf2ec72b81abfe355559c9 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 12 Oct 2021 13:21:07 +0100 Subject: [PATCH] #827 add ignore_interface_types setting --- lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm | 9 ++++++++- share/config.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm index c590174f..2d8bd084 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Properties.pm @@ -239,11 +239,18 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub { } if (exists $i_ignore->{$entry}) { - debug sprintf ' [%s] interfaces - ignoring %s (%s) (%s)', + debug sprintf ' [%s] interfaces - ignoring %s (%s) (%s) (SNMP::Info::i_ignore)', $device->ip, $entry, $port, ($i_type->{$entry} || ''); next; } + # Skip interfaces by type filter + if (defined $i_type->{$entry} and (scalar grep {$i_type->{$entry} =~ m/^$_$/} @{setting('ignore_interface_types') || []})) { + debug sprintf ' [%s] interfaces - ignoring %s (%s) (%s) (config:ignore_interface_types)', + $device->ip, $entry, $port, $i_type->{$entry}; + next; + } + # Skip interfaces which are 'notPresent' and match the notpresent type filter if (defined $i_up->{$entry} and defined $i_type->{$entry} and $i_up->{$entry} eq 'notPresent' and (scalar grep {$i_type->{$entry} =~ m/^$_$/} @{setting('ignore_notpresent_types') || []}) ) { debug sprintf ' [%s] interfaces - ignoring %s (%s) (%s) (config:ignore_notpresent_types)', diff --git a/share/config.yml b/share/config.yml index 026a0792..140e88bd 100644 --- a/share/config.yml +++ b/share/config.yml @@ -311,6 +311,7 @@ ignore_interfaces: - 'Ethernet(?:-| )QOS Packet Scheduler' - 'Ethernet(?:-| )WFP (?:802\.3|Native) MAC Layer Lightweight Filter' - 'ii\d\/\d\/\d+' +ignore_interface_types: [] ignore_notpresent_types: - 'ethernetCsmacd' - 'tunnel'