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>
This commit is contained in:
geg347
2021-06-11 20:48:33 +02:00
committed by GitHub
parent 3cf039764e
commit 672fe61b5e
59 changed files with 19866 additions and 2663 deletions

View File

@@ -437,6 +437,8 @@ class Config
self::deprecatedVariable('discovery_modules.cisco-vrf', 'discovery_modules.vrf');
self::deprecatedVariable('discovery_modules.toner', 'discovery_modules.printer-supplies');
self::deprecatedVariable('poller_modules.toner', 'poller_modules.printer-supplies');
self::deprecatedVariable('discovery_modules.cisco-sla', 'discovery_modules.slas');
self::deprecatedVariable('poller_modules.cisco-sla', 'poller_modules.slas');
self::deprecatedVariable('oxidized.group', 'oxidized.maps.group');
$persist = Eloquent::isConnected();

View File

@@ -0,0 +1,34 @@
<?php
/**
* SlaDiscovery.php
*
* Discovers the Cisco SLA or Juniper RPM or soon Huawei on network equipements
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Interfaces\Discovery;
interface SlaDiscovery
{
/**
* Discover additional information about the OS.
* Primarily this is just version, hardware, features, serial, but could be anything
*/
public function discoverSlas();
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* SlaPolling.php
*
* Polling Sla data from discovered Sla in database and fill RRD data
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Interfaces\Polling;
use Illuminate\Database\Eloquent\Collection;
interface SlaPolling
{
/**
* Poll Sla data for Sla in database.
*
* @param Collection $slas
*/
public function pollSlas(Collection $slas);
}

82
LibreNMS/Modules/Slas.php Normal file
View File

@@ -0,0 +1,82 @@
<?php
/**
* SLA.php
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*/
namespace LibreNMS\Modules;
use App\Models\Sla;
use App\Observers\ModuleModelObserver;
use LibreNMS\DB\SyncsModels;
use LibreNMS\Interfaces\Discovery\SlaDiscovery;
use LibreNMS\Interfaces\Module;
use LibreNMS\Interfaces\Polling\SlaPolling;
use LibreNMS\OS;
class Slas implements Module
{
use SyncsModels;
/**
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param OS $os
*/
public function discover(OS $os)
{
if ($os instanceof SlaDiscovery) {
$slas = $os->discoverSlas();
ModuleModelObserver::observe(Sla::class);
$this->syncModels($os->getDevice(), 'slas', $slas);
}
}
/**
* Poll data for this module and update the DB / RRD.
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param OS $os
*/
public function poll(OS $os)
{
if ($os instanceof SlaPolling) {
// Gather our SLA's from the DB.
$slas = $os->getDevice()->slas()
->where('deleted', 0)->get();
if ($slas->isNotEmpty()) {
// We have SLA's, lets go!!!
$os->pollSlas($slas);
$os->getDevice()->slas()->saveMany($slas);
}
}
}
/**
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param OS $os
*/
public function cleanup(OS $os)
{
$os->getDevice()->slas()->delete();
}
}

View File

@@ -26,10 +26,14 @@
namespace LibreNMS\OS;
use App\Models\Device;
use App\Models\Sla;
use Carbon\Carbon;
use LibreNMS\Interfaces\Discovery\SlaDiscovery;
use LibreNMS\Interfaces\Polling\OSPolling;
use LibreNMS\Interfaces\Polling\SlaPolling;
use LibreNMS\RRD\RrdDefinition;
class Junos extends \LibreNMS\OS implements OSPolling
class Junos extends \LibreNMS\OS implements SlaDiscovery, OSPolling, SlaPolling
{
public function discoverOS(Device $device): void
{
@@ -64,4 +68,136 @@ class Junos extends \LibreNMS\OS implements OSPolling
$this->enableGraph('junos_jsrx_spu_sessions');
}
}
public function discoverSlas()
{
$slas = collect();
$sla_table = snmpwalk_cache_oid($this->getDeviceArray(), 'pingCtlTable', [], 'DISMAN-PING-MIB');
if (! empty($sla_table)) {
$sla_table = snmpwalk_cache_oid($this->getDeviceArray(), 'jnxPingResultsRttUs', $sla_table, 'JUNIPER-PING-MIB');
}
foreach ($sla_table as $sla_key => $sla_config) {
[$owner, $test] = explode('.', $sla_key, 2);
$slas->push(new Sla([
'sla_nr' => hexdec(hash('crc32', $owner . $test)), // indexed by owner+test, convert to int
'owner' => $owner,
'tag' => $test,
'rtt_type' => $this->retrieveJuniperType($sla_config['pingCtlType']),
'rtt' => isset($sla_config['jnxPingResultsRttUs']) ? $sla_config['jnxPingResultsRttUs'] / 1000 : null,
'status' => ($sla_config['pingCtlAdminStatus'] == 'enabled') ? 1 : 0,
'opstatus' => ($sla_config['pingCtlRowStatus'] == 'active') ? 0 : 2,
]));
}
return $slas;
}
public function pollSlas($slas)
{
$device = $this->getDeviceArray();
// Go get some data from the device.
$data = snmpwalk_group($device, 'pingCtlRowStatus', 'DISMAN-PING-MIB', 2);
$data = snmpwalk_group($device, 'pingResultsProbeResponses', 'DISMAN-PING-MIB', 2, $data);
$data = snmpwalk_group($device, 'pingResultsSentProbes', 'DISMAN-PING-MIB', 2, $data);
$data = snmpwalk_group($device, 'jnxPingResultsTable', 'JUNIPER-PING-MIB', 2, $data);
// Get the needed information
foreach ($slas as $sla) {
$sla_nr = $sla->sla_nr;
$rtt_type = $sla->rtt_type;
$owner = $sla->owner;
$test = $sla->tag;
// Lets process each SLA
// Use DISMAN-PING Status codes. 0=Good 2=Critical
$sla->opstatus = $data[$owner][$test]['pingCtlRowStatus'] == '1' ? 0 : 2;
$sla->rtt = $data[$owner][$test]['jnxPingResultsRttUs'] / 1000;
$time = Carbon::parse($data[$owner][$test]['jnxPingResultsTime'])->toDateTimeString();
echo 'SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time . "\n";
$fields = [
'rtt' => $sla->rtt,
];
// The base RRD
$rrd_name = ['sla', $sla['sla_nr']];
$rrd_def = RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000);
$tags = compact('sla_nr', 'rrd_name', 'rrd_def');
data_update($device, 'sla', $tags, $fields);
// Let's gather some per-type fields.
switch ($rtt_type) {
case 'DnsQuery':
case 'HttpGet':
case 'HttpGetMetadata':
break;
case 'IcmpEcho':
case 'IcmpTimeStamp':
$icmp = [
'MinRttUs' => $data[$owner][$test]['jnxPingResultsMinRttUs'] / 1000,
'MaxRttUs' => $data[$owner][$test]['jnxPingResultsMaxRttUs'] / 1000,
'StdDevRttUs' => $data[$owner][$test]['jnxPingResultsStdDevRttUs'] / 1000,
'ProbeResponses' => $data[$owner][$test]['pingResultsProbeResponses'],
'ProbeLoss' => (int) $data[$owner][$test]['pingResultsSentProbes'] - (int) $data[$owner][$test]['pingResultsProbeResponses'],
];
$rrd_name = ['sla', $sla_nr, $rtt_type];
$rrd_def = RrdDefinition::make()
->addDataset('MinRttUs', 'GAUGE', 0, 300000)
->addDataset('MaxRttUs', 'GAUGE', 0, 300000)
->addDataset('StdDevRttUs', 'GAUGE', 0, 300000)
->addDataset('ProbeResponses', 'GAUGE', 0, 300000)
->addDataset('ProbeLoss', 'GAUGE', 0, 300000);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
data_update($device, 'sla', $tags, $icmp);
$fields = array_merge($fields, $icmp);
break;
case 'NtpQuery':
case 'UdpTimestamp':
break;
}
d_echo('The following datasources were collected for #' . $sla['sla_nr'] . ":\n");
d_echo($fields);
}
}
private function calculateSlaNr($key): int
{
$sum = 0;
$length = strlen($key);
for ($i = 0; $i < $length; $i++) {
$sum += ord($key[$i]);
}
return $sum;
}
/**
* Retrieve specific Juniper PingCtlType
*/
private function retrieveJuniperType($rtt_type)
{
switch ($rtt_type) {
case 'enterprises.2636.3.7.2.1':
return 'IcmpTimeStamp';
case 'enterprises.2636.3.7.2.2':
return 'HttpGet';
case 'enterprises.2636.3.7.2.3':
return 'HttpGetMetadata';
case 'enterprises.2636.3.7.2.4':
return 'DnsQuery';
case 'enterprises.2636.3.7.2.5':
return 'NtpQuery';
case 'enterprises.2636.3.7.2.6':
return 'UdpTimestamp';
default:
return str_replace('ping', '', $rtt_type);
}
}
}

View File

@@ -28,17 +28,21 @@ namespace LibreNMS\OS\Shared;
use App\Models\Device;
use App\Models\Mempool;
use App\Models\PortsNac;
use App\Models\Sla;
use Illuminate\Support\Arr;
use LibreNMS\Device\Processor;
use LibreNMS\Interfaces\Discovery\MempoolsDiscovery;
use LibreNMS\Interfaces\Discovery\OSDiscovery;
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
use LibreNMS\Interfaces\Discovery\SlaDiscovery;
use LibreNMS\Interfaces\Polling\NacPolling;
use LibreNMS\Interfaces\Polling\SlaPolling;
use LibreNMS\OS;
use LibreNMS\OS\Traits\YamlOSDiscovery;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\IP;
class Cisco extends OS implements OSDiscovery, ProcessorDiscovery, MempoolsDiscovery, NacPolling
class Cisco extends OS implements OSDiscovery, SlaDiscovery, ProcessorDiscovery, MempoolsDiscovery, NacPolling, SlaPolling
{
use YamlOSDiscovery {
YamlOSDiscovery::discoverOS as discoverYamlOS;
@@ -302,6 +306,56 @@ class Cisco extends OS implements OSDiscovery, ProcessorDiscovery, MempoolsDisco
return $processors;
}
public function discoverSlas()
{
$slas = collect();
$sla_data = snmpwalk_cache_oid($this->getDeviceArray(), 'rttMonCtrl', [], 'CISCO-RTTMON-MIB');
if (! empty($sla_data)) {
$sla_data = snmpwalk_cache_oid($this->getDeviceArray(), 'rttMonLatestRttOperCompletionTime', $sla_data, 'CISCO-RTTMON-MIB');
}
foreach ($sla_data as $index => $sla_config) {
$slas->push(new Sla([
'sla_nr' => $index,
'owner' => $sla_config['rttMonCtrlAdminOwner'] ?? '',
'tag' => $this->getSlaTag($sla_config),
'rtt_type' => $sla_config['rttMonCtrlAdminRttType'],
'rtt' => $sla_config['rttMonLatestRttOperCompletionTime'] ?? null,
'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0,
'opstatus' => ($sla_config['rttMonLatestRttOperSense'] == 'ok') ? 0 : 2,
]));
}
return $slas;
}
private function getSlaTag($data)
{
if (! empty($data['rttMonCtrlAdminTag'])) {
return $data['rttMonCtrlAdminTag'];
}
switch ($data['rttMonCtrlAdminRttType']) {
case 'http':
return $data['rttMonEchoAdminURL'];
case 'dns':
return $data['rttMonEchoAdminTargetAddressString'];
case 'echo':
return IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true);
case 'jitter':
$tag = IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true) . ':' . $data['rttMonEchoAdminTargetPort'];
if (isset($data['rttMonEchoAdminCodecType']) && $data['rttMonEchoAdminCodecType'] != 'notApplicable') {
$tag .= ' (' . $data['rttMonEchoAdminCodecType'] . ' @ ' . $data['rttMonEchoAdminCodecInterval'] . 'ms)';
}
return $tag;
default:
return '';
}
}
public function pollNac()
{
$nac = collect();
@@ -346,6 +400,110 @@ class Cisco extends OS implements OSDiscovery, ProcessorDiscovery, MempoolsDisco
return $nac;
}
public function pollSlas($slas)
{
$device = $this->getDeviceArray();
$data = snmpwalk_group($device, 'rttMonLatestRttOperTable', 'CISCO-RTTMON-MIB');
$data = snmpwalk_group($device, 'ttMonLatestOper', 'CISCO-RTTMON-MIB', 1, $data);
$time_offset = time() - $this->getDevice()->uptime;
foreach ($slas as $sla) {
$sla_id = $sla->sla_id;
$sla_nr = $sla->sla_nr;
$rtt_type = $sla->rtt_type;
// Lets process each SLA
$unixtime = intval(($data[$sla_nr]['rttMonLatestRttOperTime'] / 100 + $time_offset));
$time = strftime('%Y-%m-%d %H:%M:%S', $unixtime);
// Save data
$sla->rtt = $data[$sla_nr]['rttMonLatestRttOperCompletionTime'];
// Use Nagios Status codes. 0: Good, 2: Critical
$sla->opstatus = $data[$sla_nr]['rttMonLatestRttOperSense'] == 1 ? 0 : 2;
echo 'SLA ' . $sla_nr . ': ' . $rtt_type . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... ' . $sla->rtt . 'ms at ' . $time . "\n";
$fields = [
'rtt' => $sla->rtt,
];
// The base RRD
$rrd_name = ['sla', $sla['sla_nr']];
$rrd_def = RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000);
$tags = compact('sla_nr', 'rrd_name', 'rrd_def');
data_update($device, 'sla', $tags, $fields);
// Let's gather some per-type fields.
switch ($rtt_type) {
case 'jitter':
$jitter = [
'PacketLossSD' => $data[$sla_nr]['rttMonLatestJitterOperPacketLossSD'],
'PacketLossDS' => $data[$sla_nr]['rttMonLatestJitterOperPacketLossDS'],
'PacketOutOfSequence' => $data[$sla_nr]['rttMonLatestJitterOperPacketOutOfSequence'],
'PacketMIA' => $data[$sla_nr]['rttMonLatestJitterOperPacketMIA'],
'PacketLateArrival' => $data[$sla_nr]['rttMonLatestJitterOperPacketLateArrival'],
'MOS' => isset($data[$sla_nr]['rttMonLatestJitterOperMOS']) ? intval($data[$sla_nr]['rttMonLatestJitterOperMOS']) / 100 : null,
'ICPIF' => $data[$sla_nr]['rttMonLatestJitterOperICPIF'] ?? null,
'OWAvgSD' => $data[$sla_nr]['rttMonLatestJitterOperOWAvgSD'] ?? null,
'OWAvgDS' => $data[$sla_nr]['rttMonLatestJitterOperOWAvgDS'] ?? null,
'AvgSDJ' => $data[$sla_nr]['rttMonLatestJitterOperAvgSDJ'] ?? null,
'AvgDSJ' => $data[$sla_nr]['rttMonLatestJitterOperAvgDSJ'] ?? null,
];
$rrd_name = ['sla', $sla_nr, $rtt_type];
$rrd_def = RrdDefinition::make()
->addDataset('PacketLossSD', 'GAUGE', 0)
->addDataset('PacketLossDS', 'GAUGE', 0)
->addDataset('PacketOutOfSequence', 'GAUGE', 0)
->addDataset('PacketMIA', 'GAUGE', 0)
->addDataset('PacketLateArrival', 'GAUGE', 0)
->addDataset('MOS', 'GAUGE', 0)
->addDataset('ICPIF', 'GAUGE', 0)
->addDataset('OWAvgSD', 'GAUGE', 0)
->addDataset('OWAvgDS', 'GAUGE', 0)
->addDataset('AvgSDJ', 'GAUGE', 0)
->addDataset('AvgDSJ', 'GAUGE', 0);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
data_update($device, 'sla', $tags, $jitter);
$fields = array_merge($fields, $jitter);
break;
case 'icmpjitter':
$icmpjitter = [
'PacketLoss' => $data[$sla_nr]['rttMonLatestJitterOperPacketLossSD'],
'PacketOosSD' => $data[$sla_nr]['rttMonLatestJitterOperPacketOutOfSequence'],
'PacketOosDS' => $data[$sla_nr]['rttMonLatestJitterOperPacketMIA'],
'PacketLateArrival' => $data[$sla_nr]['rttMonLatestJitterOperPacketLateArrival'],
'JitterAvgSD' => $data[$sla_nr]['rttMonLatestJitterOperAvgSDJ'],
'JitterAvgDS' => $data[$sla_nr]['rttMonLatestJitterOperAvgDSJ'],
'LatencyOWAvgSD' => $data[$sla_nr]['rttMonLatestJitterOperOWAvgSD'],
'LatencyOWAvgDS' => $data[$sla_nr]['rttMonLatestJitterOperOWAvgDS'],
'JitterIAJOut' => $data[$sla_nr]['rttMonLatestJitterOperIAJOut'],
'JitterIAJIn' => $data[$sla_nr]['rttMonLatestJitterOperIAJIn'],
];
$rrd_name = ['sla', $sla_nr, $rtt_type];
$rrd_def = RrdDefinition::make()
->addDataset('PacketLoss', 'GAUGE', 0)
->addDataset('PacketOosSD', 'GAUGE', 0)
->addDataset('PacketOosDS', 'GAUGE', 0)
->addDataset('PacketLateArrival', 'GAUGE', 0)
->addDataset('JitterAvgSD', 'GAUGE', 0)
->addDataset('JitterAvgDS', 'GAUGE', 0)
->addDataset('LatencyOWAvgSD', 'GAUGE', 0)
->addDataset('LatencyOWAvgDS', 'GAUGE', 0)
->addDataset('JitterIAJOut', 'GAUGE', 0)
->addDataset('JitterIAJIn', 'GAUGE', 0);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
data_update($device, 'sla', $tags, $icmpjitter);
$fields = array_merge($fields, $icmpjitter);
break;
}
d_echo('The following datasources were collected for #' . $sla['sla_nr'] . ":\n");
d_echo($fields);
}
}
protected function getMainSerial()
{
$serial_output = snmp_get_multi($this->getDeviceArray(), ['entPhysicalSerialNum.1', 'entPhysicalSerialNum.1001'], '-OQUs', 'ENTITY-MIB:OLD-CISCO-CHASSIS-MIB');

View File

@@ -43,6 +43,7 @@ use App\Models\Processor;
use App\Models\Pseudowire;
use App\Models\Sensor;
use App\Models\Service;
use App\Models\Sla;
use App\Models\Storage;
use App\Models\Syslog;
use App\Models\Vlan;
@@ -96,6 +97,7 @@ class AboutController extends Controller
'stat_pw' => Pseudowire::count(),
'stat_sensors' => Sensor::count(),
'stat_services' => Service::count(),
'stat_slas' => Sla::count(),
'stat_storage' => Storage::count(),
'stat_syslog' => Syslog::count(),
'stat_toner' => PrinterSupply::count(),

View File

@@ -2,7 +2,9 @@
namespace App\Models;
class PrinterSupply extends DeviceRelatedModel
use LibreNMS\Interfaces\Models\Keyable;
class PrinterSupply extends DeviceRelatedModel implements Keyable
{
protected $table = 'printer_supplies';
protected $primaryKey = 'supply_id';

View File

@@ -2,8 +2,30 @@
namespace App\Models;
class Sla extends DeviceRelatedModel
use LibreNMS\Interfaces\Models\Keyable;
class Sla extends DeviceRelatedModel implements Keyable
{
protected $table = 'slas';
protected $primaryKey = 'sla_id';
public $timestamps = false;
protected $fillable = [
'device_id',
'sla_nr',
'owner',
'tag',
'rtt_type',
'rtt',
'status',
'opstatus',
'deleted',
];
protected $attributes = [ // default values
'deleted' => 0,
];
public function getCompositeKey()
{
return "$this->owner-$this->tag";
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SlasAddRttField extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('slas', function (Blueprint $table) {
$table->unsignedInteger('sla_nr')->change();
$table->unsignedFloat('rtt')->nullable()->after('rtt_type');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('slas', function (Blueprint $table) {
$table->integer('sla_nr')->change();
$table->dropColumn('rtt');
});
}
}

View File

@@ -55,6 +55,7 @@ if ($enabled == 1) {
'processors' => 'SELECT COUNT(*) AS `total`,`processor_type` FROM `processors` GROUP BY `processor_type`',
'pseudowires' => 'SELECT COUNT(*) AS `total` FROM `pseudowires`',
'sensors' => 'SELECT COUNT(*) AS `total`,`sensor_class` FROM `sensors` GROUP BY `sensor_class`',
'sla' => 'SELECT COUNT(*) AS `total`,`rtt_type` FROM `slas` GROUP BY `rtt_type`',
'wireless' => 'SELECT COUNT(*) AS `total`,`sensor_class` FROM `wireless_sensors` GROUP BY `sensor_class`',
'storage' => 'SELECT COUNT(*) AS `total`,`storage_type` FROM `storage` GROUP BY `storage_type`',
'toner' => 'SELECT COUNT(*) AS `total`,`supply_type` FROM `printer_supplies` GROUP BY `supply_type`',

View File

@@ -14,13 +14,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -16,13 +16,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -16,13 +16,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -13,13 +13,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -15,7 +15,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -23,7 +23,7 @@ poller_modules:
cisco-vpdn: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -16,14 +16,14 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
ipmi: false
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -13,13 +13,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -12,13 +12,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -15,7 +15,7 @@ poller_modules:
cisco-mac-accounting: false
cisco-voice: false
cisco-remote-access-monitor: false
cisco-sla: false
slas: false
cisco-ipsec-flow-monitor: false
cipsec-tunnels: false
cisco-otv: false
@@ -23,7 +23,7 @@ poller_modules:
wireless: false
discovery_modules:
cisco-cef: false
cisco-sla: false
slas: false
cisco-mac-accounting: false
cisco-otv: false
cisco-pw: false

View File

@@ -20,13 +20,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -15,13 +15,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -13,13 +13,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -33,7 +33,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -41,7 +41,7 @@ poller_modules:
ipmi: false
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -17,7 +17,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -26,7 +26,7 @@ poller_modules:
cisco-qfp: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -17,7 +17,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -25,7 +25,7 @@ poller_modules:
cisco-vpdn: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -12,13 +12,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -6,7 +6,10 @@ over:
- { graph: device_processor, text: 'CPU Usage' }
- { graph: device_mempool, text: 'Memory Usage' }
discovery_modules:
slas: true
vrf: true
poller_modules:
slas: true
discovery:
-
sysObjectID: .1.3.6.1.4.1.2636

View File

@@ -15,7 +15,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -23,7 +23,7 @@ poller_modules:
cisco-vpdn: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -14,13 +14,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -16,7 +16,7 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
@@ -34,7 +34,7 @@ discovery_modules:
bgp-peers: false
stp: false
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -13,13 +13,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -15,13 +15,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -8,13 +8,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -12,13 +12,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -8,13 +8,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -8,13 +8,13 @@ poller_modules:
cisco-mac-accounting: true
cisco-voice: true
cisco-remote-access-monitor: true
cisco-sla: true
slas: true
cisco-ipsec-flow-monitor: true
cipsec-tunnels: true
cisco-otv: true
discovery_modules:
cisco-cef: true
cisco-sla: true
slas: true
cisco-mac-accounting: true
cisco-otv: true
cisco-pw: true

View File

@@ -17,7 +17,7 @@ poller_modules:
cisco-mac-accounting: false
cisco-otv: false
cisco-remote-access-monitor: false
cisco-sla: false
slas: false
cisco-voice: false
ipmi: false
ospf: false
@@ -30,7 +30,7 @@ discovery_modules:
cisco-mac-accounting: false
cisco-otv: false
cisco-pw: false
cisco-sla: false
slas: false
cisco-vrf-lite: false
vrf: false
libvirt-vminfo: false

View File

@@ -1,97 +0,0 @@
<?php
use LibreNMS\Config;
use LibreNMS\Util\IP;
if (Config::get('enable_sla') && $device['os_group'] == 'cisco') {
$slas = snmp_walk($device, 'ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl', '-Osq', '+CISCO-RTTMON-MIB');
$sla_table = [];
foreach (explode("\n", $slas) as $sla) {
$key_val = explode(' ', $sla, 2);
if (count($key_val) != 2) {
$key_val[] = '';
}
$key = $key_val[0];
$value = $key_val[1];
$prop_id = explode('.', $key);
if ((count($prop_id) != 2) || ! ctype_digit($prop_id[1])) {
continue;
}
$property = $prop_id[0];
$id = intval($prop_id[1]);
$sla_table[$id][$property] = trim($value);
}
// var_dump($sla_table);
// Get existing SLAs
$existing_slas = dbFetchColumn('SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `deleted` = 0', ['device_id' => $device['device_id']]);
foreach ($sla_table as $sla_nr => $sla_config) {
$query_data = [
'device_id' => $device['device_id'],
'sla_nr' => $sla_nr,
];
$sla_id = dbFetchCell('SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr', $query_data);
$data = [
'device_id' => $device['device_id'],
'sla_nr' => $sla_nr,
'owner' => $sla_config['rttMonCtrlAdminOwner'],
'tag' => $sla_config['rttMonCtrlAdminTag'],
'rtt_type' => $sla_config['rttMonCtrlAdminRttType'],
'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0,
'opstatus' => ($sla_config['rttMonLatestRttOperSense'] == 'ok') ? 0 : 2,
'deleted' => 0,
];
// Some fallbacks for when the tag is empty
if (! $data['tag']) {
switch ($data['rtt_type']) {
case 'http':
$data['tag'] = $sla_config['rttMonEchoAdminURL'];
break;
case 'dns':
$data['tag'] = $sla_config['rttMonEchoAdminTargetAddressString'];
break;
case 'echo':
$data['tag'] = IP::fromHexString($sla_config['rttMonEchoAdminTargetAddress'], true);
break;
case 'jitter':
if ($sla_config['rttMonEchoAdminCodecType'] != 'notApplicable') {
$codec_info = ' (' . $sla_config['rttMonEchoAdminCodecType'] . ' @ ' . preg_replace('/milliseconds/', 'ms', $sla_config['rttMonEchoAdminCodecInterval']) . ')';
} else {
$codec_info = '';
}
$data['tag'] = IP::fromHexString($sla_config['rttMonEchoAdminTargetAddress'], true) . ':' . $sla_config['rttMonEchoAdminTargetPort'] . $codec_info;
break;
}//end switch
}//end if
if (! $sla_id) {
$sla_id = dbInsert($data, 'slas');
echo '+';
} else {
// Remove from the list
$existing_slas = array_diff($existing_slas, [$sla_id]);
dbUpdate($data, 'slas', 'sla_id = ?', [$sla_id]);
echo '.';
}
}//end foreach
// Mark all remaining SLAs as deleted
foreach ($existing_slas as $existing_sla) {
dbUpdate(['deleted' => 1], 'slas', 'sla_id = ?', [$existing_sla]);
echo '-';
}
echo "\n";
}

View File

@@ -0,0 +1,8 @@
<?php
use LibreNMS\OS;
if (! $os instanceof OS) {
$os = OS::make($device);
}
(new \LibreNMS\Modules\Slas())->discover($os);

View File

@@ -78,3 +78,19 @@ function cast_number($number)
{
return \LibreNMS\Util\Number::cast($number);
}
if (! function_exists('trans_fb')) {
/**
* Translate the given message with a fallback string if none exists.
*
* @param string $key
* @param string $fallback
* @param array $replace
* @param string $locale
* @return \Symfony\Component\Translation\TranslatorInterface|string
*/
function trans_fb($key, $fallback, $replace = [], $locale = null)
{
return ($key === ($translation = trans($key, $replace, $locale))) ? $fallback : $translation;
}
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Juniper RPM IcmpEcho 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` = ?', [$vars['id']]);
require 'includes/html/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = Rrd::name($device['hostname'], ['sla', $sla['sla_nr'], 'IcmpEcho']);
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_options .= " COMMENT:'Packet loss\: Cur Avg Min Max\\n' ";
// Calculating percentage
$rrd_options .= ' DEF:ProbeResponses=' . $rrd_filename . ':ProbeResponses:AVERAGE ';
$rrd_options .= ' DEF:ProbeLoss=' . $rrd_filename . ':ProbeLoss:AVERAGE ';
$rrd_options .= ' CDEF:ProbeCount=ProbeResponses,ProbeLoss,+ ';
$rrd_options .= ' CDEF:PercentageLoss=ProbeLoss,UNKN,NE,0,ProbeLoss,IF,ProbeCount,/,100,*,CEIL ';
$rrd_options .= " LINE1:PercentageLoss#CC0000:'PercentageLoss'";
$rrd_options .= ' GPRINT:PercentageLoss:LAST:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:AVERAGE:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:MIN:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:MAX:%6.1lf%%\\l ';
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* LibreNMS module to Graph Juniper RPM IcmpTimeStamp 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` = ?', [$vars['id']]);
require 'includes/html/graphs/common.inc.php';
$rrd_options .= ' -l 0 -E ';
$rrd_filename = Rrd::name($device['hostname'], ['sla', $sla['sla_nr'], 'IcmpTimeStamp']);
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_options .= " COMMENT:'Packet loss\: Cur Avg Min Max\\n' ";
// Calculating percentage
$rrd_options .= ' DEF:ProbeResponses=' . $rrd_filename . ':ProbeResponses:AVERAGE ';
$rrd_options .= ' DEF:ProbeLoss=' . $rrd_filename . ':ProbeLoss:AVERAGE ';
$rrd_options .= ' CDEF:ProbeCount=ProbeResponses,ProbeLoss,+ ';
$rrd_options .= ' CDEF:PercentageLoss=ProbeLoss,UNKN,NE,0,ProbeLoss,IF,ProbeCount,/,100,*,CEIL ';
$rrd_options .= " LINE1:PercentageLoss#CC0000:'PercentageLoss'";
$rrd_options .= ' GPRINT:PercentageLoss:LAST:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:AVERAGE:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:MIN:%6.1lf%% ';
$rrd_options .= ' GPRINT:PercentageLoss:MAX:%6.1lf%%\\l ';
}

View File

@@ -0,0 +1,15 @@
<div class="panel-heading">
<h3 class="panel-title">Packet Loss</h3>
</div>
<div class="panel-body">
<?php
$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_IcmpEcho';
$graph_array['id'] = $vars['id'];
require 'includes/html/print-graphrow.inc.php';
?>
</div>

View File

@@ -0,0 +1,15 @@
<div class="panel-heading">
<h3 class="panel-title">Packet Loss</h3>
</div>
<div class="panel-body">
<?php
$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_IcmpTimeStamp';
$graph_array['id'] = $vars['id'];
require 'includes/html/print-graphrow.inc.php';
?>
</div>

View File

@@ -2,7 +2,7 @@
if ($vars['id']) {
$sla = dbFetchRow('SELECT `tag`, `sla_nr`,`rtt_type` FROM `slas` WHERE `sla_id` = ?', [$vars['id']]);
$name = 'SLA #' . $sla['sla_nr'] . ' - ' . \LibreNMS\Config::get("sla_type_labels.{$sla['rtt_type']}", ucfirst($sla['rtt_type']));
$name = 'SLA #' . $sla['sla_nr'] . ' - ' . trans_fb("modules.slas.{$sla['rtt_type']}", ucfirst($sla['rtt_type']));
if ($sla['tag']) {
$name .= ': ' . $sla['tag'];
}
@@ -40,8 +40,7 @@ if ($vars['id']) {
$sla_types = ['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);
$sla_types[$sla_type] = trans_fb("modules.slas.{$sla_type}", ucfirst($sla_type));
}
asort($sla_types);
@@ -118,7 +117,7 @@ if ($vars['id']) {
}
// These Types have more graphs. Display a sub-page
if (($sla['rtt_type'] == 'jitter') || ($sla['rtt_type'] == 'icmpjitter')) {
if (($sla['rtt_type'] == 'jitter') || ($sla['rtt_type'] == 'icmpjitter') || ($sla['rtt_type'] == 'IcmpEcho') || ($sla['rtt_type'] == 'IcmpTimeStamp')) {
$name = '<a href="' . \LibreNMS\Util\Url::generate($vars, ['tab' => 'slas', 'id' => $sla['sla_id']]) . '">' . $name . '</a>';
} else {
$name = htmlentities($name);

View File

@@ -1,127 +0,0 @@
<?php
use LibreNMS\RRD\RrdDefinition;
// Gather our SLA's from the DB.
$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', [$device['device_id']]);
if (count($slas) > 0) {
// We have SLA's, lets go!!!
// Go get some data from the device.
$rttMonLatestRttOperTable = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.2.10.1', 1);
$rttMonLatestOper = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.5', 1);
$uptime = snmp_get($device, 'sysUpTime.0', '-Otv');
$time_offset = (time() - intval($uptime) / 100);
foreach ($slas as $sla) {
$sla_nr = $sla['sla_nr'];
$rtt_type = $sla['rtt_type'];
// Lets process each SLA
$unixtime = intval(($rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.5'][$sla_nr] / 100 + $time_offset));
$time = strftime('%Y-%m-%d %H:%M:%S', $unixtime);
$update = [];
// Use Nagios Status codes.
$opstatus = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.2'][$sla_nr];
if ($opstatus == 1) {
$opstatus = 0; // 0=Good
} else {
$opstatus = 2; // 2=Critical
}
// Populating the update array means we need to update the DB.
if ($opstatus != $sla['opstatus']) {
$update['opstatus'] = $opstatus;
}
$rtt = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.1'][$sla_nr];
echo 'SLA ' . $sla_nr . ': ' . $rtt_type . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... ' . $rtt . 'ms at ' . $time . '\n';
$fields = [
'rtt' => $rtt,
];
// The base RRD
$rrd_name = ['sla', $sla_nr];
$rrd_def = RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000);
$tags = compact('sla_nr', 'rrd_name', 'rrd_def');
data_update($device, 'sla', $tags, $fields);
// Let's gather some per-type fields.
switch ($rtt_type) {
case 'jitter':
$jitter = [
'PacketLossSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.26'][$sla_nr],
'PacketLossDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.27'][$sla_nr],
'PacketOutOfSequence' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.28'][$sla_nr],
'PacketMIA' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.29'][$sla_nr],
'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.30'][$sla_nr],
'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla_nr] / 100,
'ICPIF' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.43'][$sla_nr],
'OWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.49'][$sla_nr],
'OWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.50'][$sla_nr],
'AvgSDJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.47'][$sla_nr],
'AvgDSJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.48'][$sla_nr],
];
$rrd_name = ['sla', $sla_nr, $rtt_type];
$rrd_def = RrdDefinition::make()
->addDataset('PacketLossSD', 'GAUGE', 0)
->addDataset('PacketLossDS', 'GAUGE', 0)
->addDataset('PacketOutOfSequence', 'GAUGE', 0)
->addDataset('PacketMIA', 'GAUGE', 0)
->addDataset('PacketLateArrival', 'GAUGE', 0)
->addDataset('MOS', 'GAUGE', 0)
->addDataset('ICPIF', 'GAUGE', 0)
->addDataset('OWAvgSD', 'GAUGE', 0)
->addDataset('OWAvgDS', 'GAUGE', 0)
->addDataset('AvgSDJ', 'GAUGE', 0)
->addDataset('AvgDSJ', 'GAUGE', 0);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
data_update($device, 'sla', $tags, $jitter);
$fields = array_merge($fields, $jitter);
break;
case 'icmpjitter':
$icmpjitter = [
'PacketLoss' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.26'][$sla_nr],
'PacketOosSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.28'][$sla_nr],
'PacketOosDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.29'][$sla_nr],
'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.32'][$sla_nr],
'JitterAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.45'][$sla_nr],
'JitterAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.46'][$sla_nr],
'LatencyOWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.47'][$sla_nr],
'LatencyOWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.48'][$sla_nr],
'JitterIAJOut' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.49'][$sla_nr],
'JitterIAJIn' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.50'][$sla_nr],
];
$rrd_name = ['sla', $sla_nr, $rtt_type];
$rrd_def = RrdDefinition::make()
->addDataset('PacketLoss', 'GAUGE', 0)
->addDataset('PacketOosSD', 'GAUGE', 0)
->addDataset('PacketOosDS', 'GAUGE', 0)
->addDataset('PacketLateArrival', 'GAUGE', 0)
->addDataset('JitterAvgSD', 'GAUGE', 0)
->addDataset('JitterAvgDS', 'GAUGE', 0)
->addDataset('LatencyOWAvgSD', 'GAUGE', 0)
->addDataset('LatencyOWAvgDS', 'GAUGE', 0)
->addDataset('JitterIAJOut', 'GAUGE', 0)
->addDataset('JitterIAJIn', 'GAUGE', 0);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
data_update($device, 'sla', $tags, $icmpjitter);
$fields = array_merge($fields, $icmpjitter);
break;
}
d_echo('The following datasources were collected for #' . $sla['sla_nr'] . ":\n");
d_echo($fields);
// Update the DB if necessary
if (count($update) > 0) {
$updated = dbUpdate($update, 'slas', '`sla_id` = ?', [$sla['sla_id']]);
}
}
}
unset($slas);

View File

@@ -0,0 +1,26 @@
<?php
/**
* sla.inc.php
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*/
use LibreNMS\OS;
if (! $os instanceof OS) {
$os = OS::make($device);
}
(new \LibreNMS\Modules\Slas())->poll($os);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1049,7 +1049,7 @@
"default": false,
"type": "boolean"
},
"discovery_modules.cisco-sla": {
"discovery_modules.slas": {
"order": 80,
"group": "discovery",
"section": "discovery_modules",
@@ -1529,10 +1529,6 @@
"default": true,
"type": "boolean"
},
"enable_sla": {
"default": false,
"type": "boolean"
},
"enable_syslog": {
"default": false,
"type": "boolean"
@@ -4417,7 +4413,7 @@
"default": false,
"type": "boolean"
},
"poller_modules.cisco-sla": {
"poller_modules.slas": {
"order": 140,
"group": "poller",
"section": "poller_modules",
@@ -4980,90 +4976,6 @@
"mono": "mono"
}
},
"sla_type_labels.dhcp": {
"default": "DHCP",
"type": "text"
},
"sla_type_labels.dlsw": {
"default": "DLSW",
"type": "text"
},
"sla_type_labels.dns": {
"default": "DNS",
"type": "text"
},
"sla_type_labels.echo": {
"default": "ICMP ping",
"type": "text"
},
"sla_type_labels.ethernetJitter": {
"default": "Ethernet jitter",
"type": "text"
},
"sla_type_labels.ethernetPing": {
"default": "Ethernet ping",
"type": "text"
},
"sla_type_labels.fileIO": {
"default": "File I/O",
"type": "text"
},
"sla_type_labels.ftp": {
"default": "FTP",
"type": "text"
},
"sla_type_labels.http": {
"default": "HTTP",
"type": "text"
},
"sla_type_labels.icmpjitter": {
"default": "ICMP jitter",
"type": "text"
},
"sla_type_labels.jitter": {
"default": "Jitter",
"type": "text"
},
"sla_type_labels.lspGroup": {
"default": "LSP group",
"type": "text"
},
"sla_type_labels.lspPing": {
"default": "LSP ping",
"type": "text"
},
"sla_type_labels.lspPingPseudowire": {
"default": "LSP Pseudowire ping",
"type": "text"
},
"sla_type_labels.lspTrace": {
"default": "LSP trace",
"type": "text"
},
"sla_type_labels.pathEcho": {
"default": "Path ICMP ping",
"type": "text"
},
"sla_type_labels.rtp": {
"default": "RTP",
"type": "text"
},
"sla_type_labels.script": {
"default": "Script",
"type": "text"
},
"sla_type_labels.tcpConnect": {
"default": "TCP connect",
"type": "text"
},
"sla_type_labels.udpEcho": {
"default": "UDP ping",
"type": "text"
},
"sla_type_labels.voip": {
"default": "VoIP",
"type": "text"
},
"smokeping.pings": {
"default": 5,
"group": "external",

View File

@@ -1849,10 +1849,11 @@ slas:
Columns:
- { Field: sla_id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }
- { Field: device_id, Type: 'int unsigned', 'Null': false, Extra: '' }
- { Field: sla_nr, Type: int, 'Null': false, Extra: '' }
- { Field: sla_nr, Type: 'int unsigned', 'Null': false, Extra: '' }
- { Field: owner, Type: varchar(255), 'Null': false, Extra: '' }
- { Field: tag, Type: varchar(255), 'Null': false, Extra: '' }
- { Field: rtt_type, Type: varchar(16), 'Null': false, Extra: '' }
- { Field: rtt, Type: 'double(8,2) unsigned', 'Null': true, Extra: '' }
- { Field: status, Type: tinyint, 'Null': false, Extra: '' }
- { Field: opstatus, Type: tinyint, 'Null': false, Extra: '', Default: '0' }
- { Field: deleted, Type: tinyint, 'Null': false, Extra: '', Default: '0' }

View File

@@ -78,7 +78,7 @@
"cisco-remote-access-monitor": {
"type": "boolean"
},
"cisco-sla": {
"slas": {
"type": "boolean"
},
"cisco-ipsec-flow-monitor": {
@@ -219,7 +219,7 @@
"cisco-cef": {
"type": "boolean"
},
"cisco-sla": {
"slas": {
"type": "boolean"
},
"cisco-mac-accounting": {

View File

@@ -0,0 +1,36 @@
<?php
return [
'slas' => [
'types' => [
'dhcp' => 'DHCP',
'dlsw' => 'DLSW',
'dns' => 'DNS',
'DnsQuery' => 'DNS Query',
'echo' => 'ICMP Ping',
'ethernetJitter' => 'Ethernet Jitter',
'ethernetPing' => 'Ethernet Ping',
'fileIO' => 'File I/O',
'ftp' => 'FTP',
'http' => 'HTTP',
'HttpGet' => 'HTTP Get',
'HttpGetMetadata' => 'HTTP Get Metadata',
'IcmpEcho' => 'ICMP Echo',
'icmpjitter' => 'ICMP Jitter',
'IcmpTimeStamp' => 'ICMP TimeStamp',
'jitter' => 'Jitter',
'lspGroup' => 'LSP Group',
'lspPing' => 'LSP Ping',
'lspPingPseudowire' => 'LSP Pseudowire Ping"',
'lspTrace' => 'LSP Trace',
'NtpQuery' => 'NTP Query',
'pathEcho' => 'Path ICMP Ping',
'rtp' => 'RTP',
'script' => 'Script',
'tcpConnect' => 'TCP Connect',
'udpEcho' => 'UDP Ping',
'UdpTimestamp' => 'UDP Timestamp',
'voip' => 'VoIP',
],
],
];

View File

@@ -42619,5 +42619,122 @@
}
]
}
},
"slas": {
"discovery": {
"slas": [
{
"sla_nr": 10,
"owner": "",
"tag": "194.53.124.254:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 11,
"owner": "",
"tag": "194.53.125.33:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 12,
"owner": "",
"tag": "194.53.125.37:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 50,
"owner": "",
"tag": "194.53.124.211:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 51,
"owner": "",
"tag": "194.53.124.212:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 52,
"owner": "",
"tag": "194.53.124.213:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 100,
"owner": "",
"tag": "194.53.124.239",
"rtt_type": "echo",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 190,
"owner": "",
"tag": "194.53.124.222:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 191,
"owner": "",
"tag": "194.53.124.223:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 300,
"owner": "",
"tag": "194.53.124.32:1000",
"rtt_type": "jitter",
"rtt": 1.0,
"status": 1,
"opstatus": 0,
"deleted": 0
},
{
"sla_nr": 1000,
"owner": "",
"tag": "10.30.1.2",
"rtt_type": "echo",
"rtt": 3.0,
"status": 1,
"opstatus": 0,
"deleted": 0
}
]
},
"poller": "matches discovery"
}
}

13783
tests/data/junos_vmx.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -116,6 +116,10 @@ sensors:
- { custom: 'INNER JOIN ( SELECT i.state_index_id FROM `sensors_to_state_indexes` i LEFT JOIN `sensors` s ON (i.`sensor_id` = s.`sensor_id`) WHERE `device_id`=? GROUP BY i.state_index_id) d ON d.state_index_id = state_indexes.state_index_id' }
order_by: state_indexes.state_name, state_translations.state_value
custom_where: ''
slas:
slas:
excluded_fields: [device_id, sla_id]
order_by: sla_nr
storage:
storage:
excluded_fields: [device_id, storage_id]

File diff suppressed because it is too large Load Diff