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
This commit is contained in:
Adam Amstrong
2012-04-09 13:03:42 +00:00
parent 8c88728143
commit 7ffe4f2de1
4 changed files with 24 additions and 0 deletions

View File

@@ -8,10 +8,12 @@
if (eregi(".rrd", $file)) { if (eregi(".rrd", $file)) {
if (eregi("~", $file)) { if (eregi("~", $file)) {
list($target,$slave) = explode("~", str_replace(".rrd", "", $file)); list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
$target = str_replace("_", ".", $target);
$smokeping_files['in'][$target][$slave] = $file; $smokeping_files['in'][$target][$slave] = $file;
$smokeping_files['out'][$slave][$target] = $file; $smokeping_files['out'][$slave][$target] = $file;
} else { } else {
$target = str_replace(".rrd", "", $file); $target = str_replace(".rrd", "", $file);
$target = str_replace("_", ".", $target);
$smokeping_files['in'][$target][$config['own_hostname']] = $file; $smokeping_files['in'][$target][$config['own_hostname']] = $file;
$smokeping_files['out'][$config['own_hostname']][$target] = $file; $smokeping_files['out'][$config['own_hostname']][$target] = $file;
} }

View File

@@ -34,8 +34,18 @@ if($width > "500")
if($src['hostname'] == $config['own_hostname']) if($src['hostname'] == $config['own_hostname'])
{ {
$filename = $config['smokeping']['dir'] . $device['hostname'].'.rrd'; $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 { } else {
$filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$src['hostname'].'.rrd'; $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; } if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; }

View File

@@ -34,8 +34,18 @@ if($width > "500")
if($device['hostname'] == $config['own_hostname']) if($device['hostname'] == $config['own_hostname'])
{ {
$filename = $config['smokeping']['dir'] . $dest['hostname'].'.rrd'; $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 { } else {
$filename = $config['smokeping']['dir'] . $dest['hostname'] .'~'.$device['hostname'].'.rrd'; $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; } if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; }

View File

@@ -123,10 +123,12 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
if (eregi("~", $file)) if (eregi("~", $file))
{ {
list($target,$slave) = explode("~", str_replace(".rrd", "", $file)); list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
$target = str_replace("_", ".", $target);
$smokeping_files['in'][$target][$slave] = $file; $smokeping_files['in'][$target][$slave] = $file;
$smokeping_files['out'][$slave][$target] = $file; $smokeping_files['out'][$slave][$target] = $file;
} else { } else {
$target = str_replace(".rrd", "", $file); $target = str_replace(".rrd", "", $file);
$target = str_replace("_", ".", $target);
$smokeping_files['in'][$target][$config['own_hostname']] = $file; $smokeping_files['in'][$target][$config['own_hostname']] = $file;
$smokeping_files['out'][$config['own_hostname']][$target] = $file; $smokeping_files['out'][$config['own_hostname']][$target] = $file;
} }