mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
add IPSLA support
git-svn-id: http://www.observium.org/svn/observer/trunk@3002 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$sla = dbFetchRow("SELECT * FROM `slas` WHERE `sla_id` = ?", array($id));
|
||||
$device = device_by_id_cache($sla['device_id']);
|
||||
|
||||
#if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; }
|
||||
$descr_len = intval($_GET['width'] / 8) * 0.8;
|
||||
|
||||
$unit_long = 'milliseconds';
|
||||
$unit = 'ms';
|
||||
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'";
|
||||
|
||||
$name = "";
|
||||
if ($sla['tag'])
|
||||
$name .= $sla['tag'];
|
||||
if ($sla['owner'])
|
||||
$name .= " (Owner: ". $sla['owner'] .")";
|
||||
|
||||
$descr_fixed = substr(str_pad($name, $descr_len-3),0,$descr_len-3);
|
||||
$avg_fixed = substr(str_pad('Average', $descr_len-3),0,$descr_len-3);
|
||||
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sla-" . $sla['sla_nr'] . ".rrd");
|
||||
|
||||
$rrd_options .= " DEF:rtt=$rrd_file:rtt:AVERAGE ";
|
||||
$rrd_options .= " VDEF:avg=rtt,AVERAGE ";
|
||||
$rrd_options .= " LINE1:avg#CCCCFF:'".$avg_fixed."':dashes";
|
||||
$rrd_options .= " GPRINT:rtt:AVERAGE:%4.1lf".$unit."\\\l ";
|
||||
$rrd_options .= " LINE1:rtt#CC0000:'" . str_replace(':','\:',str_replace('\*','*',$descr_fixed)) . "'";
|
||||
$rrd_options .= " GPRINT:rtt:LAST:%4.1lf".$unit." ";
|
||||
$rrd_options .= " GPRINT:rtt:MIN:%4.1lf".$unit." ";
|
||||
$rrd_options .= " GPRINT:rtt:MAX:%4.1lf".$unit."\\\l ";
|
||||
|
||||
?>
|
||||
@@ -100,6 +100,15 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
|
||||
</li>');
|
||||
}
|
||||
|
||||
if (@dbFetchCell("SELECT COUNT(sla_id) FROM slas WHERE device_id = '" . $device['device_id'] . "'") > '0')
|
||||
{
|
||||
echo('<li class="' . $select['slas'] . $select['sla'] . '">
|
||||
<a href="'.generate_device_url($device, array('tab' => 'slas')). '">
|
||||
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> SLAs
|
||||
</a>
|
||||
</li>');
|
||||
}
|
||||
|
||||
if (isset($config['smokeping']['dir']))
|
||||
{
|
||||
$smokeping_files = array();
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
echo("<span style='font-weight: bold;'>SLA</span> » ");
|
||||
|
||||
$slas = dbFetchRows("SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 ORDER BY `sla_nr`", array($device['device_id']));
|
||||
|
||||
// Collect types
|
||||
$sla_types = array('all' => 'All');
|
||||
foreach ($slas as $sla)
|
||||
{
|
||||
$sla_type = $sla['rtt_type'];
|
||||
|
||||
if (!in_array($sla_type, $sla_types))
|
||||
if (isset($config['sla_type_labels'][$sla_type]))
|
||||
{
|
||||
$text = $config['sla_type_labels'][$sla_type];
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = ucfirst($sla_type);
|
||||
}
|
||||
|
||||
$sla_types[$sla_type] = $text;
|
||||
}
|
||||
asort($sla_types);
|
||||
|
||||
$sep = "";
|
||||
foreach ($sla_types as $sla_type => $text)
|
||||
{
|
||||
if (!$vars['view']) { $vars['view'] = $sla_type; }
|
||||
|
||||
echo($sep);
|
||||
if ($vars['view'] == $sla_type)
|
||||
{
|
||||
echo("<span class='pagemenu-selected'>");
|
||||
}
|
||||
echo(generate_link($text,$vars,array('view'=>$sla_type)));
|
||||
if ($vars['view'] == $sla_type)
|
||||
{
|
||||
echo("</span>");
|
||||
}
|
||||
$sep = " | ";
|
||||
}
|
||||
unset($sep);
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
echo('<table>');
|
||||
|
||||
foreach ($slas as $sla)
|
||||
{
|
||||
if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type'])
|
||||
continue;
|
||||
|
||||
$name = "SLA #". $sla['sla_nr'];
|
||||
if ($sla['tag'])
|
||||
$name .= ": ".$sla['tag'];
|
||||
if ($sla['owner'])
|
||||
$name .= " (Owner: ". $sla['owner'] .")";
|
||||
|
||||
$graph_array['type'] = "device_sla";
|
||||
$graph_array['id'] = $sla['sla_id'];
|
||||
echo('<tr><td>');
|
||||
echo('<h3>'.htmlentities($name).'</h3>');
|
||||
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
|
||||
echo('</td></tr>');
|
||||
}
|
||||
|
||||
echo('</table>');
|
||||
|
||||
$pagetitle[] = "SLAs";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user