Files
librenms-librenms/includes/html/pages/device/slas.inc.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

154 lines
4.6 KiB
PHP
Raw Normal View History

<?php
if ($vars['id']) {
$sla = dbFetchRow('SELECT `tag`, `sla_nr`,`rtt_type` FROM `slas` WHERE `sla_id` = ?', [$vars['id']]);
New module add juniper rpm support + reimplementation of cisco-sla module (#12799) * Definition of a new SLA module to migrate from old cisco-sla and support other devices : Juniper RPM and Huawei * Change wrong description name of module SLA * Re implementing Juniper RPM support in a new module Slas (Cisco SLA to be added) * Added Graphs for Juniper RPM types * Tried to make discover and poller generic : to handle Cisco SLA and Juniper RPM and others * Reimplementing Cisco SLA in the new Sla module and adding condition to manage both SLA and RPM * Definition of a new SLA module to migrate from old cisco-sla and support other devices : Juniper RPM and Huawei * Change wrong description name of module SLA * Re implementing Juniper RPM support in a new module Slas (Cisco SLA to be added) * Added Graphs for Juniper RPM types * Tried to make discover and poller generic : to handle Cisco SLA and Juniper RPM and others * Reimplementing Cisco SLA in the new Sla module and adding condition to manage both SLA and RPM * Fix some error due to Elequent object replacing SQL request * Fixing indentation * Fixed continuous integrations errors * Fixed continuous integrations errors part 2 * Fixed continuous integrations errors part 3 : missing last new lines * Fixed PHP Static Analysis checks * Fixed continuous integrations errors part 4 * Fixed PHP Static Analysis checks part 2 * Trying to convert existing cisco-sla to new slas one * Trying to add slas to fix test failure (I am pretty sure this is not enough but I don't know how to do it) * Switching old cisco-sla module declaration to new slas module in concerned OS files * Fixing wrong sla module name instead of slas in concerned OS files * Fixing wrong module name sla changed to slas (as is it in power-supplies reimplementation) * Fixing some warnings shown in the Inspection CI but skipping some that are already present * Adding tests files from virtual Juniper VMX and adding slas modules in /tests/module_tables * Adding missing SNMP data files * Module Slas modifications to use inheritance * Fix CI errors * Fix CI errors part 2 * Fix CI errors part 3 * Fixing no value on RTT graphs * Fixing only last SLA to be polled : problem with loops * Fix CI errors part 4 * Optimizing a little the Juniper RPM poller part I wanted to query only the required values but it is complicated to query a specific OID as Cisco-SLA does because the owner and tag are hardcoded in ASCII decimal with strange values. So I use the function snmp_walk which gets the whole OID values in text. And I index the Juniper MIB (because we want multiple values). But I changed the DISMAN MIB requests to get only what we want. * Fix CI errors * Fix CI errors part 2 * Fix CI errors part 3 * Fixing PHP Static Analysis error 2/4 * Fix CI errors * Implementing Interfaces to fix some errors that occurs with inheritance * Adding missing Interfaces files * Moving generic Sla discovery code into Junos Class * Fix CI errors * Fix CI errors part 2 * Fixing missing definition of SlaDiscovery in Cisco shared Class * Fixing missing import for Illuminate\Database\Eloquent\Collection * Fix CI errors part 3 * Fix PHP Static Analysis error * change type strings to use translations instead of config * IOSXR test data * remove test data garbage * simplify discovery * Fix style * Updating test files to adapt mock sla_nr ID starting from 0 and not 1 : CI tests should pass * clean up polling add rtt field in the db cisco icmpjitter seems to have confused a lot of values * rtt on discovery * use crc32 for consistent sla_nr values * revert snmprec * Fix style * correct schema Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-06-11 20:48:33 +02:00
$name = 'SLA #' . $sla['sla_nr'] . ' - ' . trans_fb("modules.slas.{$sla['rtt_type']}", ucfirst($sla['rtt_type']));
if ($sla['tag']) {
$name .= ': ' . $sla['tag'];
}
if ($sla['owner']) {
$name .= ' (Owner: ' . $sla['owner'] . ')';
}
if ($sla['opstatus'] == 2) {
$danger = 'panel-danger';
} else {
$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`', [$device['device_id']]);
// Collect types
$sla_types = ['all' => 'All'];
foreach ($slas as $sla) {
$sla_type = $sla['rtt_type'];
New module add juniper rpm support + reimplementation of cisco-sla module (#12799) * Definition of a new SLA module to migrate from old cisco-sla and support other devices : Juniper RPM and Huawei * Change wrong description name of module SLA * Re implementing Juniper RPM support in a new module Slas (Cisco SLA to be added) * Added Graphs for Juniper RPM types * Tried to make discover and poller generic : to handle Cisco SLA and Juniper RPM and others * Reimplementing Cisco SLA in the new Sla module and adding condition to manage both SLA and RPM * Definition of a new SLA module to migrate from old cisco-sla and support other devices : Juniper RPM and Huawei * Change wrong description name of module SLA * Re implementing Juniper RPM support in a new module Slas (Cisco SLA to be added) * Added Graphs for Juniper RPM types * Tried to make discover and poller generic : to handle Cisco SLA and Juniper RPM and others * Reimplementing Cisco SLA in the new Sla module and adding condition to manage both SLA and RPM * Fix some error due to Elequent object replacing SQL request * Fixing indentation * Fixed continuous integrations errors * Fixed continuous integrations errors part 2 * Fixed continuous integrations errors part 3 : missing last new lines * Fixed PHP Static Analysis checks * Fixed continuous integrations errors part 4 * Fixed PHP Static Analysis checks part 2 * Trying to convert existing cisco-sla to new slas one * Trying to add slas to fix test failure (I am pretty sure this is not enough but I don't know how to do it) * Switching old cisco-sla module declaration to new slas module in concerned OS files * Fixing wrong sla module name instead of slas in concerned OS files * Fixing wrong module name sla changed to slas (as is it in power-supplies reimplementation) * Fixing some warnings shown in the Inspection CI but skipping some that are already present * Adding tests files from virtual Juniper VMX and adding slas modules in /tests/module_tables * Adding missing SNMP data files * Module Slas modifications to use inheritance * Fix CI errors * Fix CI errors part 2 * Fix CI errors part 3 * Fixing no value on RTT graphs * Fixing only last SLA to be polled : problem with loops * Fix CI errors part 4 * Optimizing a little the Juniper RPM poller part I wanted to query only the required values but it is complicated to query a specific OID as Cisco-SLA does because the owner and tag are hardcoded in ASCII decimal with strange values. So I use the function snmp_walk which gets the whole OID values in text. And I index the Juniper MIB (because we want multiple values). But I changed the DISMAN MIB requests to get only what we want. * Fix CI errors * Fix CI errors part 2 * Fix CI errors part 3 * Fixing PHP Static Analysis error 2/4 * Fix CI errors * Implementing Interfaces to fix some errors that occurs with inheritance * Adding missing Interfaces files * Moving generic Sla discovery code into Junos Class * Fix CI errors * Fix CI errors part 2 * Fixing missing definition of SlaDiscovery in Cisco shared Class * Fixing missing import for Illuminate\Database\Eloquent\Collection * Fix CI errors part 3 * Fix PHP Static Analysis error * change type strings to use translations instead of config * IOSXR test data * remove test data garbage * simplify discovery * Fix style * Updating test files to adapt mock sla_nr ID starting from 0 and not 1 : CI tests should pass * clean up polling add rtt field in the db cisco icmpjitter seems to have confused a lot of values * rtt on discovery * use crc32 for consistent sla_nr values * revert snmprec * Fix style * correct schema Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-06-11 20:48:33 +02:00
$sla_types[$sla_type] = trans_fb("modules.slas.{$sla_type}", ucfirst($sla_type));
}
asort($sla_types);
$status_options = [
'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, ['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> &#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, ['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') || ($sla['rtt_type'] == 'IcmpEcho') || ($sla['rtt_type'] == 'IcmpTimeStamp') || ($sla['rtt_type'] == 'icmpAppl')) {
$name = '<a href="' . \LibreNMS\Util\Url::generate($vars, ['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 = [];
$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 . '">
2016-07-12 20:51:52 +02:00
<div class="panel-heading">
<h3 class="panel-title">' . $name . '</h3>
2016-07-12 20:51:52 +02:00
</div>
<div class="panel-body">';
echo "<div class='row'>";
include 'includes/html/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}
}
$pagetitle[] = 'SLAs';