mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added bad ifName and ifAlias regex matching
Allow user to ignore interfaces based on regex matching of ifName and ifAlias values
This commit is contained in:
@@ -400,6 +400,8 @@ by continuing the array.
|
||||
`bad_if` is matched against the ifDescr value.
|
||||
`bad_iftype` is matched against the ifType value.
|
||||
`bad_if_regexp` is matched against the ifDescr value as a regular expression.
|
||||
`bad_ifname_regexp` is matched against the ifName value as a regular expression.
|
||||
`bad_ifalias_regexp` is matched against the ifAlias value as a regular expression.
|
||||
|
||||
#### Interfaces to be rewritten
|
||||
|
||||
|
@@ -873,6 +873,8 @@ function is_port_valid($port, $device) {
|
||||
else {
|
||||
$valid = 1;
|
||||
$if = strtolower($port['ifDescr']);
|
||||
$ifname = strtolower($port['ifName']);
|
||||
$ifalias = strtolower($port['ifAlias']);
|
||||
$fringe = $config['bad_if'];
|
||||
if( is_array($config['os'][$device['os']]['bad_if']) ) {
|
||||
$fringe = array_merge($config['bad_if'],$config['os'][$device['os']]['bad_if']);
|
||||
@@ -894,6 +896,30 @@ function is_port_valid($port, $device) {
|
||||
d_echo("ignored : $bi : ".$if);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($config['bad_ifname_regexp'])) {
|
||||
$fringe = $config['bad_ifname_regexp'];
|
||||
if( is_array($config['os'][$device['os']]['bad_ifname_regexp']) ) {
|
||||
$fringe = array_merge($config['bad_ifname_regexp'],$config['os'][$device['os']]['bad_ifname_regexp']);
|
||||
}
|
||||
foreach ($fringe as $bi) {
|
||||
if (preg_match($bi ."i", $ifname)) {
|
||||
$valid = 0;
|
||||
d_echo("ignored : $bi : ".$ifname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($config['bad_ifalias_regexp'])) {
|
||||
$fringe = $config['bad_ifalias_regexp'];
|
||||
if( is_array($config['os'][$device['os']]['bad_ifalias_regexp']) ) {
|
||||
$fringe = array_merge($config['bad_ifalias_regexp'],$config['os'][$device['os']]['bad_ifalias_regexp']);
|
||||
}
|
||||
foreach ($fringe as $bi) {
|
||||
if (preg_match($bi ."i", $ifalias)) {
|
||||
$valid = 0;
|
||||
d_echo("ignored : $bi : ".$ifalias);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($config['bad_iftype'])) {
|
||||
$fringe = $config['bad_iftype'];
|
||||
|
Reference in New Issue
Block a user