mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
WebUI: Fixed URL of detailed graphs for jitter SLA probe (#11984)
* Fix single SLA page * Update slas.inc.php blank lines at the start and end of control structure
This commit is contained in:
@@ -10,6 +10,8 @@ if ($sla['owner']) {
|
||||
|
||||
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr']));
|
||||
|
||||
$rrd_options .= " -l 0 ";
|
||||
|
||||
$rrd_options .= " COMMENT:'Round Trip Time Cur Min Max\\n'";
|
||||
$rrd_options .= " DEF:rtt=$rrd_filename:rtt:AVERAGE ";
|
||||
$rrd_options .= ' VDEF:avg=rtt,AVERAGE ';
|
||||
|
||||
@@ -14,21 +14,21 @@
|
||||
$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));
|
||||
|
||||
require 'includes/html/graphs/common.inc.php';
|
||||
$rrd_options .= ' -l 0 -E ';
|
||||
$rrd_options .= ' -l 0 ';
|
||||
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
$rrd_options .= " COMMENT:' Cur Min Max Avg\\n'";
|
||||
|
||||
$rrd_options .= " DEF:SD=" . $rrd_filename . ":PacketLossSD:AVERAGE ";
|
||||
$rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst (ms) ' ";
|
||||
$rrd_options .= " LINE1.25:SD#FF3300:'Src to Dst (pkts) ' ";
|
||||
$rrd_options .= " GPRINT:SD:LAST:'%5.2lf' ";
|
||||
$rrd_options .= " GPRINT:SD:MIN:'%5.2lf' ";
|
||||
$rrd_options .= " GPRINT:SD:MAX:'%5.2lf' ";
|
||||
$rrd_options .= " GPRINT:SD:AVERAGE:'%5.2lf'\\\l ";
|
||||
|
||||
$rrd_options .= " DEF:DS=" . $rrd_filename . ":PacketLossDS:AVERAGE ";
|
||||
$rrd_options .= " LINE1.25:DS#008C00:'Dst to Src (ms) ' ";
|
||||
$rrd_options .= " LINE1.25:DS#FF6633:'Dst to Src (pkts) ' ";
|
||||
$rrd_options .= " GPRINT:DS:LAST:'%5.2lf' ";
|
||||
$rrd_options .= " GPRINT:DS:MIN:'%5.2lf' ";
|
||||
$rrd_options .= " GPRINT:DS:MAX:'%5.2lf' ";
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$sla = dbFetchRow('SELECT `sla_nr`,`rtt_type` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));
|
||||
|
||||
?>
|
||||
<div class="well well-sm">
|
||||
<!-- Need some kind of header here to represent the SLA -->
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default" id="ipsla">
|
||||
<?php
|
||||
|
||||
// All SLA's support the RTT metric
|
||||
include 'sla/rtt.inc.php';
|
||||
|
||||
// Load the per-type SLA metrics
|
||||
$rtt_type = basename($sla['rtt_type']);
|
||||
if (file_exists("includes/html/pages/device/sla/$rtt_type.inc.php")) {
|
||||
include "includes/html/pages/device/sla/$rtt_type.inc.php";
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
@@ -1,121 +1,154 @@
|
||||
<?php
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
$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'];
|
||||
|
||||
$sla_types[$sla_type] = !in_array($sla_type, $sla_types) ? \LibreNMS\Config::get("sla_type_labels.$sla_type", 'Unknown') : ucfirst($sla_type);
|
||||
}
|
||||
asort($sla_types);
|
||||
|
||||
$status_options = array(
|
||||
'all' => 'All',
|
||||
'up' => 'Up',
|
||||
'down' => 'Down',
|
||||
);
|
||||
|
||||
echo "<span style='font-weight: bold;'>SLA</span> » ";
|
||||
|
||||
// SLA Types, on the left.
|
||||
$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);
|
||||
|
||||
// The status option - on the right
|
||||
echo '<div class="pull-right">';
|
||||
echo "<span style='font-weight: bold;'>Status</span> » ";
|
||||
$sep = '';
|
||||
foreach ($status_options as $option => $text) {
|
||||
if (empty($vars['opstatus'])) {
|
||||
$vars['opstatus'] = $option;
|
||||
}
|
||||
echo $sep;
|
||||
if ($vars['opstatus'] == $option) {
|
||||
echo "<span class='pagemenu-selected'>";
|
||||
}
|
||||
|
||||
echo generate_link($text, $vars, array('opstatus' => $option));
|
||||
if ($vars['opstatus'] == $option) {
|
||||
echo '</span>';
|
||||
}
|
||||
$sep = ' | ';
|
||||
}
|
||||
unset($sep);
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
foreach ($slas as $sla) {
|
||||
if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$opstatus = ($sla['opstatus'] === 0) ? 'up' : 'down';
|
||||
d_echo("<br>Opstatus :: var: ".$vars['opstatus'].", db: ".$sla['opstatus'].", name: ".$opstatus."<br>");
|
||||
if ($vars['opstatus'] != 'all' && $vars['opstatus'] != $opstatus) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = 'SLA #'.$sla['sla_nr'].' - '.$sla_types[$sla['rtt_type']];
|
||||
if ($vars['id']) {
|
||||
$sla = dbFetchRow('SELECT `tag`, `sla_nr`,`rtt_type` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));
|
||||
$name = 'SLA #' . $sla['sla_nr'] . ' - ' . \LibreNMS\Config::get("sla_type_labels.{$sla['rtt_type']}", ucfirst($sla['rtt_type']));
|
||||
if ($sla['tag']) {
|
||||
$name .= ': '.$sla['tag'];
|
||||
$name .= ': ' . $sla['tag'];
|
||||
}
|
||||
|
||||
if ($sla['owner']) {
|
||||
$name .= ' (Owner: '.$sla['owner'].')';
|
||||
$name .= ' (Owner: ' . $sla['owner'] . ')';
|
||||
}
|
||||
|
||||
// These Types have more graphs. Display a sub-page
|
||||
if (($sla['rtt_type'] == 'jitter') || ($sla['rtt_type'] == 'icmpjitter')) {
|
||||
$name = '<a href="'.generate_url($vars, array('tab' => "sla", 'id' => $sla['sla_id'])).'">'.$name.'</a>';
|
||||
} else {
|
||||
$name = htmlentities($name);
|
||||
}
|
||||
|
||||
// If we have an error highlight the row.
|
||||
if ($sla['opstatus'] == 2) {
|
||||
$danger = "panel-danger";
|
||||
} else {
|
||||
$danger = '';
|
||||
}
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = \LibreNMS\Config::get('time.now');
|
||||
$graph_array['type'] = 'device_sla';
|
||||
$graph_array['id'] = $sla['sla_id'];
|
||||
echo '<div class="panel panel-default '.$danger.'">
|
||||
echo "<div class=\"well well-sm\"><h3 class=\"panel-title\">$name</h3></div>";
|
||||
|
||||
echo '<div class="panel panel-default ' . $danger . '">';
|
||||
|
||||
// All SLA's support the RTT metric
|
||||
include 'sla/rtt.inc.php';
|
||||
|
||||
// Load the per-type SLA metrics
|
||||
$rtt_type = basename($sla['rtt_type']);
|
||||
if (file_exists("includes/html/pages/device/sla/$rtt_type.inc.php")) {
|
||||
include "includes/html/pages/device/sla/$rtt_type.inc.php";
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
} else {
|
||||
print_optionbar_start();
|
||||
|
||||
$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'];
|
||||
|
||||
$sla_types[$sla_type] = !in_array($sla_type, $sla_types) ? \LibreNMS\Config::get("sla_type_labels.$sla_type", 'Unknown') : ucfirst($sla_type);
|
||||
}
|
||||
asort($sla_types);
|
||||
|
||||
$status_options = array(
|
||||
'all' => 'All',
|
||||
'up' => 'Up',
|
||||
'down' => 'Down',
|
||||
);
|
||||
|
||||
echo "<span style='font-weight: bold;'>SLA</span> » ";
|
||||
|
||||
// SLA Types, on the left.
|
||||
$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);
|
||||
|
||||
// The status option - on the right
|
||||
echo '<div class="pull-right">';
|
||||
echo "<span style='font-weight: bold;'>Status</span> » ";
|
||||
$sep = '';
|
||||
foreach ($status_options as $option => $text) {
|
||||
if (empty($vars['opstatus'])) {
|
||||
$vars['opstatus'] = $option;
|
||||
}
|
||||
echo $sep;
|
||||
if ($vars['opstatus'] == $option) {
|
||||
echo "<span class='pagemenu-selected'>";
|
||||
}
|
||||
|
||||
echo generate_link($text, $vars, array('opstatus' => $option));
|
||||
if ($vars['opstatus'] == $option) {
|
||||
echo '</span>';
|
||||
}
|
||||
$sep = ' | ';
|
||||
}
|
||||
unset($sep);
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
foreach ($slas as $sla) {
|
||||
if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$opstatus = ($sla['opstatus'] === 0) ? 'up' : 'down';
|
||||
d_echo("<br>Opstatus :: var: " . $vars['opstatus'] . ", db: " . $sla['opstatus'] . ", name: " . $opstatus . "<br>");
|
||||
if ($vars['opstatus'] != 'all' && $vars['opstatus'] != $opstatus) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = 'SLA #' . $sla['sla_nr'] . ' - ' . $sla_types[$sla['rtt_type']];
|
||||
if ($sla['tag']) {
|
||||
$name .= ': ' . $sla['tag'];
|
||||
}
|
||||
|
||||
if ($sla['owner']) {
|
||||
$name .= ' (Owner: ' . $sla['owner'] . ')';
|
||||
}
|
||||
|
||||
// These Types have more graphs. Display a sub-page
|
||||
if (($sla['rtt_type'] == 'jitter') || ($sla['rtt_type'] == 'icmpjitter')) {
|
||||
$name = '<a href="' . generate_url($vars, array('tab' => "slas", 'id' => $sla['sla_id'])) . '">' . $name . '</a>';
|
||||
} else {
|
||||
$name = htmlentities($name);
|
||||
}
|
||||
|
||||
// If we have an error highlight the row.
|
||||
if ($sla['opstatus'] == 2) {
|
||||
$danger = "panel-danger";
|
||||
} else {
|
||||
$danger = '';
|
||||
}
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = \LibreNMS\Config::get('time.now');
|
||||
$graph_array['type'] = 'device_sla';
|
||||
$graph_array['id'] = $sla['sla_id'];
|
||||
echo '<div class="panel panel-default ' . $danger . '">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.$name.'</h3>
|
||||
<h3 class="panel-title">' . $name . '</h3>
|
||||
</div>
|
||||
<div class="panel-body">';
|
||||
echo "<div class='row'>";
|
||||
include 'includes/html/print-graphrow.inc.php';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo "<div class='row'>";
|
||||
include 'includes/html/print-graphrow.inc.php';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$pagetitle[] = 'SLAs';
|
||||
|
||||
Reference in New Issue
Block a user