Windows
banshee/windows-collection/windows/snmp/
clock
The offset of the clock of a Windows from a time server, by SNMP and NTP
by banshee1 installation2 versions
// The offset of a Windows clock from a time server: the system time, hrSystemDate
// (HOST-RESOURCES-MIB), read by SNMP, compared with the time of the server named by "Time server"
// (pool.ntp.org when unset). Positive, the clock is ahead; negative, it is behind.
// The server's time is brought back to the middle of the SNMP read: neither the SNMP round trip,
// nor the time between the two reads, nor the error of the poller's own clock counts in the offset.
// hrSystemDate is precise to a tenth of a second only. An agent that serves it without its offset
// from UTC does not say which instant it is: the collector then stops, rather than guess.
need('protocol:snmp');
need('protocol:ntp');
output('offset', 'number', array('label' => 'Offset from the time server', 'unit' => 's'));
output('drift', 'number', array('label' => 'Offset, without its sign', 'unit' => 's'));
watch.above('clock-drift', 'Clock off', 'drift', array('warning' => 5, 'critical' => 60));
$asked = time.now();
$date = snmp.date('1.3.6.1.2.1.25.1.2.0');
$answered = time.now();
$server = ntp.time(errors=$err);
$now = time.now();
if ($err['code'] != '') {
fail('unreachable', 'Time server unreachable', $err['text']);
}
// The server's time at the middle of the SNMP read: its time, minus the time elapsed since,
// measured by the poller's clock.
$reference = $server - ($now - ($asked + $answered) / 2);
$offset = $date - $reference;
$drift = $offset;
if ($drift < 0) {
$drift = -$drift;
}
value('offset', number.round($offset, 1));
value('drift', number.round($drift, 1));