Formatting + scrut updates

This commit is contained in:
laf
2015-07-16 16:01:51 +01:00
parent 7eed295897
commit 6ec525c222
4 changed files with 22 additions and 20 deletions

View File

@@ -35,14 +35,14 @@ if ($src['hostname'] == $config['own_hostname']) {
$filename = $filename_dir . $device['hostname'].'.rrd';
if (!file_exists($filename_dir.$device['hostname'].'.rrd')) {
// Try with dots in hostname replaced by underscores
$filename = $filename_dir . str_replace(".", "_", $device['hostname']).'.rrd';
$filename = $filename_dir . str_replace('.', '_', $device['hostname']).'.rrd';
}
}
else {
$filename = $filename_dir . $device['hostname'] .'~'.$src['hostname'].'.rrd';
if (!file_exists($filename)) {
// Try with dots in hostname replaced by underscores
$filename = $filename_dir . str_replace(".", "-", $device['hostname']) .'~'.$src['hostname'].'.rrd';
$filename = $filename_dir . str_replace('.', '-', $device['hostname']) .'~'.$src['hostname'].'.rrd';
}
}

View File

@@ -71,7 +71,7 @@ if ($vars['view'] == 'incoming') {
}
if (is_numeric($host['device_id'])) {
echo '<tr><td>';
echo('<h3>'.generate_device_link($dest).'</h3>');
echo '<h3>'.generate_device_link($dest).'</h3>';
$graph_array['type'] = 'smokeping_in';
$graph_array['device'] = $device['device_id'];
$graph_array['src'] = $host['device_id'];

View File

@@ -701,21 +701,22 @@ function get_graph_subtypes($type) {
function get_smokeping_files($device) {
global $config;
$smokeping_files = array();
if (isset($config['smokeping']['dir'])) {
$smokeping_files = array();
$smokeping_dir = generate_smokeping_file($device);
if ($handle = opendir($smokeping_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (eregi(".rrd", $file)) {
if (eregi("~", $file)) {
list($target,$slave) = explode("~", str_replace(".rrd", "", $file));
$target = str_replace("_", ".", $target);
if ($file != '.' && $file != '..') {
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);
}
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;
}
@@ -731,7 +732,8 @@ function generate_smokeping_file($device,$file='') {
global $config;
if ($config['smokeping']['integration'] === true) {
return $config['smokeping']['dir'] .'/'. $device['type'] .'/' . $file;
} else {
}
else {
return $config['smokeping']['dir'] . '/' . $file;
}
}

View File

@@ -22,14 +22,14 @@ title = Network Latency Grapher
<?php
foreach (dbFetchRows("SELECT `type` FROM `devices` WHERE `ignore` = 0 AND `disabled` = 0 AND `type` != '' GROUP BY `type`") as $groups) {
echo ("+ " . $groups['type'] . PHP_EOL);
echo ("menu = " . $groups['type'] . PHP_EOL);
echo ("title = " . $groups['type'] . PHP_EOL);
echo '+ ' . $groups['type'] . PHP_EOL;
echo 'menu = ' . $groups['type'] . PHP_EOL;
echo 'title = ' . $groups['type'] . PHP_EOL;
foreach (dbFetchRows("SELECT `hostname` FROM `devices` WHERE `type` = ? AND `ignore` = 0 AND `disabled` = 0", array($groups['type'])) as $devices) {
//Dot needs to be replaced, since smokeping doesn't accept it at this level
echo("++ " . str_replace(".","_",$devices['hostname']) . PHP_EOL);
echo("menu = " . $devices['hostname'] . PHP_EOL);
echo("title = " . $devices['hostname'] . PHP_EOL);
echo("host = " . $devices['hostname'] . PHP_EOL . PHP_EOL);
echo '++ ' . str_replace(".","_",$devices['hostname']) . PHP_EOL;
echo 'menu = ' . $devices['hostname'] . PHP_EOL;
echo 'title = ' . $devices['hostname'] . PHP_EOL;
echo 'host = ' . $devices['hostname'] . PHP_EOL . PHP_EOL;
}
}