Skip to content

Commit

Permalink
Merge pull request #4006 from adaniels21487/issue-3550
Browse files Browse the repository at this point in the history
Change the IPSLA feature to allow different metrics to be collected…
  • Loading branch information
murrant committed Aug 16, 2016
2 parents 3c24a67 + 0fbea91 commit 232fdc2
Show file tree
Hide file tree
Showing 15 changed files with 527 additions and 80 deletions.
35 changes: 10 additions & 25 deletions html/includes/graphs/device/sla.inc.php
Expand Up @@ -2,35 +2,20 @@

require 'includes/graphs/common.inc.php';

// FIXME - THIS IS BROKEN
$sla = dbFetchRow('SELECT * FROM `slas` WHERE `sla_id` = ?', array($vars['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'];
}
$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

if ($sla['owner']) {
$name .= ' (Owner: '.$sla['owner'].')';
}

$rrd_file = rrd_name($device['hostname'], array('sla', $sla['sla_nr']));
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr']));

$rrd_options .= " DEF:rtt=$rrd_file:rtt:AVERAGE ";
$rrd_options .= " COMMENT:'Round Trip Time Cur Min Max\\n'";
$rrd_options .= " DEF:rtt=$rrd_filename:rtt:AVERAGE ";
$rrd_options .= ' VDEF:avg=rtt,AVERAGE ';
$rrd_options .= " LINE1:avg#CCCCFF:'".str_pad('Average', ($descr_len - 3))."':dashes";
$rrd_options .= ' GPRINT:rtt:AVERAGE:%4.1lf'.$unit.'\\\l ';
$rrd_options .= " LINE1:rtt#CC0000:'".rrdtool_escape($descr, ($descr_len - 3))."'";
$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 ';
$rrd_options .= " LINE1:avg#CCCCFF:'Average':dashes";
$rrd_options .= ' GPRINT:rtt:AVERAGE:%4.1lfms\\\l ';
$rrd_options .= " LINE1:rtt#CC0000:'RTT'";
$rrd_options .= ' GPRINT:rtt:LAST:%4.1lfms ';
$rrd_options .= ' GPRINT:rtt:MIN:%4.1lfms ';
$rrd_options .= ' GPRINT:rtt:MAX:%4.1lfms\\\l ';
28 changes: 28 additions & 0 deletions html/includes/graphs/device/sla_jitter-icpif.inc.php
@@ -0,0 +1,28 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:ICPIF=" . $rrd_filename . ":ICPIF:AVERAGE ";
$rrd_options .= " LINE1.25:ICPIF#0000ee:'ICPIF ' ";
$rrd_options .= " GPRINT:ICPIF:LAST:%3.0lf ";
$rrd_options .= " GPRINT:ICPIF:MIN:%3.0lf ";
$rrd_options .= " GPRINT:ICPIF:MAX:%3.0lf\\\l ";
}
34 changes: 34 additions & 0 deletions html/includes/graphs/device/sla_jitter-latency.inc.php
@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:SD=" . $rrd_filename . ":OWAvgSD:AVERAGE ";
$rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' ";
$rrd_options .= " GPRINT:SD:LAST:%3.0lf ";
$rrd_options .= " GPRINT:SD:MIN:%3.0lf ";
$rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:DS=" . $rrd_filename . ":OWAvgDS:AVERAGE ";
$rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' ";
$rrd_options .= " GPRINT:DS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:DS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l ";
}
34 changes: 34 additions & 0 deletions html/includes/graphs/device/sla_jitter-loss.inc.php
@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:SD=" . $rrd_filename . ":PacketLossSD:AVERAGE ";
$rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' ";
$rrd_options .= " GPRINT:SD:LAST:%3.0lf ";
$rrd_options .= " GPRINT:SD:MIN:%3.0lf ";
$rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:DS=" . $rrd_filename . ":PacketLossDS:AVERAGE ";
$rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' ";
$rrd_options .= " GPRINT:DS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:DS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l ";
}
40 changes: 40 additions & 0 deletions html/includes/graphs/device/sla_jitter-lost.inc.php
@@ -0,0 +1,40 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:POS=" . $rrd_filename . ":PacketOutOfSequence:AVERAGE ";
$rrd_options .= " LINE1.25:POS#0000ee:'Out of Sequence ' ";
$rrd_options .= " GPRINT:POS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:POS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:POS:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:MIA=" . $rrd_filename . ":PacketMIA:AVERAGE ";
$rrd_options .= " LINE1.25:MIA#008C00:'Missing in Action ' ";
$rrd_options .= " GPRINT:MIA:LAST:%3.0lf ";
$rrd_options .= " GPRINT:MIA:MIN:%3.0lf ";
$rrd_options .= " GPRINT:MIA:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:PLA=" . $rrd_filename . ":PacketLateArrival:AVERAGE ";
$rrd_options .= " LINE1.25:PLA#CC0000:'Late Arrival ' ";
$rrd_options .= " GPRINT:PLA:LAST:%3.0lf ";
$rrd_options .= " GPRINT:PLA:MIN:%3.0lf ";
$rrd_options .= " GPRINT:PLA:MAX:%3.0lf\\\l ";
}
28 changes: 28 additions & 0 deletions html/includes/graphs/device/sla_jitter-mos.inc.php
@@ -0,0 +1,28 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:MOS=" . $rrd_filename . ":MOS:AVERAGE ";
$rrd_options .= " LINE1.25:MOS#0000ee:'Mean Opinion Score ' ";
$rrd_options .= " GPRINT:MOS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:MOS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:MOS:MAX:%3.0lf\\\l ";
}
34 changes: 34 additions & 0 deletions html/includes/graphs/device/sla_jitter.inc.php
@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = rrd_name($device['hostname'], array('sla', $sla['sla_nr'], 'jitter'));

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:SD=" . $rrd_filename . ":AvgSDJ:AVERAGE ";
$rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' ";
$rrd_options .= " GPRINT:SD:LAST:%3.0lf ";
$rrd_options .= " GPRINT:SD:MIN:%3.0lf ";
$rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:DS=" . $rrd_filename . ":AvgDSJ:AVERAGE ";
$rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' ";
$rrd_options .= " GPRINT:DS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:DS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l ";
}
34 changes: 34 additions & 0 deletions html/includes/graphs/sla-jitter-jitter.inc.php
@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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` FROM `slas` WHERE `sla_id` = ?', array($vars['id']));

require 'includes/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd');

if (file_exists($rrd_filename)) {
$rrd_options .= " COMMENT:' Cur Min Max\\n'";

$rrd_options .= " DEF:SD=" . $rrd_filename . ":AvgSDJ:AVERAGE ";
$rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' ";
$rrd_options .= " GPRINT:SD:LAST:%3.0lf ";
$rrd_options .= " GPRINT:SD:MIN:%3.0lf ";
$rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l ";

$rrd_options .= " DEF:DS=" . $rrd_filename . ":AvgDSJ:AVERAGE ";
$rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' ";
$rrd_options .= " GPRINT:DS:LAST:%3.0lf ";
$rrd_options .= " GPRINT:DS:MIN:%3.0lf ";
$rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l ";
}
34 changes: 34 additions & 0 deletions html/pages/device/sla.inc.php
@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Cisco IPSLA UDP Jitter metrics
*
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
*
* 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
if (file_exists('pages/device/sla/'.$sla['rtt_type'].'.inc.php')) {
include 'sla/'.$sla['rtt_type'].'.inc.php';
}

?>
</div>
<?php

0 comments on commit 232fdc2

Please sign in to comment.