Examples
banshee/examples-collection/examples/protocols/
ntp-time
Example: ntp.time and time.now; a time server against the poller's clock.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
// ntp.time: ask a time server for its time, in seconds since 1 January 1970 UTC, to the millisecond.
// It asks the server of "Time server", never the host itself; time.now gives the poller's own time.
// The collector watches a time server: it answers, and its time agrees with the poller's clock.
need('protocol:ntp');
output('drift', 'number', array('label' => 'Offset from the poller clock', 'unit' => 's'));
watch.above('clock-off', 'Time server off', 'drift', array('warning' => 1, 'critical' => 10));
// The server's time is the one at the arrival of its answer: it compares with the poller's time just after.
$server = ntp.time();
$offset = $server - time.now();
if ($offset < 0) {
$offset = -$offset;
}
value('drift', number.round($offset, 3));