mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add NTP client/server application poller. fix powerdns_latency graphtype. from Dennis de Houx.
git-svn-id: http://www.observium.org/svn/observer/trunk@2612 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
20
html/includes/graphs/application/ntpclient_freq.inc.php
Normal file
20
html/includes/graphs/application/ntpclient_freq.inc.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$scale_min = 0;
|
||||
$ds = "frequency";
|
||||
$colour_area = "F6F6F6";
|
||||
$colour_line = "B3D0DB";
|
||||
$colour_area_max = "FFEE99";
|
||||
$graph_max = 100;
|
||||
$unit_text = "Frequency";
|
||||
$ntpclient_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpclient-".$app['app_id'].".rrd";
|
||||
|
||||
if (is_file($ntpclient_rrd)) {
|
||||
$rrd_filename = $ntpclient_rrd;
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
32
html/includes/graphs/application/ntpclient_stats.inc.php
Normal file
32
html/includes/graphs/application/ntpclient_stats.inc.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = (($width<224) ? 1 : 0);
|
||||
$unit_text = "Milliseconds";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpclient-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'offset' => array('descr' => 'Offset'),
|
||||
'jitter' => array('descr' => 'Jitter'),
|
||||
'noise' => array('descr' => 'Noise'),
|
||||
'stability' => array('descr' => 'Stability')
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
?>
|
33
html/includes/graphs/application/ntpdserver_bits.inc.php
Normal file
33
html/includes/graphs/application/ntpdserver_bits.inc.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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";
|
||||
$colour_area_out = "FFDD88";
|
||||
$colour_area_in_max = "CC88CC";
|
||||
$colour_area_out_max= "FFEFAA";
|
||||
|
||||
$ntpdserver_rrd = $config['rrd_dir'] . "/". $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
|
||||
if (is_file($ntpdserver_rrd)) {
|
||||
$rrd_filename = $ntpdserver_rrd;
|
||||
}
|
||||
|
||||
// include("includes/graphs/generic_bits.inc.php");
|
||||
include("includes/graphs/generic_duplex.inc.php");
|
||||
|
||||
?>
|
20
html/includes/graphs/application/ntpdserver_freq.inc.php
Normal file
20
html/includes/graphs/application/ntpdserver_freq.inc.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$scale_min = 0;
|
||||
$ds = "frequency";
|
||||
$colour_area = "F6F6F6";
|
||||
$colour_line = "B3D0DB";
|
||||
$colour_area_max = "FFEE99";
|
||||
$graph_max = 100;
|
||||
$unit_text = "Frequency";
|
||||
$ntpdserver_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
|
||||
if (is_file($ntpdserver_rrd)) {
|
||||
$rrd_filename = $ntpdserver_rrd;
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
31
html/includes/graphs/application/ntpdserver_packets.inc.php
Normal file
31
html/includes/graphs/application/ntpdserver_packets.inc.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$scale_min = 0;
|
||||
$nototal = (($width<224) ? 1 : 0);
|
||||
$unit_text = "Packets";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'packets_drop' => array('descr' => 'Dropped', 'colour' => '880000FF'),
|
||||
'packets_ignore' => array('descr' => 'Ignored', 'colour' => 'FF8800FF')
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
// include("includes/graphs/generic_multi_line.inc.php");
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
32
html/includes/graphs/application/ntpdserver_stats.inc.php
Normal file
32
html/includes/graphs/application/ntpdserver_stats.inc.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$colours = "mixed";
|
||||
$nototal = (($width<224) ? 1 : 0);
|
||||
$unit_text = "Milliseconds";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
$array = array(
|
||||
'offset' => array('descr' => 'Offset'),
|
||||
'jitter' => array('descr' => 'Jitter'),
|
||||
'noise' => array('descr' => 'Noise'),
|
||||
'stability' => array('descr' => 'Stability')
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo("file missing: $file");
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
?>
|
20
html/includes/graphs/application/ntpdserver_stratum.inc.php
Normal file
20
html/includes/graphs/application/ntpdserver_stratum.inc.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$scale_min = 0;
|
||||
$ds = "stratum";
|
||||
$colour_area = "FFCECE";
|
||||
$colour_line = "880000";
|
||||
$colour_area_max = "FFCCCC";
|
||||
$graph_max = 0;
|
||||
$unit_text = "Stratum";
|
||||
$ntpdserver_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
|
||||
if (is_file($ntpdserver_rrd)) {
|
||||
$rrd_filename = $ntpdserver_rrd;
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
36
html/includes/graphs/application/ntpdserver_uptime.inc.php
Normal file
36
html/includes/graphs/application/ntpdserver_uptime.inc.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
include("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 = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
|
||||
if (is_file($ntpdserver_rrd)) {
|
||||
$rrd_filename = $ntpdserver_rrd;
|
||||
}
|
||||
|
||||
include("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";
|
||||
|
||||
?>
|
@@ -4,8 +4,8 @@
|
||||
|
||||
$scale_min = 0;
|
||||
$ds = "latency";
|
||||
$colour_area = "6699FF";
|
||||
$colour_line = "336699";
|
||||
$colour_area = "F6F6F6";
|
||||
$colour_line = "B3D0DB";
|
||||
$colour_area_max = "FFEE99";
|
||||
$graph_max = 100;
|
||||
$unit_text = "Latency";
|
||||
|
@@ -181,6 +181,7 @@ print_optionbar_end();
|
||||
<b>Jonathan De Graeve</b> SNMP code improvements. <br />
|
||||
<b>Xiaochi Jin</b> Logo design. <br />
|
||||
<b>Bruno Pramont</b> Collectd code. <br />
|
||||
<b>Dennis de Houx</b> Application monitors for PowerDNS, Shoutcast, NTPD (Client, Server). <br />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
21
html/pages/device/apps/ntp-client.inc.php
Normal file
21
html/pages/device/apps/ntp-client.inc.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
$graphs = array('ntpclient_stats' => 'NTP Client - Statistics',
|
||||
'ntpclient_freq' => 'NTP Client - Frequency');
|
||||
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = "application_".$key;
|
||||
echo('<h3>'.$text.'</h3>');
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
echo("</td></tr>");
|
||||
}
|
||||
|
||||
?>
|
26
html/pages/device/apps/ntpd-server.inc.php
Normal file
26
html/pages/device/apps/ntpd-server.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
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');
|
||||
|
||||
foreach ($graphs as $key => $text) {
|
||||
$graph_type = $key;
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $now;
|
||||
$graph_array['id'] = $app['app_id'];
|
||||
$graph_array['type'] = "application_".$key;
|
||||
echo('<h3>'.$text.'</h3>');
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=5>");
|
||||
include("includes/print-quadgraphs.inc.php");
|
||||
echo("</td></tr>");
|
||||
}
|
||||
|
||||
?>
|
@@ -43,7 +43,6 @@ if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"]))
|
||||
$config['title_image'] = "images/observium-logo.png";
|
||||
$config['stylesheet'] = "css/styles.css";
|
||||
$config['mono_font'] = "DejaVuSansMono";
|
||||
#$config['mono_font'] = "LiberationMono";
|
||||
$config['favicon'] = "images/observium-icon.png";
|
||||
$config['header_color'] = "#1F334E";
|
||||
$config['page_refresh'] = "300"; ## Refresh the page every xx seconds
|
||||
|
38
includes/polling/applications/ntp-client.inc.php
Normal file
38
includes/polling/applications/ntp-client.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
## Polls ntp-client statistics from script via SNMP
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpclient-".$app['app_id'].".rrd";
|
||||
$options = "-O qv";
|
||||
$oid = "nsExtendOutputFull.9.110.116.112.99.108.105.101.110.116";
|
||||
|
||||
$ntpclient = snmp_get($device, $oid, $options);
|
||||
|
||||
echo(" ntp-client");
|
||||
|
||||
list ($offset, $frequency, $jitter, $noise, $stability) = explode("\n", $ntpclient);
|
||||
|
||||
if (!is_file($rrd_filename)) {
|
||||
rrdtool_create($rrd_filename, "--step 300 \
|
||||
DS:offset:GAUGE:600:0:125000000000 \
|
||||
DS:frequency:GAUGE:600:0:125000000000 \
|
||||
DS:jitter:GAUGE:600:0:125000000000 \
|
||||
DS:noise:GAUGE:600:0:125000000000 \
|
||||
DS:stability:GAUGE:600:0:125000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
rrdtool_update($rrd_filename, "N:$offset:$frequency:$jitter:$noise:$stability");
|
||||
|
||||
?>
|
47
includes/polling/applications/ntpd-server.inc.php
Normal file
47
includes/polling/applications/ntpd-server.inc.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
## Polls ntpd-server statistics from script via SNMP
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-ntpdserver-".$app['app_id'].".rrd";
|
||||
$options = "-O qv";
|
||||
$oid = "nsExtendOutputFull.10.110.116.112.100.115.101.114.118.101.114";
|
||||
|
||||
$ntpdserver = snmp_get($device, $oid, $options);
|
||||
|
||||
echo(" ntpd-server");
|
||||
|
||||
list ($stratum, $offset, $frequency, $jitter, $noise, $stability, $uptime, $buffer_recv, $buffer_free, $buffer_used, $packets_drop, $packets_ignore, $packets_recv, $packets_sent) = explode("\n", $ntpdserver);
|
||||
|
||||
if (!is_file($rrd_filename)) {
|
||||
rrdtool_create($rrd_filename, "--step 300 \
|
||||
DS:stratum:GAUGE:600:0:125000000000 \
|
||||
DS:offset:GAUGE:600:0:125000000000 \
|
||||
DS:frequency:GAUGE:600:0:125000000000 \
|
||||
DS:jitter:GAUGE:600:0:125000000000 \
|
||||
DS:noise:GAUGE:600:0:125000000000 \
|
||||
DS:stability:GAUGE:600:0:125000000000 \
|
||||
DS:uptime:GAUGE:600:0:125000000000 \
|
||||
DS:buffer_recv:GAUGE:600:0:125000000000 \
|
||||
DS:buffer_free:GAUGE:600:0:125000000000 \
|
||||
DS:buffer_used:GAUGE:600:0:125000000000 \
|
||||
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 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MIN:0.5:1:600 \
|
||||
RRA:MIN:0.5:6:700 \
|
||||
RRA:MIN:0.5:24:775 \
|
||||
RRA:MIN:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
rrdtool_update($rrd_filename, "N:$stratum:$offset:$frequency:$jitter:$noise:$stability:$uptime:$buffer_recv:$buffer_free:$buffer_used:$packets_drop:$packets_ignore:$packets_recv:$packets_sent");
|
||||
|
||||
?>
|
68
scripts/ntp-client.php
Normal file
68
scripts/ntp-client.php
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
########################################################################################
|
||||
##
|
||||
## A small script to grab the NTP Client statistics from a NTPD server
|
||||
## Needed commands: php, ntpd, ntpq
|
||||
##
|
||||
## Install:
|
||||
## Add the following to your snmpd.conf file:
|
||||
## extend ntpclient /opt/observium/scripts/ntp-client.php
|
||||
##
|
||||
## Version 1.0 By:
|
||||
## All In One - Dennis de Houx <info@all-in-one.be>
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
|
||||
#### START SETTINGS ####
|
||||
|
||||
$ntpq = "/usr/sbin/ntpq";
|
||||
|
||||
#### END SETTINGS ####
|
||||
|
||||
|
||||
##
|
||||
## DO NOT EDIT BENETH THIS LINE
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
$cmd = shell_exec($ntpq." -c rv | grep '^offset'");
|
||||
$cmd2 = shell_exec($ntpq." -c rv | grep '^stability'");
|
||||
$vars = array();
|
||||
$vars2 = array();
|
||||
$vars = explode(',', $cmd);
|
||||
$vars2 = explode(',', $cmd2);
|
||||
|
||||
function doSNMPv2($vars, $vars2) {
|
||||
$ntp = array();
|
||||
foreach ($vars as $item=>$value) {
|
||||
if (!empty($value)) {
|
||||
$temp = explode('=', $value);
|
||||
if (isset($temp[1])) {
|
||||
$ntp[trim($temp[0])] = trim($temp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($vars2 as $item=>$value) {
|
||||
if (!empty($value)) {
|
||||
$temp = explode('=', $value);
|
||||
if (isset($temp[1])) {
|
||||
$ntp[trim($temp[0])] = trim($temp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$var['offset'] = (isset($ntp['offset']) ? $ntp['offset'] : "U");
|
||||
$var['frequency'] = (isset($ntp['frequency']) ? $ntp['frequency'] : "U");
|
||||
$var['jitter'] = (isset($ntp['jitter']) ? $ntp['jitter'] : "U");
|
||||
$var['noise'] = (isset($ntp['noise']) ? $ntp['noise'] : "U");
|
||||
$var['stability'] = (isset($ntp['stability']) ? $ntp['stability'] : "U");
|
||||
foreach ($var as $item=>$count) {
|
||||
echo $count."\n";
|
||||
}
|
||||
}
|
||||
|
||||
doSNMPv2($vars, $vars2);
|
||||
|
||||
?>
|
81
scripts/ntpd-server.php
Normal file
81
scripts/ntpd-server.php
Normal file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
########################################################################################
|
||||
##
|
||||
## A small script to grab the NTPD Server statistics from a NTPD server
|
||||
## Needed commands: php, ntpd, ntpq, ntpdc
|
||||
##
|
||||
## Install:
|
||||
## Add the following to your snmpd.conf file:
|
||||
## extend ntpdserver /opt/observium/scripts/ntpd-server.php
|
||||
##
|
||||
## Version 1.0 By:
|
||||
## All In One - Dennis de Houx <info@all-in-one.be>
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
|
||||
#### START SETTINGS ####
|
||||
|
||||
$ntpq = "/usr/sbin/ntpq";
|
||||
$ntpdc = "/usr/sbin/ntpdc";
|
||||
|
||||
#### END SETTINGS ####
|
||||
|
||||
|
||||
##
|
||||
## DO NOT EDIT BENETH THIS LINE
|
||||
##
|
||||
########################################################################################
|
||||
|
||||
$cmd = shell_exec($ntpq." -c rv");
|
||||
$cmd2 = shell_exec($ntpdc." -c iostats");
|
||||
$vars = array();
|
||||
$vars2 = array();
|
||||
$vars = explode(',', $cmd);
|
||||
$vars2 = eregi_replace(' ', '', $cmd2);
|
||||
$vars2 = explode("\n", $vars2);
|
||||
|
||||
function doSNMPv2($vars, $vars2) {
|
||||
$ntpd = array();
|
||||
foreach ($vars as $item=>$value) {
|
||||
if (!empty($value)) {
|
||||
$temp = explode('=', $value);
|
||||
if (isset($temp[1])) {
|
||||
$ntpd[trim($temp[0])] = trim($temp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($vars2 as $item=>$value) {
|
||||
if (!empty($value)) {
|
||||
$temp = explode(':', $value);
|
||||
if (isset($temp[1])) {
|
||||
$ntpd[trim($temp[0])] = trim($temp[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$var['stratum'] = (isset($ntpd['stratum']) ? $ntpd['stratum'] : "U");
|
||||
$var['offset'] = (isset($ntpd['offset']) ? $ntpd['offset'] : "U");
|
||||
$var['frequency'] = (isset($ntpd['frequency']) ? $ntpd['frequency'] : "U");
|
||||
$var['jitter'] = (isset($ntpd['jitter']) ? $ntpd['jitter'] : "U");
|
||||
$var['noise'] = (isset($ntpd['noise']) ? $ntpd['noise'] : "U");
|
||||
$var['stability'] = (isset($ntpd['stability']) ? $ntpd['stability'] : "U");
|
||||
$var['uptime'] = (isset($ntpd['timesincereset']) ? $ntpd['timesincereset'] : "U");
|
||||
$var['buffer_recv'] = (isset($ntpd['receivebuffers']) ? $ntpd['receivebuffers'] : "U");
|
||||
$var['buffer_free'] = (isset($ntpd['freereceivebuffers']) ? $ntpd['freereceivebuffers'] : "U");
|
||||
$var['buffer_used'] = (isset($ntpd['usedreceivebuffers']) ? $ntpd['usedreceivebuffers'] : "U");
|
||||
$var['packets_drop'] = (isset($ntpd['droppedpackets']) ? $ntpd['droppedpackets'] : "U");
|
||||
$var['packets_ignore'] = (isset($ntpd['ignoredpackets']) ? $ntpd['ignoredpackets'] : "U");
|
||||
$var['packets_recv'] = (isset($ntpd['receivedpackets']) ? $ntpd['receivedpackets'] : "U");
|
||||
$var['packets_sent'] = (isset($ntpd['packetssent']) ? $ntpd['packetssent'] : "U");
|
||||
foreach ($var as $item=>$count) {
|
||||
echo $count."\n";
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($vars2);
|
||||
|
||||
doSNMPv2($vars, $vars2);
|
||||
|
||||
?>
|
Reference in New Issue
Block a user