Examples
banshee/examples-collection/examples/protocols/
snmp-date
Example: snmp.date, a DateAndTime brought back to UTC; the clock of a device.
by banshee1 installation1 version
Published on October 27, 2026. First version in this collection.
// snmp.date: read an OID that holds a date (DateAndTime), brought back to UTC, in seconds since
// 1 January 1970. A date without its offset from UTC stops the collector rather than guess it.
// The collector compares the clock of a device with the clock of the poller.
need('protocol:snmp');
output('drift', 'number', array('label' => 'Offset from the poller clock', 'unit' => 's'));
watch.above('clock-off', 'Clock off', 'drift', array('warning' => 5, 'critical' => 60));
// hrSystemDate (HOST-RESOURCES-MIB): the date of the device.
$date = snmp.date('1.3.6.1.2.1.25.1.2.0');
$offset = $date - time.now();
// The minus before a value turns its sign: the offset, without its sign.
if ($offset < 0) {
$offset = -$offset;
}
value('drift', number.round($offset, 1));