mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated smokeping to support Rosiaks integration
This commit is contained in:
@@ -38,7 +38,11 @@ foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filena
|
||||
|
||||
$descr = rrdtool_escape($source, $descr_len);
|
||||
|
||||
if ($config['smokeping']['integration'] === true) {
|
||||
$filename = $config['smokeping']['dir'] .'/'. $device['type'] .'/'. $filename;
|
||||
} else {
|
||||
$filename = $config['smokeping']['dir'] . $filename;
|
||||
}
|
||||
$rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE ";
|
||||
$rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE";
|
||||
$rrd_options .= " CDEF:ploss$i=loss$i,$pings,/,100,*";
|
||||
|
@@ -39,7 +39,11 @@ foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filena
|
||||
|
||||
$descr = rrdtool_escape($source, $descr_len);
|
||||
|
||||
if ($config['smokeping']['integration'] === true) {
|
||||
$filename = $config['smokeping']['dir'] .'/'. $device['type'] .'/'. $filename;
|
||||
} else {
|
||||
$filename = $config['smokeping']['dir'] . $filename;
|
||||
}
|
||||
$rrd_options .= " DEF:median$i=".$filename.":median:AVERAGE ";
|
||||
$rrd_options .= " CDEF:dm$i=median$i,UN,0,median$i,IF";
|
||||
$rrd_options .= " DEF:loss$i=".$filename.":loss:AVERAGE";
|
||||
|
@@ -1,26 +1,3 @@
|
||||
<?php
|
||||
|
||||
if (isset($config['smokeping']['dir'])) {
|
||||
$smokeping_files = array();
|
||||
if ($handle = opendir($config['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);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
$smokeping_files = get_smokeping_files($device);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (is_numeric($vars['id']) && ($auth || device_permitted($vars['id'])))
|
||||
if (is_numeric($vars['device']) && ($auth || device_permitted($vars['src'])))
|
||||
{
|
||||
$device = device_by_id_cache($vars['id']);
|
||||
$device = device_by_id_cache($vars['device']);
|
||||
$title = generate_device_link($device);
|
||||
$graph_title = $device['hostname'];
|
||||
$auth = TRUE;
|
||||
|
@@ -33,18 +33,22 @@ if($width > "500")
|
||||
|
||||
if($src['hostname'] == $config['own_hostname'])
|
||||
{
|
||||
$filename = $config['smokeping']['dir'] . $device['hostname'].'.rrd';
|
||||
if (!file_exists($filename))
|
||||
if ($config['smokeping']['integration'] === true) {
|
||||
$filename_dir = $config['smokeping']['dir'] .'/'. $device['type'] .'/';
|
||||
} else {
|
||||
$filename_dir = $config['smokeping']['dir'];
|
||||
}
|
||||
if (!file_exists($filename_dir.$device['hostname'].'.rrd'))
|
||||
{
|
||||
// Try with dots in hostname replaced by underscores
|
||||
$filename = $config['smokeping']['dir'] . str_replace(".", "_", $device['hostname']).'.rrd';
|
||||
$filename = $filename_dir . str_replace(".", "_", $device['hostname']).'.rrd';
|
||||
}
|
||||
} else {
|
||||
$filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$src['hostname'].'.rrd';
|
||||
$filename = $filename_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';
|
||||
$filename = $filename_dir . str_replace(".", "-", $device['hostname']) .'~'.$src['hostname'].'.rrd';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -138,34 +138,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
|
||||
</li>');
|
||||
}
|
||||
|
||||
if (isset($config['smokeping']['dir']))
|
||||
{
|
||||
$smokeping_files = array();
|
||||
if ($handle = opendir($config['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);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$smokeping_files = get_smokeping_files($device);
|
||||
|
||||
if (count($smokeping_files['in'][$device['hostname']]) || count($smokeping_files['out'][$device['hostname']]))
|
||||
{
|
||||
|
@@ -747,4 +747,34 @@ function get_graph_subtypes($type)
|
||||
return $types;
|
||||
}
|
||||
|
||||
?>
|
||||
function get_smokeping_files($device) {
|
||||
global $config;
|
||||
if (isset($config['smokeping']['dir'])) {
|
||||
$smokeping_files = array();
|
||||
if ($config['smokeping']['integration'] === true) {
|
||||
$smokeping_dir = $config['smokeping']['dir'] . "/" . $device['type'];
|
||||
} else {
|
||||
$smokeping_dir = $config['smokeping']['dir'];
|
||||
}
|
||||
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);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $smokeping_files;
|
||||
}
|
||||
|
Reference in New Issue
Block a user