mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Add support for Allied Telesis AlliedWare Plus products - Uses mibs from 5.4.7-2.1 for AlliedWare Plus products - Updates Legacy AlliedWare mibs - Added Allied Telesis svg * Remove unnecessary "trim" from snmpget * Add new line to end of file * Minor fixes for commit * awplus: initial ntp commit This isn't completely working, however initial patch of it partially working * awplus: Add NTP support - Fixed polling issues for awplus. Now offset and delay graphs work. - html/includes/graphs/device/ntp_*.inc.php -- Removed extra "\" from MAX count which showed up in Graph legend - html/includes/graphs/device/ntp_delay.inc.php -- Present legend in either seconds, or milliseconds (depending on vendor) - html/includes/graphs/device/ntp_dispersion.inc.php -- Present legend in either seconds, or milliseconds (depending on vendor) - html/includes/graphs/device/ntp_offset.inc.php -- Removed rrd minimum (-l 0). This is because offset can be below 0. --- It's better for the graph to auto scale than set a fixed minimum to display here. - html/includes/graphs/device/ntp_stratum.inc.php -- Changed graph to go from 0 to max of 16. NTP Stratum can only be 0 to 16. * awplus: Add NTP test data * updated awplus ntp poller * device: awplus convert NTP poller into seconds * device: fix NTP graph formatting * device: Improve NTP formatting * device: unset awplus NTP variable * fix formatting * device: awplus change NTP from numerical OIDs to named * device: update awplus ntp json tests * device: fix cisco and awplus ntp database creation * device: update awplus json
86 lines
3.6 KiB
PHP
86 lines
3.6 KiB
PHP
<?php
|
|
/*
|
|
* LibreNMS module to capture statistics from the AT-NTP-MIB
|
|
*
|
|
* Copyright (c) 2018 Matt Read <matt.read@alliedtelesis.co.nz>
|
|
*
|
|
* 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 LibreNMS\RRD\RrdDefinition;
|
|
|
|
$tmp_module = 'ntp';
|
|
|
|
$component = new LibreNMS\Component();
|
|
$options = array();
|
|
$options['filter']['type'] = array('=',$tmp_module);
|
|
$options['filter']['disabled'] = array('=',0);
|
|
$options['filter']['ignore'] = array('=',0);
|
|
$components = $component->getComponents($device['device_id'], $options);
|
|
|
|
// We only care about our device id.
|
|
$components = $components[$device['device_id']];
|
|
|
|
// Only collect SNMP data if we have enabled components
|
|
if (count($components > 0)) {
|
|
// Let's gather the stats..
|
|
$atNtpAssociationEntry = snmpwalk_group($device, 'atNtpAssociationEntry', 'AT-NTP-MIB');
|
|
|
|
// Loop through the components and extract the data.
|
|
foreach ($components as $key => &$array) {
|
|
$peer = $array['peer'];
|
|
|
|
// Let's make sure the rrd is setup for this class.
|
|
$rrd_name = array('ntp', $peer);
|
|
$rrd_def = RrdDefinition::make()
|
|
->addDataset('stratum', 'GAUGE', 0, 16)
|
|
->addDataset('offset', 'GAUGE', -1000)
|
|
->addDataset('delay', 'GAUGE', -1000)
|
|
->addDataset('dispersion', 'GAUGE', -1000);
|
|
|
|
$array['stratum'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationStratum'];
|
|
// Set the status, 16 = Bad
|
|
if ($array['stratum'] == 16) {
|
|
$array['status'] = 2;
|
|
$array['error'] = 'NTP is not in sync';
|
|
} else {
|
|
$array['status'] = 0;
|
|
$array['error'] = '';
|
|
}
|
|
|
|
// Extract the statistics and update rrd
|
|
$rrd['stratum'] = $array['stratum'];
|
|
$rrd['offset'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationOffset'];
|
|
$rrd['offset'] = str_replace(' milliseconds', '', $rrd['offset']);
|
|
$rrd['offset'] = $rrd['offset'] / 1000; // Convert to seconds
|
|
$rrd['delay'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationDelay'];
|
|
$rrd['delay'] = str_replace(' milliseconds', '', $rrd['delay']);
|
|
$rrd['delay'] = $rrd['delay'] / 1000; // Convert to seconds
|
|
$rrd['dispersion'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationDisp'];
|
|
$tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer');
|
|
data_update($device, 'ntp', $tags, $rrd);
|
|
|
|
// Let's print some debugging info.
|
|
d_echo("\n\nComponent: ".$key."\n");
|
|
d_echo(" Index: ".$array['UID']."\n");
|
|
d_echo(" Peer: ".$array['peer'].":".$array['port']."\n");
|
|
d_echo(" Stratum: atNtpAssociationStratum.".$array['UID']." = ".$rrd['stratum']."\n");
|
|
d_echo(" Offset: atNtpAssociationOffset.".$array['UID']." = ".$rrd['offset']."\n");
|
|
d_echo(" Delay: atNtpAssociationDelay.".$array['UID']." = ".$rrd['delay']."\n");
|
|
d_echo(" Dispersion: atNtpAssociationDisp.".$array['UID']." = ".$rrd['dispersion']."\n");
|
|
|
|
// Clean-up after yourself!
|
|
unset($filename, $rrd_filename, $rrd);
|
|
} // End foreach components
|
|
|
|
// Write the Components back to the DB.
|
|
$component->setComponentPrefs($device['device_id'], $components);
|
|
} // end if count components
|
|
|
|
// Clean-up after yourself!
|
|
unset($type, $components, $component, $options, $tmp_module);
|