From 7ffe4f2de10de35d849ca7b77fc61f3e10bb2bf3 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 9 Apr 2012 13:03:42 +0000 Subject: [PATCH] improve smokeping filename detection (see filenames with underscores instead of dots). this is temporary until we "discovery" these rather than look for them on the fly. git-svn-id: http://www.observium.org/svn/observer/trunk@3005 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/device/smokeping_common.inc.php | 2 ++ html/includes/graphs/smokeping/in.inc.php | 10 ++++++++++ html/includes/graphs/smokeping/out.inc.php | 10 ++++++++++ html/pages/device.inc.php | 2 ++ 4 files changed, 24 insertions(+) diff --git a/html/includes/graphs/device/smokeping_common.inc.php b/html/includes/graphs/device/smokeping_common.inc.php index 55d1cfbbf3..c158e8267e 100644 --- a/html/includes/graphs/device/smokeping_common.inc.php +++ b/html/includes/graphs/device/smokeping_common.inc.php @@ -8,10 +8,12 @@ if (eregi(".rrd", $file)) { if (eregi("~", $file)) { list($target,$slave) = explode("~", str_replace(".rrd", "", $file)); + $target = str_replace("_", ".", $target); $smokeping_files['in'][$target][$slave] = $file; $smokeping_files['out'][$slave][$target] = $file; } else { $target = str_replace(".rrd", "", $file); + $target = str_replace("_", ".", $target); $smokeping_files['in'][$target][$config['own_hostname']] = $file; $smokeping_files['out'][$config['own_hostname']][$target] = $file; } diff --git a/html/includes/graphs/smokeping/in.inc.php b/html/includes/graphs/smokeping/in.inc.php index 5456fa7c2b..28ee285286 100644 --- a/html/includes/graphs/smokeping/in.inc.php +++ b/html/includes/graphs/smokeping/in.inc.php @@ -34,8 +34,18 @@ if($width > "500") if($src['hostname'] == $config['own_hostname']) { $filename = $config['smokeping']['dir'] . $device['hostname'].'.rrd'; + if (!file_exists($filename)) + { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'] . str_replace(".", "_", $device['hostname']).'.rrd'; + } } else { $filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$src['hostname'].'.rrd'; + if (!file_exists($filename)) + { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'] . str_replace(".", "-", $device['hostname']) .'~'.$src['hostname'].'.rrd'; + } } if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } diff --git a/html/includes/graphs/smokeping/out.inc.php b/html/includes/graphs/smokeping/out.inc.php index 96147b2241..9165da6c77 100644 --- a/html/includes/graphs/smokeping/out.inc.php +++ b/html/includes/graphs/smokeping/out.inc.php @@ -34,8 +34,18 @@ if($width > "500") if($device['hostname'] == $config['own_hostname']) { $filename = $config['smokeping']['dir'] . $dest['hostname'].'.rrd'; + if (!file_exists($filename)) + { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'] . str_replace(".", "_", $dest['hostname']).'.rrd'; + } } else { $filename = $config['smokeping']['dir'] . $dest['hostname'] .'~'.$device['hostname'].'.rrd'; + if (!file_exists($filename)) + { + // Try with dots in hostname replaced by underscores + $filename = $config['smokeping']['dir'] . str_replace(".", "_", $dest['hostname']) .'~'.$device['hostname'].'.rrd'; + } } if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; } diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 630b003f5c..437fd93787 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -123,10 +123,12 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) if (eregi("~", $file)) { list($target,$slave) = explode("~", str_replace(".rrd", "", $file)); + $target = str_replace("_", ".", $target); $smokeping_files['in'][$target][$slave] = $file; $smokeping_files['out'][$slave][$target] = $file; } else { $target = str_replace(".rrd", "", $file); + $target = str_replace("_", ".", $target); $smokeping_files['in'][$target][$config['own_hostname']] = $file; $smokeping_files['out'][$config['own_hostname']][$target] = $file; }