From d5fe0a8050b41906f3b6c0fd4bf5fcb36500eb6a Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 27 Mar 2015 21:42:23 +0000 Subject: [PATCH 1/2] 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 3b23be7e9..6c40dfb04 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 2/2] 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 6c40dfb04..2a23caaa4 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 ); }