refactor: ntp apps (#4333)

* updated nicecase function for ntp server and client app

* ntp applications refactoring

* removed agent for ntp-server: reported as not working

* removed ntpd from agent polling. thx @murrant
This commit is contained in:
crcro
2016-09-10 15:37:00 +03:00
committed by Tony Murray
parent d6d2ff8499
commit de707a259f
19 changed files with 138 additions and 146 deletions

View File

@@ -12,7 +12,8 @@ Different applications support a variety of ways collect data: by direct connect
1. [Memcached](#memcached) - SNMP extend
1. [MySQL](#mysql) - Agent
1. [NGINX](#nginx) - Agent
1. [NTPD](#ntpd-server) - SNMP extend, Agent
1. [NTP Client](#ntp-client) - SNMP extend
1. [NTP Server](#ntp-server) - SNMP extend
1. [OS Updates](#os-updates) - SNMP extend
1. [PowerDNS](#powerdns) - Agent
1. [PowerDNS Recursor](#powerdns-recursor) - Direct, Agent
@@ -151,25 +152,39 @@ location /nginx-status {
```
### NTPD Server
Supports NTPD Server (not client, that is separate)
### NTP Client
A shell script that gets stats from ntp client.
##### SNMP Extend
1. Download the script onto the desired host (the host must be added to LibreNMS devices)
```
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/ntpd-server.php -O /etc/snmp/ntpd-server.php
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/ntp-client.sh -O /opt/ntp-client.sh
```
2. Make the script executable (chmod +x /etc/snmp/ntdp-server.php)
2. Make the script executable (chmod +x /opt/ntp-client.sh)
3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
```
extend ntpdserver /etc/snmp/ntpd-server.php
extend ntp-client /etc/snmp/ntp-client.sh
```
4. Restart snmpd on your host
5. On the device page in Librenms, edit your host and check the `Ntpd-server` under the Applications tab.
5. On the device page in Librenms, edit your host and check the `NTP Client` under the Applications tab.
##### Agent
Support is built into the agent, and this app will be automatically enabled.
### NTP Server (NTPD)
A shell script that gets stats from ntp server (ntpd).
##### SNMP Extend
1. Download the script onto the desired host (the host must be added to LibreNMS devices)
```
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/ntp-server.sh -O /opt/ntp-server.sh
```
2. Make the script executable (chmod +x /opt/ntp-server.sh)
3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add:
```
extend ntp-server /etc/snmp/ntp-server.sh
```
4. Restart snmpd on your host
5. On the device page in Librenms, edit your host and check the `NTP Server` under the Applications tab.

View File

@@ -73,8 +73,11 @@ function nicecase($item)
case 'nfs-v3-stats':
return 'NFS v3 Stats';
case 'ntpd':
return 'NTPD (Server)';
case 'ntp-client':
return 'NTP Client';
case 'ntp-server':
return 'NTP Server';
case 'os-updates':
return 'OS Updates';

View File

@@ -9,7 +9,7 @@ $colour_line = 'B3D0DB';
$colour_area_max = 'FFEE99';
$graph_max = 100;
$unit_text = 'Frequency';
$ntpclient_rrd = rrd_name($device['hostname'], array('app', 'ntpclient', $app['app_id']));
$ntpclient_rrd = rrd_name($device['hostname'], array('app', 'ntp-client', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpclient_rrd)) {
$rrd_filename = $ntpclient_rrd;

View File

@@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php';
$colours = 'mixed';
$nototal = (($width < 224) ? 1 : 0);
$unit_text = 'Milliseconds';
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpclient', $app['app_id']));
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntp-client', $app['app_id']));
$array = array(
'offset' => array('descr' => 'Offset'),
'jitter' => array('descr' => 'Jitter'),

View File

@@ -1,18 +1,9 @@
<?php
// $units = "b";
// $total_units = "B";
// $colours_in = "greens";
// $multiplier = "0";
// $colours_out = "blues";
$nototal = 1;
$ds_in = 'packets_recv';
$ds_out = 'packets_sent';
$graph_title .= '::packets';
$unit_text = 'Packets';
$colour_line_in = '330033';
$colour_line_out = 'FF6600';
$colour_area_in = 'AA66AA';
@@ -20,11 +11,10 @@ $colour_area_out = 'FFDD88';
$colour_area_in_max = 'CC88CC';
$colour_area_out_max = 'FFEFAA';
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpdserver_rrd)) {
$rrd_filename = $ntpdserver_rrd;
}
// include("includes/graphs/generic_bits.inc.php");
require 'includes/graphs/generic_duplex.inc.php';

View File

@@ -6,7 +6,7 @@ $scale_min = 0;
$colours = 'mixed';
$nototal = (($width < 224) ? 1 : 0);
$unit_text = 'Buffer';
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
$array = array(
'buffer_recv' => array('descr' => 'Received'),
'buffer_used' => array('descr' => 'Used'),

View File

@@ -9,7 +9,7 @@ $colour_line = 'B3D0DB';
$colour_area_max = 'FFEE99';
$graph_max = 100;
$unit_text = 'Frequency';
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpdserver_rrd)) {
$rrd_filename = $ntpdserver_rrd;

View File

@@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php';
$scale_min = 0;
$nototal = (($width < 224) ? 1 : 0);
$unit_text = 'Packets';
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
$array = array(
'packets_drop' => array(
'descr' => 'Dropped',
@@ -31,5 +31,4 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
echo "file missing: $file";
}
// include("includes/graphs/generic_multi_line.inc.php");
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';

View File

@@ -5,7 +5,7 @@ require 'includes/graphs/common.inc.php';
$colours = 'mixed';
$nototal = (($width < 224) ? 1 : 0);
$unit_text = 'Milliseconds';
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$rrd_filename = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
$array = array(
'offset' => array('descr' => 'Offset'),
'jitter' => array('descr' => 'Jitter'),

View File

@@ -9,7 +9,7 @@ $colour_line = '880000';
$colour_area_max = 'FFCCCC';
$graph_max = 0;
$unit_text = 'Stratum';
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpdserver_rrd)) {
$rrd_filename = $ntpdserver_rrd;

View File

@@ -0,0 +1,18 @@
<?php
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$ds = 'uptime';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Seconds';
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntp-server', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpdserver_rrd)) {
$rrd_filename = $ntpdserver_rrd;
}
require 'includes/graphs/generic_simplex.inc.php';

View File

@@ -1,36 +0,0 @@
<?php
require 'includes/graphs/common.inc.php';
$scale_min = 0;
$ds = 'uptime';
// $colour_area = "CEFFCE";
// $colour_line = "008800";
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$graph_max = 0;
$unit_text = 'Seconds';
$ntpdserver_rrd = rrd_name($device['hostname'], array('app', 'ntpdserver', $app['app_id']));
if (rrdtool_check_rrd_exists($ntpdserver_rrd)) {
$rrd_filename = $ntpdserver_rrd;
}
require 'includes/graphs/common.inc.php';
$rrd_options .= ' DEF:uptime='.$rrd_filename.':uptime:AVERAGE';
$rrd_options .= ' CDEF:cuptime=uptime,86400,/';
if ($width < 224) {
$rrd_options .= " 'COMMENT:Days Cur Min Max Avg\\n'";
} else {
$rrd_options .= " 'COMMENT:Days Current Minimum Maximum Average\\n'";
}
$rrd_options .= ' AREA:cuptime#'.$colour_area.':';
$rrd_options .= ' LINE1.25:cuptime#'.$colour_line.':Uptime';
$rrd_options .= ' GPRINT:cuptime:LAST:%6.2lf';
$rrd_options .= ' GPRINT:cuptime:AVERAGE:%6.2lf';
$rrd_options .= ' GPRINT:cuptime:MAX:%6.2lf';
$rrd_options .= " GPRINT:cuptime:AVERAGE:%6.2lf\\n";

View File

@@ -66,6 +66,21 @@ $graphs['powerdns'] = array(
'queries_udp',
);
$graphs['ntp-client'] = array(
'stats',
'freq',
);
$graphs['ntp-server'] = array(
'stats',
'freq',
'stratum',
'buffer',
'bits',
'packets',
'uptime',
);
$graphs['nfs-v3-stats'] = array(
'stats',
'io',

View File

@@ -3,8 +3,8 @@
global $config;
$graphs = array(
'ntpclient_stats' => 'NTP Client - Statistics',
'ntpclient_freq' => 'NTP Client - Frequency',
'ntp-client_stats' => 'NTP Client - Statistics',
'ntp-client_freq' => 'NTP Client - Frequency',
);
foreach ($graphs as $key => $text) {

View File

@@ -3,13 +3,13 @@
global $config;
$graphs = array(
'ntpdserver_stats' => 'NTPD Server - Statistics',
'ntpdserver_freq' => 'NTPD Server - Frequency',
'ntpdserver_stratum' => 'NTPD Server - Stratum',
'ntpdserver_buffer' => 'NTPD Server - Buffer',
'ntpdserver_bits' => 'NTPD Server - Packets Sent/Received',
'ntpdserver_packets' => 'NTPD Server - Packets Dropped/Ignored',
'ntpdserver_uptime' => 'NTPD Server - Uptime',
'ntp-server_stats' => 'NTPD Server - Statistics',
'ntp-server_freq' => 'NTPD Server - Frequency',
'ntp-server_stratum' => 'NTPD Server - Stratum',
'ntp-server_buffer' => 'NTPD Server - Buffer',
'ntp-server_bits' => 'NTPD Server - Packets Sent/Received',
'ntp-server_packets' => 'NTPD Server - Packets Dropped/Ignored',
'ntp-server_uptime' => 'NTPD Server - Uptime',
);
foreach ($graphs as $key => $text) {

View File

@@ -1,13 +1,11 @@
<?php
// Polls ntp-client statistics from script via SNMP
$options = '-O qv';
$oid = 'nsExtendOutputFull.9.110.116.112.99.108.105.101.110.116';
$ntpclient = snmp_get($device, $oid, $options);
$name = 'ntpclient';
//NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ntp-client"
$name = 'ntp-client';
$app_id = $app['app_id'];
echo ' ntp-client';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.110.116.112.45.99.108.105.101.110.116';
$ntpclient = snmp_get($device, $oid, '-Oqv');
echo ' '.$name;
list ($offset, $frequency, $jitter, $noise, $stability) = explode("\n", $ntpclient);
@@ -21,10 +19,10 @@ $rrd_def = array(
);
$fields = array(
'offset' => $offset,
'offset' => $offset,
'frequency' => $frequency,
'jitter' => $jitter,
'noise' => $noise,
'jitter' => $jitter,
'noise' => $noise,
'stability' => $stability,
);

View File

@@ -0,0 +1,49 @@
<?php
//NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ntp-server"
$name = 'ntp-server';
$app_id = $app['app_id'];
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.110.116.112.45.115.101.114.118.101.114';
$ntpserver_data = snmp_get($device, $oid, '-Oqv');
list ($stratum, $offset, $frequency, $jitter, $noise, $stability, $uptime, $buffer_recv, $buffer_free, $buffer_used, $packets_drop, $packets_ignore, $packets_recv, $packets_sent) = explode("\n", $ntpserver_data);
echo ' '.$name;
$rrd_name = array('app', $name, $app_id);
$rrd_def = array(
'DS:stratum:GAUGE:600:0:1000',
'DS:offset:GAUGE:600:-1000:1000',
'DS:frequency:GAUGE:600:-1000:1000',
'DS:jitter:GAUGE:600:-1000:1000',
'DS:noise:GAUGE:600:-1000:1000',
'DS:stability:GAUGE:600:-1000:1000',
'DS:uptime:GAUGE:600:0:125000000000',
'DS:buffer_recv:GAUGE:600:0:100000',
'DS:buffer_free:GAUGE:600:0:100000',
'DS:buffer_used:GAUGE:600:0:100000',
'DS:packets_drop:DERIVE:600:0:125000000000',
'DS:packets_ignore:DERIVE:600:0:125000000000',
'DS:packets_recv:DERIVE:600:0:125000000000',
'DS:packets_sent:DERIVE:600:0:125000000000'
);
$fields = array(
'stratum' => $stratum,
'offset' => $offset,
'frequency' => $frequency,
'jitter' => $jitter,
'noise' => $noise,
'stability' => $stability,
'uptime' => $uptime,
'buffer_recv' => $buffer_recv,
'buffer_free' => $buffer_free,
'buffer_used' => $buffer_used,
'packets_drop' => $packets_drop,
'packets_ignore' => $packets_ignore,
'packets_recv' => $packets_recv,
'packets_sent' => $packets_sent,
);
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
data_update($device, 'app', $tags, $fields);

View File

@@ -1,58 +0,0 @@
<?php
// Polls ntpd-server statistics from script via SNMP
$name = 'ntpdserver';
$app_id = $app['app_id'];
echo ' ntpd-server';
$rrd_name = array('app', $name, $app_id);
$rrd_def = array(
'DS:stratum:GAUGE:600:-1000:1000',
'DS:offset:GAUGE:600:-1000:1000',
'DS:frequency:GAUGE:600:-1000:1000',
'DS:jitter:GAUGE:600:-1000:1000',
'DS:noise:GAUGE:600:-1000:1000',
'DS:stability:GAUGE:600:-1000:1000',
'DS:uptime:GAUGE:600:0:125000000000',
'DS:buffer_recv:GAUGE:600:0:100000',
'DS:buffer_free:GAUGE:600:0:100000',
'DS:buffer_used:GAUGE:600:0:100000',
'DS:packets_drop:DERIVE:600:0:125000000000',
'DS:packets_ignore:DERIVE:600:0:125000000000',
'DS:packets_recv:DERIVE:600:0:125000000000',
'DS:packets_sent:DERIVE:600:0:125000000000'
);
if ($agent_data['app']['ntpd']) {
$data = explode("\n", $agent_data['app']['ntpd']);
$fields = array();
foreach ($data as $line) {
$split = explode(':', $line);
$fields[$split[0]] = $split[1];
}
} else {
// NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ntpdserver"
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.110.116.112.100.115.101.114.118.101.114';
$data = explode("\n", snmp_get($device, $oid, '-Oqv'));
$fields = array(
'stratum' => $data[0],
'offset' => $data[1],
'frequency' => $data[2],
'jitter' => $data[3],
'noise' => $data[4],
'stability' => $data[5],
'uptime' => $data[6],
'buffer_recv' => $data[7],
'buffer_free' => $data[8],
'buffer_used' => $data[9],
'packets_drop' => $data[10],
'packets_ignore' => $data[11],
'packets_recv' => $data[12],
'packets_sent' => $data[13],
);
}
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
data_update($device, 'app', $tags, $fields);

View File

@@ -57,7 +57,6 @@ if ($device['os_group'] == 'unix') {
"ceph",
"mysql",
"nginx",
"ntpd",
"powerdns",
"powerdns-recursor",
"proxmox",