From 36ec1316336da2c2f32e160d52c2915fb3130bad Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 27 Mar 2015 19:54:03 +0000 Subject: [PATCH 1/4] Fixed the issue with ports constantly logging descr changes --- includes/polling/ports.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index ddb7fe3667..183381945d 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -277,8 +277,15 @@ foreach ($ports as $port) $attrib_key = "port_descr_".$attrib; if ($port_ifAlias[$attrib] != $port[$attrib_key]) { + if (!isset($port_ifAlias[$attrib])) { + $port_ifAlias[$attrib] = array('NULL'); + $log_port = 'NULL'; + } else { + $log_port = $port_ifAlias[$attrib]; + } $port['update'][$attrib_key] = $port_ifAlias[$attrib]; - log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device, 'interface', $port['port_id']); + log_event($attrib . ": ".$port[$attrib_key]." -> " . $log_port, $device, 'interface', $port['port_id']); + unset($log_port); } } } From 6455f3924e3fc363e457ab3f4b0d9e5dec5cbb41 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 27 Mar 2015 20:13:41 +0000 Subject: [PATCH 2/4] This is a proper fix for PR 623 + 625 --- includes/polling/ports.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index ddb7fe3667..7f38382b2f 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -253,12 +253,12 @@ foreach ($ports as $port) // Update IF-MIB data foreach ($data_oids as $oid) { - if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid]) && $this_port['ifAdminStatus'] != 'down') + if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) { - $port['update'][$oid] = NULL; + $port['update'][$oid] = array('NULL'); log_event($oid . ": ".$port[$oid]." -> NULL", $device, 'interface', $port['port_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); } - } elseif ($port[$oid] != $this_port[$oid] && $this_port['ifAdminStatus'] != 'down') { + } elseif ($port[$oid] != $this_port[$oid]) { $port['update'][$oid] = $this_port[$oid]; log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device, 'interface', $port['port_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); } From d5fe0a8050b41906f3b6c0fd4bf5fcb36500eb6a Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 27 Mar 2015 21:42:23 +0000 Subject: [PATCH 3/4] Shorten interface names into Fa, Gi, Te --- includes/rrdtool.inc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 3b23be7e9d..6c40dfb045 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -251,7 +251,9 @@ function rrdtool_escape($string, $maxlength = NULL) $result = str_replace('%','%%',$result); // FIXME: should maybe also probably escape these? # \ + ? [ ^ ] ( $ ) ' - + + $result = shorten_interface_type($result); + if ($maxlength != NULL) { return substr(str_pad($result, $maxlength),0,$maxlength+(strlen($result)-strlen($string))); @@ -262,4 +264,13 @@ function rrdtool_escape($string, $maxlength = NULL) } } +function shorten_interface_type($string) { + + return str_ireplace( + array('FastEthernet','GigbitEthernet','TenGigabitEthernet'), + array('Fa','Gi','Te'), + $string + ); +} + ?> From e94c2385882abadcb1756af73901a904dff909c0 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 27 Mar 2015 22:22:11 +0000 Subject: [PATCH 4/4] Added some more examples --- includes/rrdtool.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 6c40dfb045..2a23caaa47 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -267,8 +267,8 @@ function rrdtool_escape($string, $maxlength = NULL) function shorten_interface_type($string) { return str_ireplace( - array('FastEthernet','GigbitEthernet','TenGigabitEthernet'), - array('Fa','Gi','Te'), + array('FastEthernet','GigbitEthernet','TenGigabitEthernet','Port-Channel','Ethernet'), + array('Fa','Gi','Te','Po','Eth'), $string ); }