From 107736697ce1fefbca10f95e2113a77f425c641b Mon Sep 17 00:00:00 2001 From: bonzo81 <2754635+bonzo81@users.noreply.github.com> Date: Mon, 10 Jan 2022 00:57:16 +0000 Subject: [PATCH] Add Sla jitter packet loss percent graph (#13600) * Add sla packet loss percent rrd graph * Add packet loss percent div * Add OID for NumPackets * Fixed CDEF typo * Rename graph file to include .inc * Flipped axis for Src and Dst to match key * Create new rrd file for loss percent * Remove duplicate rrd data and rename rrd to reflect * Amend to use second rrd file for NumPackets * Removed spaces * dbFetchRow be gone * insert if statement check * white space cleanup * New line at end of file Co-authored-by: Tony Murray --- LibreNMS/OS/Shared/Cisco.php | 11 +++++ .../device/sla_jitter-loss-percent.inc.php | 44 +++++++++++++++++++ includes/html/pages/device/sla/jitter.inc.php | 18 +++++++- 3 files changed, 72 insertions(+), 1 deletion(-) mode change 100644 => 100755 LibreNMS/OS/Shared/Cisco.php create mode 100755 includes/html/graphs/device/sla_jitter-loss-percent.inc.php diff --git a/LibreNMS/OS/Shared/Cisco.php b/LibreNMS/OS/Shared/Cisco.php old mode 100644 new mode 100755 index 864791c8be..b0658fb594 --- a/LibreNMS/OS/Shared/Cisco.php +++ b/LibreNMS/OS/Shared/Cisco.php @@ -411,6 +411,7 @@ class Cisco extends OS implements OSDiscovery, SlaDiscovery, ProcessorDiscovery, $data = snmpwalk_group($device, 'rttMonLatestRttOperTable', 'CISCO-RTTMON-MIB'); $data = snmpwalk_group($device, 'rttMonLatestOper', 'CISCO-RTTMON-MIB', 1, $data); + $data = snmpwalk_group($device, 'rttMonEchoAdminNumPackets', 'CISCO-RTTMON-MIB', 1, $data); $time_offset = time() - $this->getDevice()->uptime; @@ -472,6 +473,16 @@ class Cisco extends OS implements OSDiscovery, SlaDiscovery, ProcessorDiscovery, $tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type'); data_update($device, 'sla', $tags, $jitter); $fields = array_merge($fields, $jitter); + // Additional rrd for total number packet in sla + $numPackets = [ + 'NumPackets' => $data[$sla_nr]['rttMonEchoAdminNumPackets'], + ]; + $rrd_name = ['sla', $sla_nr, 'NumPackets']; + $rrd_def = RrdDefinition::make() + ->addDataset('NumPackets', 'GAUGE', 0); + $tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type'); + data_update($device, 'sla', $tags, $numPackets); + $fields = array_merge($fields, $numPackets); break; case 'icmpjitter': $icmpjitter = [ diff --git a/includes/html/graphs/device/sla_jitter-loss-percent.inc.php b/includes/html/graphs/device/sla_jitter-loss-percent.inc.php new file mode 100755 index 0000000000..744885fed3 --- /dev/null +++ b/includes/html/graphs/device/sla_jitter-loss-percent.inc.php @@ -0,0 +1,44 @@ + + * + * 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. + */ +use App\Models\Sla; + +$sla_nr = Sla::where('sla_id', $vars['id'])->value('sla_nr'); + +if ($sla_nr) { + require 'includes/html/graphs/common.inc.php'; + $rrd_options .= ' -l -100 -u 100 -E -r'; + $rrd_filename_1 = Rrd::name($device['hostname'], ['sla', $sla_nr, 'jitter']); + $rrd_filename_2 = Rrd::name($device['hostname'], ['sla', $sla_nr, 'NumPackets']); + + if (Rrd::checkRrdExists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max Avg\\n'"; + + $rrd_options .= ' DEF:PacketLossSD=' . $rrd_filename_1 . ':PacketLossSD:AVERAGE '; + $rrd_options .= ' DEF:PacketLossDS=' . $rrd_filename_1 . ':PacketLossDS:AVERAGE '; + $rrd_options .= ' DEF:NumPackets=' . $rrd_filename_2 . ':NumPackets:AVERAGE '; + + $rrd_options .= ' CDEF:PktLossOut=PacketLossSD,NumPackets,/,100,* '; + $rrd_options .= " LINE1.25:PktLossOut#0000ee:'Src to Dst (%) ' "; + $rrd_options .= " GPRINT:PktLossOut:LAST:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossOut:MIN:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossOut:MAX:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossOut:AVERAGE:'%5.2lf'\\\l "; + + $rrd_options .= ' CDEF:PktLossIn=PacketLossDS,NumPackets,/,100,*,-1,* '; + $rrd_options .= " LINE1.25:PktLossIn#008C00:'Dst to Src (%) ' "; + $rrd_options .= " GPRINT:PktLossIn:LAST:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossIn:MIN:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossIn:MAX:'%5.2lf' "; + $rrd_options .= " GPRINT:PktLossIn:AVERAGE:'%5.2lf'\\\l "; + } +} diff --git a/includes/html/pages/device/sla/jitter.inc.php b/includes/html/pages/device/sla/jitter.inc.php index 6538daff95..2f8a75fe98 100644 --- a/includes/html/pages/device/sla/jitter.inc.php +++ b/includes/html/pages/device/sla/jitter.inc.php @@ -31,7 +31,23 @@
-

Packet Loss

+

Packet Loss (Percent)

+
+
+ +
+ +
+

Packet Loss (Count)