mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add bad_ifoperstatus for filtering interfaces having a status for example 'notPresent' (#10977)
* Add bad_ifoperstatus for filtering interfaces having a status for example notPresent * Add bad_ifoperstatus for filtering interfaces having a status for example notPresent * Add bad_ifoperstatus for filtering interfaces having a status for example notPresent
This commit is contained in:
@@ -8,6 +8,7 @@ $port_stats = snmpwalk_cache_oid($device, 'ifDescr', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifName', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifAlias', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifType', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifOperStatus', $port_stats, 'IF-MIB');
|
||||
|
||||
// End Building SNMP Cache Array
|
||||
d_echo($port_stats);
|
||||
|
@@ -1042,7 +1042,7 @@ function include_dir($dir, $regex = "")
|
||||
|
||||
/**
|
||||
* Check if port is valid to poll.
|
||||
* Settings: empty_ifdescr, good_if, bad_if, bad_if_regexp, bad_ifname_regexp, bad_ifalias_regexp, bad_iftype
|
||||
* Settings: empty_ifdescr, good_if, bad_if, bad_if_regexp, bad_ifname_regexp, bad_ifalias_regexp, bad_iftype, bad_ifoperstatus
|
||||
*
|
||||
* @param array $port
|
||||
* @param array $device
|
||||
@@ -1069,6 +1069,7 @@ function is_port_valid($port, $device)
|
||||
$ifName = $port['ifName'];
|
||||
$ifAlias = $port['ifAlias'];
|
||||
$ifType = $port['ifType'];
|
||||
$ifOperStatus = $port['ifOperStatus'];
|
||||
|
||||
if (str_i_contains($ifDescr, Config::getOsSetting($device['os'], 'good_if'))) {
|
||||
return true;
|
||||
@@ -1095,7 +1096,6 @@ function is_port_valid($port, $device)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (Config::getCombined($device['os'], 'bad_ifalias_regexp') as $bar) {
|
||||
if (preg_match($bar ."i", $ifAlias)) {
|
||||
d_echo("ignored by ifName: $ifAlias (matched: $bar)\n");
|
||||
@@ -1110,6 +1110,13 @@ function is_port_valid($port, $device)
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Config::getCombined($device['os'], 'bad_ifoperstatus') as $bos) {
|
||||
if (str_contains($ifOperStatus, $bos)) {
|
||||
d_echo("ignored by ifOperStatus: $ifOperStatus (matched: $bos)\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user