From 20ddcab9c125b586336c63cb5c9e9898d4600cb3 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Sun, 31 Jan 2010 17:03:22 +0000 Subject: [PATCH] allow ignoring comments in rancid showconfig git-svn-id: http://www.observium.org/svn/observer/trunk@752 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 2 ++ html/pages/device/showconfig.inc.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config.php.default b/config.php.default index 4a795422cf..e898225854 100755 --- a/config.php.default +++ b/config.php.default @@ -104,6 +104,8 @@ $config['enable_pseudowires'] = 1; # Enable Pseudowires $config['enable_ports_etherlike'] = 0; # Enable Polling EtherLike-MIB (doubles interface processing time) #$config['rancid_configs'] = '/var/lib/rancid/network/configs/'; +$config['rancid_ignorecomments'] = 0; # Ignore lines starting with # + #$config['collectd_dir'] = '/var/lib/collectd/rrd'; ## If a syslog entry contails these strings it is deleted from the database diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index d703e2de54..a4b7368059 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -2,10 +2,19 @@ include("includes/geshi/geshi.php"); -if($_SESSION[userlevel] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) { +if($_SESSION['userlevel'] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) { $file = $config['rancid_configs'] . $device['hostname']; $fh = fopen($file, 'r') or die("Can't open file"); $text = fread($fh, filesize($file)); + if ($config['rancid_ignorecomments']) + { + $lines = split("\n",$text); + for ($i = 0;$i < count($lines);$i++) + { + if ($lines[$i][0] == "#") { unset($lines[$i]); } + } + $text = join("\n",$lines); + } $language = "ios"; $geshi = new GeSHi($text, $language); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);