Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUI: Fixed URL of detailed graphs for jitter SLA probe #11984

Merged
merged 2 commits into from Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions includes/html/graphs/device/sla.inc.php
Expand Up @@ -10,6 +10,8 @@

$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 ';
Expand Down
6 changes: 3 additions & 3 deletions includes/html/graphs/device/sla_jitter-loss.inc.php
Expand Up @@ -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' ";
Expand Down
35 changes: 0 additions & 35 deletions includes/html/pages/device/sla.inc.php

This file was deleted.

227 changes: 130 additions & 97 deletions includes/html/pages/device/slas.inc.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> &#187; ";

// SLA Types, on the left.
$sep = '';
foreach ($sla_types as $sla_type => $text) {
if (!$vars['view']) {
$vars['view'] = $sla_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'];
}

echo $sep;
if ($vars['view'] == $sla_type) {
echo "<span class='pagemenu-selected'>";
if ($sla['owner']) {
$name .= ' (Owner: ' . $sla['owner'] . ')';
}

echo generate_link($text, $vars, array('view' => $sla_type));
if ($vars['view'] == $sla_type) {
echo '</span>';
if ($sla['opstatus'] == 2) {
$danger = "panel-danger";
} else {
$danger = '';
}

$sep = ' | ';
}
unset($sep);

// The status option - on the right
echo '<div class="pull-right">';
echo "<span style='font-weight: bold;'>Status</span> &#187; ";
$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 "<div class=\"well well-sm\"><h3 class=\"panel-title\">$name</h3></div>";

echo generate_link($text, $vars, array('opstatus' => $option));
if ($vars['opstatus'] == $option) {
echo '</span>';
}
$sep = ' | ';
}
unset($sep);
echo '<div class="panel panel-default ' . $danger . '">';

print_optionbar_end();
// All SLA's support the RTT metric
include 'sla/rtt.inc.php';

foreach ($slas as $sla) {
if ($vars['view'] != 'all' && $vars['view'] != $sla['rtt_type']) {
continue;
// 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";
}

$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;
}
echo '</div>';
} else {
print_optionbar_start();

$name = 'SLA #'.$sla['sla_nr'].' - '.$sla_types[$sla['rtt_type']];
if ($sla['tag']) {
$name .= ': '.$sla['tag'];
}
$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 ORDER BY `sla_nr`', array($device['device_id']));

if ($sla['owner']) {
$name .= ' (Owner: '.$sla['owner'].')';
}
// Collect types
$sla_types = array('all' => 'All');
foreach ($slas as $sla) {
$sla_type = $sla['rtt_type'];

// 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);
$sla_types[$sla_type] = !in_array($sla_type, $sla_types) ? \LibreNMS\Config::get("sla_type_labels.$sla_type", 'Unknown') : ucfirst($sla_type);
}

// If we have an error highlight the row.
if ($sla['opstatus'] == 2) {
$danger = "panel-danger";
} else {
$danger = '';
asort($sla_types);

$status_options = array(
'all' => 'All',
'up' => 'Up',
'down' => 'Down',
);

echo "<span style='font-weight: bold;'>SLA</span> &#187; ";

// 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 = ' | ';
}

$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.'">
unset($sep);

// The status option - on the right
echo '<div class="pull-right">';
echo "<span style='font-weight: bold;'>Status</span> &#187; ";
$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';