mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more smokeping
git-svn-id: http://www.observium.org/svn/observer/trunk@2704 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
11
html/includes/graphs/smokeping/auth.inc.php
Normal file
11
html/includes/graphs/smokeping/auth.inc.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (is_numeric($id) && ($config['allow_unauth_graphs'] || device_permitted($id)))
|
||||||
|
{
|
||||||
|
$device = device_by_id_cache($id);
|
||||||
|
$title = generate_device_link($device);
|
||||||
|
$graph_title = $device['hostname'];
|
||||||
|
$auth = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
96
html/includes/graphs/smokeping/in.inc.php
Normal file
96
html/includes/graphs/smokeping/in.inc.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$src = device_by_id_cache($_GET['src']);
|
||||||
|
|
||||||
|
## Dear Tobias. You write in Perl, this makes me hate you forever.
|
||||||
|
## This is my translation of Smokeping's graphing.
|
||||||
|
## Thanks to Bill Fenner for Perl->Human translation:>
|
||||||
|
|
||||||
|
$scale_min = 0;
|
||||||
|
$scale_rigid = TRUE;
|
||||||
|
|
||||||
|
include("includes/graphs/common.inc.php");
|
||||||
|
include("smokeping_common.inc.php");
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$pings = 20;
|
||||||
|
$iter = 0;
|
||||||
|
$colourset = "mixed";
|
||||||
|
|
||||||
|
if($width > "500")
|
||||||
|
{
|
||||||
|
$descr_len = 18;
|
||||||
|
} else {
|
||||||
|
$descr_len = 12 + round(($width - 275) / 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($width > "500")
|
||||||
|
{
|
||||||
|
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'";
|
||||||
|
} else {
|
||||||
|
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($src['hostname'] == $config['own_hostname'])
|
||||||
|
{
|
||||||
|
$filename = $config['smokeping']['dir'] . $device['hostname'].'.rrd';
|
||||||
|
} else {
|
||||||
|
$filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$src['hostname'].'.rrd';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; }
|
||||||
|
$colour = $config['graph_colours'][$colourset][$iter];
|
||||||
|
$iter++;
|
||||||
|
|
||||||
|
$descr = str_replace(":", "\:", substr(str_pad($source, $descr_len),0,$descr_len));
|
||||||
|
|
||||||
|
$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,*";
|
||||||
|
$rrd_options .= " CDEF:dm$i=median$i";
|
||||||
|
# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT";
|
||||||
|
|
||||||
|
/// start emulate Smokeping::calc_stddev
|
||||||
|
foreach (range(1, $pings) as $p)
|
||||||
|
{
|
||||||
|
$rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE";
|
||||||
|
$rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF";
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($pings_options, $m_options, $sdev_options);
|
||||||
|
|
||||||
|
foreach (range(2, $pings) as $p)
|
||||||
|
{
|
||||||
|
$pings_options .= ",p".$i."p".$p.",UN,+";
|
||||||
|
$m_options .= ",p".$i."p".$p.",+";
|
||||||
|
$sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+";
|
||||||
|
}
|
||||||
|
|
||||||
|
$rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-";
|
||||||
|
$rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/";
|
||||||
|
$rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT";
|
||||||
|
// end emulate Smokeping::calc_stddev
|
||||||
|
|
||||||
|
$rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-";
|
||||||
|
$rrd_options .= " CDEF:s2d$i=sdev$i";
|
||||||
|
$rrd_options .= " AREA:dmlow$i";
|
||||||
|
$rrd_options .= " AREA:s2d$i#".$colour."30::STACK";
|
||||||
|
$rrd_options .= " LINE1:dm$i#".$colour.":'$descr'";
|
||||||
|
|
||||||
|
# $rrd_options .= " LINE1:sdev$i#000000:$descr";
|
||||||
|
|
||||||
|
$rrd_options .= " VDEF:avmed$i=median$i,AVERAGE";
|
||||||
|
$rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE";
|
||||||
|
$rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/";
|
||||||
|
$rrd_options .= " VDEF:avmsr$i=msr$i,AVERAGE";
|
||||||
|
|
||||||
|
$rrd_options .= " GPRINT:avmed$i:'%5.1lf%ss'";
|
||||||
|
$rrd_options .= " GPRINT:ploss$i:AVERAGE:'%5.1lf%%'";
|
||||||
|
|
||||||
|
$rrd_options .= " GPRINT:avsd$i:'%5.1lf%Ss'";
|
||||||
|
$rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
?>
|
96
html/includes/graphs/smokeping/out.inc.php
Normal file
96
html/includes/graphs/smokeping/out.inc.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dest = device_by_id_cache($_GET['dest']);
|
||||||
|
|
||||||
|
## Dear Tobias. You write in Perl, this makes me hate you forever.
|
||||||
|
## This is my translation of Smokeping's graphing.
|
||||||
|
## Thanks to Bill Fenner for Perl->Human translation:>
|
||||||
|
|
||||||
|
$scale_min = 0;
|
||||||
|
$scale_rigid = TRUE;
|
||||||
|
|
||||||
|
include("includes/graphs/common.inc.php");
|
||||||
|
include("smokeping_common.inc.php");
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$pings = 20;
|
||||||
|
$iter = 0;
|
||||||
|
$colourset = "mixed";
|
||||||
|
|
||||||
|
if($width > "500")
|
||||||
|
{
|
||||||
|
$descr_len = 18;
|
||||||
|
} else {
|
||||||
|
$descr_len = 12 + round(($width - 275) / 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($width > "500")
|
||||||
|
{
|
||||||
|
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'";
|
||||||
|
} else {
|
||||||
|
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)." RTT Loss SDev RTT\:SDev \l'";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($device['hostname'] == $config['own_hostname'])
|
||||||
|
{
|
||||||
|
$filename = $config['smokeping']['dir'] . $dest['hostname'].'.rrd';
|
||||||
|
} else {
|
||||||
|
$filename = $config['smokeping']['dir'] . $device['hostname'] .'~'.$dest['hostname'].'.rrd';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($config['graph_colours'][$colourset][$iter])) { $iter = 0; }
|
||||||
|
$colour = $config['graph_colours'][$colourset][$iter];
|
||||||
|
$iter++;
|
||||||
|
|
||||||
|
$descr = str_replace(":", "\:", substr(str_pad($source, $descr_len),0,$descr_len));
|
||||||
|
|
||||||
|
$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,*";
|
||||||
|
$rrd_options .= " CDEF:dm$i=median$i";
|
||||||
|
# $rrd_options .= " CDEF:dm$i=median$i,0,".$max->{$start}.",LIMIT";
|
||||||
|
|
||||||
|
/// start emulate Smokeping::calc_stddev
|
||||||
|
foreach (range(1, $pings) as $p)
|
||||||
|
{
|
||||||
|
$rrd_options .= " DEF:pin".$i."p".$p."=".$filename.":ping".$p.":AVERAGE";
|
||||||
|
$rrd_options .= " CDEF:p".$i."p".$p."=pin".$i."p".$p.",UN,0,pin".$i."p".$p.",IF";
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($pings_options, $m_options, $sdev_options);
|
||||||
|
|
||||||
|
foreach (range(2, $pings) as $p)
|
||||||
|
{
|
||||||
|
$pings_options .= ",p".$i."p".$p.",UN,+";
|
||||||
|
$m_options .= ",p".$i."p".$p.",+";
|
||||||
|
$sdev_options .= ",p".$i."p".$p.",m".$i.",-,DUP,*,+";
|
||||||
|
}
|
||||||
|
|
||||||
|
$rrd_options .= " CDEF:pings".$i."=".$pings .",p".$i."p1,UN". $pings_options . ",-";
|
||||||
|
$rrd_options .= " CDEF:m".$i."=p".$i."p1".$m_options.",pings".$i.",/";
|
||||||
|
$rrd_options .= " CDEF:sdev".$i."=p".$i."p1,m".$i.",-,DUP,*".$sdev_options.",pings".$i.",/,SQRT";
|
||||||
|
// end emulate Smokeping::calc_stddev
|
||||||
|
|
||||||
|
$rrd_options .= " CDEF:dmlow$i=dm$i,sdev$i,2,/,-";
|
||||||
|
$rrd_options .= " CDEF:s2d$i=sdev$i";
|
||||||
|
$rrd_options .= " AREA:dmlow$i";
|
||||||
|
$rrd_options .= " AREA:s2d$i#".$colour."30::STACK";
|
||||||
|
$rrd_options .= " LINE1:dm$i#".$colour.":'$descr'";
|
||||||
|
|
||||||
|
# $rrd_options .= " LINE1:sdev$i#000000:$descr";
|
||||||
|
|
||||||
|
$rrd_options .= " VDEF:avmed$i=median$i,AVERAGE";
|
||||||
|
$rrd_options .= " VDEF:avsd$i=sdev$i,AVERAGE";
|
||||||
|
$rrd_options .= " CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/";
|
||||||
|
$rrd_options .= " VDEF:avmsr$i=msr$i,AVERAGE";
|
||||||
|
|
||||||
|
$rrd_options .= " GPRINT:avmed$i:'%5.1lf%ss'";
|
||||||
|
$rrd_options .= " GPRINT:ploss$i:AVERAGE:'%5.1lf%%'";
|
||||||
|
|
||||||
|
$rrd_options .= " GPRINT:avsd$i:'%5.1lf%Ss'";
|
||||||
|
$rrd_options .= " GPRINT:avmsr$i:'%5.1lf%s\\l'";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
?>
|
@@ -31,6 +31,7 @@ unset($sep);
|
|||||||
|
|
||||||
print_optionbar_end();
|
print_optionbar_end();
|
||||||
|
|
||||||
|
echo('<table>');
|
||||||
|
|
||||||
if($vars['view'] == "incoming")
|
if($vars['view'] == "incoming")
|
||||||
{
|
{
|
||||||
@@ -41,7 +42,35 @@ if($vars['view'] == "incoming")
|
|||||||
$graph_array['type'] = "device_smokeping_in_all";
|
$graph_array['type'] = "device_smokeping_in_all";
|
||||||
$graph_array['id'] = $device['device_id'];
|
$graph_array['id'] = $device['device_id'];
|
||||||
|
|
||||||
|
$graph_array['legend'] = no;
|
||||||
|
|
||||||
|
echo('<tr><td>');
|
||||||
|
echo('<h3>Aggregate</h3>');
|
||||||
include("includes/print-quadgraphs.inc.php");
|
include("includes/print-quadgraphs.inc.php");
|
||||||
|
echo('</td></tr>');
|
||||||
|
|
||||||
|
unset($graph_array['legend']);
|
||||||
|
|
||||||
|
|
||||||
|
ksort($smokeping_files['in'][$device['hostname']]);
|
||||||
|
foreach($smokeping_files['in'][$device['hostname']] AS $src => $host)
|
||||||
|
{
|
||||||
|
echo("$src -> $host");
|
||||||
|
$hostname = str_replace(".rrd", "", $host);
|
||||||
|
$host = device_by_name($src);
|
||||||
|
if(is_numeric($host['device_id']))
|
||||||
|
{
|
||||||
|
echo('<tr><td>');
|
||||||
|
echo('<h3>'.generate_device_link($host).'</h3>');
|
||||||
|
$graph_array['type'] = "smokeping_in";
|
||||||
|
$graph_array['id'] = $device['device_id'];
|
||||||
|
$graph_array['src'] = $host['device_id'];
|
||||||
|
include("includes/print-quadgraphs.inc.php");
|
||||||
|
echo('</td></tr>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,19 +81,37 @@ if($vars['view'] == "incoming")
|
|||||||
|
|
||||||
$graph_array['type'] = "device_smokeping_out_all";
|
$graph_array['type'] = "device_smokeping_out_all";
|
||||||
$graph_array['id'] = $device['device_id'];
|
$graph_array['id'] = $device['device_id'];
|
||||||
|
$graph_array['legend'] = no;
|
||||||
|
|
||||||
|
echo('<tr><td>');
|
||||||
|
echo('<h3>Aggregate</h3>');
|
||||||
include("includes/print-quadgraphs.inc.php");
|
include("includes/print-quadgraphs.inc.php");
|
||||||
|
echo('</td></tr>');
|
||||||
|
|
||||||
|
unset($graph_array['legend']);
|
||||||
|
|
||||||
foreach($smokeping_files['out'][$device['hostname']] AS $host)
|
asort($smokeping_files['out'][$device['hostname']]);
|
||||||
|
foreach($smokeping_files['out'][$device['hostname']] AS $host)
|
||||||
{
|
{
|
||||||
print_r($);
|
$hostname = str_replace(".rrd", "", $host);
|
||||||
|
$host = device_by_name($hostname);
|
||||||
|
if(is_numeric($host['device_id']))
|
||||||
|
{
|
||||||
|
echo('<tr><td>');
|
||||||
|
echo('<h3>'.generate_device_link($host).'</h3>');
|
||||||
|
$graph_array['type'] = "smokeping_out";
|
||||||
|
$graph_array['id'] = $device['device_id'];
|
||||||
|
$graph_array['dest'] = $host['device_id'];
|
||||||
|
include("includes/print-quadgraphs.inc.php");
|
||||||
|
echo('</td></tr>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo('</table>');
|
||||||
|
|
||||||
$pagetitle[] = "Latency";
|
$pagetitle[] = "Latency";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -275,7 +275,7 @@ function getifhost($id)
|
|||||||
function gethostbyid($id)
|
function gethostbyid($id)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (isset($cache['devices']['id'][$id]['hostname']))
|
if (isset($cache['devices']['id'][$id]['hostname']))
|
||||||
{
|
{
|
||||||
$hostname = $cache['devices']['id'][$id]['hostname'];
|
$hostname = $cache['devices']['id'][$id]['hostname'];
|
||||||
@@ -284,7 +284,7 @@ function gethostbyid($id)
|
|||||||
{
|
{
|
||||||
$hostname = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
$hostname = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hostname;
|
return $hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user