From d7d7d917a82aac413e03fa5e088b19ee71d99b41 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 28 Nov 2008 12:59:33 +0000 Subject: [PATCH] updates git-svn-id: http://www.observium.org/svn/observer/trunk@328 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/rewrites.php | 108 ++++++++++++++++++++++++++++++++++++++++++ includes/syslog.php | 13 +++++ 2 files changed, 121 insertions(+) create mode 100644 includes/rewrites.php diff --git a/includes/rewrites.php b/includes/rewrites.php new file mode 100644 index 000000000..700c9dfce --- /dev/null +++ b/includes/rewrites.php @@ -0,0 +1,108 @@ + 'Te', + 'gigabitethernet' => 'Gi', + 'fastethernet' => 'Fa', + 'ethernet' => 'Et', + 'serial' => 'Se', + 'pos' => 'Pos', + 'port-channel' => 'Po', + 'atm' => 'Atm', + 'null' => 'Null', + 'loopback' => 'Lo', + 'dialer' => 'Di', + 'vlan' => 'Vlan', + 'tunnel' => 'Tunnel', + ); + + $rewrite_iftype = array ( + '/^frameRelay$/' => 'Frame Relay', + '/^ethernetCsmacd$/' => 'Ethernet', + '/^softwareLoopback$/' => 'Loopback', + '/^tunnel$/' => 'Tunnel', + '/^propVirtual$/' => 'Virtual Int', + '/^ppp$/' => 'PPP', + '/^ds1$/' => 'DS1', + '/^pos$/' => 'POS', + '/^sonet$/' => 'SONET', + '/^slip$/' => 'SLIP', + '/^mpls$/' => 'MPLS Layer', + '/^l2vlan$/' => 'VLAN Subif', + '/^atm$/' => 'ATM', + '/^aal5$/' => 'ATM AAL5', + '/^atmSubInterface$/' => 'ATM Subif', + '/^propPointToPointSerial$/' => 'PtP Serial', + ); + + $rewrite_ifname = array ( + 'ether' => 'Ether', + 'gig' => 'Gig', + 'fast' => 'Fast', + 'ten' => 'Ten', + '-802.1q vlan subif' => '', + '-802.1q' => '', + 'bvi' => 'BVI', + 'vlan' => 'Vlan', + 'ether' => 'Ether', + 'tunnel' => 'Tunnel', + 'serial' => 'Serial', + '-aal5 layer' => ' aal5', + 'null' => 'Null', + 'atm' => 'ATM', + 'port-channel' => 'Port-Channel', + 'dial' => 'Dial', + 'hp procurve switch software loopback interface' => 'Loopback Interface', + 'control plane interface' => 'Control Plane', + 'loop' => 'Loop', + ); + +// Specific rewrite functions + +function makeshortif($if) +{ + global $rewrite_shortif; + $if = fixifName ($if); + $if = strtolower($if); + $if = array_str_replace($rewrite_shortif, $if); + return $if; +} + +function fixiftype ($type) +{ + global $rewrite_iftype; + $type = array_preg_replace($rewrite_iftype, $type); + return ($type); +} + +function fixifName ($inf) +{ + global $rewrite_ifname; + $inf = strtolower($inf); + $inf = array_str_replace($rewrite_ifname, $inf); + return $inf; +} + + +// Underlying rewrite functions + + + function array_str_replace($array, $string) + { + foreach ($array as $search => $replace) { + $string = str_replace($search, $replace, $string); + } + return $string; + } + + function array_preg_replace($array, $string) + { + foreach ($array as $search => $replace) { + $string = preg_replace($search, $replace, $string); + } + return $string; + } + + + +?> diff --git a/includes/syslog.php b/includes/syslog.php index eb888a688..d65673e64 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -29,8 +29,21 @@ function process_syslog ($entry, $update) { $entry['msg'] = "%" . $entry['msg']; $entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); } else { $entry['msg'] = "||" . $entry['msg']; } + $entry['msg'] = preg_replace("/^.+\.[0-9]{3}:/", "", $entry['msg']); + $entry['msg'] = preg_replace("/^.+-Traceback=/", "Traceback||", $entry['msg']); + list($entry['program'], $entry['msg']) = explode("||", $entry['msg']); $entry['msg'] = preg_replace("/^[0-9]+:/", "", $entry['msg']); + + if(!$entry['program']) { + $entry['msg'] = preg_replace("/^([0-9A-Z\-]+?):\ /", "\\1||", $entry['msg']); + list($entry['program'], $entry['msg']) = explode("||", $entry['msg']); + } + + if(!$entry['msg']) { $entry['msg'] = $entry['program']; } + + + } else { $program = preg_quote($entry['program'],'/'); $entry['msg'] = preg_replace("/^$program:\ /", "", $entry['msg']);