Monitor local system time of a WRS via SNMP

1. Introduction

WRS synchronises its local time with an external NTP server, if one is specified in CONFIG_NTP_SERVER configuration entry. Moreover, the synchronisation between them can be remotely monitored via SNMP. Refer to the current user manual v6.0.1 for more details.

In order to enable system clock monitoring a set of configuration entries (given below) should be set properly in /wr/etc/dot-config:

CONFIG_SNMP_SYSTEM_CLOCK_MONITOR_ENABLED
CONFIG_SNMP_SYSTEM_CLOCK_DRIFT_THOLD
CONFIG_SNMP_SYSTEM_CLOCK_UNIT_DAYS
CONFIG_SNMP_SYSTEM_CLOCK_UNIT_HOURS
CONFIG_SNMP_SYSTEM_CLOCK_UNIT_MINUTES
CONFIG_SNMP_SYSTEM_CLOCK_CHECK_INTERVAL_DAYS
CONFIG_SNMP_SYSTEM_CLOCK_CHECK_INTERVAL_HOURS
CONFIG_SNMP_SYSTEM_CLOCK_CHECK_INTERVAL_MINUTES

CONFIG_NTP_SERVER
CONFIG_WRS_LOG_SNMPD

2. Usage

User can get more details about system clock monitoring from user manual, but it provides no example. Therefore, a simple example is given here:
  • check minimal time drift (ie., 1 second) and
  • perform it regularly in 30-minute period

It's done by setting corresponding entries given below:

CONFIG_SNMP_SYSTEM_CLOCK_MONITOR_ENABLED=y       # enable comparision of local time and NTP server time
CONFIG_SNMP_SYSTEM_CLOCK_DRIFT_THOLD=1           # 1 second drift
CONFIG_SNMP_SYSTEM_CLOCK_UNIT_MINUTES=y
CONFIG_SNMP_SYSTEM_CLOCK_CHECK_INTERVAL_MINUTES=30  # comparision will be done every 30 minutes

CONFIG_NTP_SERVER=<NTP server>                   # IP address of NTP server
CONFIG_WRS_LOG_SNMPD="Swd"                       # SNMP logging is allowed to the 'warning', 'error' and 'alert' levels

If system clock monitoring is enabled, then the comparison result and status are written to certain log files in the /var/log/ directory:
  • system_clock_monitor_drift that contains '0' in normal case
  • system_clock_monitor_status that contains 'no_error' in normal case

Use following SNMP objects to obtain the monitoring status from a target WRS using SNMP:
  • wrsSystemClockStatusDetails provides comparision result between system clock and NTP time
  • wrsSystemClockStatus provides collective status of system clock

3. Examination

To validate system clock monitoring you need to have at least:
  • WRS connected to management network
  • NTP server connected to management network
  • management host with the snmpwalk utility and WR-SWITCH-MIB.txt located in your home directory

Obtain the comparision result via SNMP from a target WRS:

$ snmpwalk -c public -v 2c -Oxs -m ALL -M +$HOME <target WRS> wrsSystemClockStatusDetails

SNMP response will provide the detailed system clock status:
wrsSystemClockStatusDetails.0 = INTEGER: ok(1)                   # no error or monitoring is disabled
wrsSystemClockStatusDetails.0 = INTEGER: thresholdExceeded(2)    # system time has drifted from NTP server time
wrsSystemClockStatusDetails.0 = INTEGER: ntpError(3)             # specified NTP server is not reacheable

or some other status like na(0), error(4), ioError(5), unknownStatus(6)

Additionally, if management host receives syslog messages from WRSs, then one could check information of comparision task scheduled by crond (every 30 minutes according to above example):
$ grep system_clock_monitor /var/log/remote_wrs.log              # log file name may differ in production environment
Sep 24 10:26:00 nwt0290m66.timing crond[1957]: USER root pid 2004 cmd /etc/init.d/system_clock_monitor
Sep 24 10:56:00 nwt0290m66.timing crond[1957]: USER root pid 2045 cmd /etc/init.d/system_clock_monitor
...

Commands given below can be used to examine the monitoring feature:
ntpd -q -p <NTP server>            # synchronise with a given NTP server
date -s `expr $(date +%H%M) - 1`   # change local time, ie., to run it late by 1 second

-- EnkhboldOchirsuren - 24 Sep 2021
Topic revision: r1 - 24 Sep 2021, EnkhboldOchirsuren
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback