Search This Blog

2014-02-12

Debugging NTPd

Getting an alert where ntp was out of sync?

There are a couple tools you can use to validate whether ntp is functioning normally.

First is ntpstat, which will show you which ntp server the device is currently synchronized with:
ntpstat
synchronised to NTP server (142.137.247.109) at stratum 3
   time correct to within 1945 ms
   polling server every 1024 s

In the above we can see that this server is actually in sync, but only in sync within 1945ms which is about 2 seconds. This seems a bit long to me and since we were getting an alert I decided to see if the server was actually accessible.

After a ping, it looks like I was unable to access it.

Tried manually syncging with ntpdate -q 142.137.247.109 and it was unable to perform the task
ntpdate -q 142.137.247.109
server 142.137.247.109, stratum 0, offset 0.000000, delay 0.00000
12 Feb 11:22:12 ntpdate[15082]: no server suitable for synchronization found

I restarted ntpd:
service ntpd restart

It looked like it had a new set of peers, but was still unsynchronized:
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 penguin.hopcoun 204.9.54.119     2 u   44   64    1   10.000    0.369   0.000
 ks4001083.ip-19 192.93.2.20      2 u   43   64    1   13.813    0.007   0.000
 time1.srv.ualbe .GPS.            1 u   44   64    1  147.417  -48.701   0.000

# ntpstat
unsynchronised
  time server re-starting
   polling server every 64 s

After a while though it eventually synched and everything was fine
# ntpstat
synchronised to NTP server (129.128.5.210) at stratum 2
   time correct to within 60 ms
   polling server every 256 s

In redhat you can also configure additional logging by adding the -l $dir in /etc/sysconfig/ntpd and restarting the service.

Resources: https://access.redhat.com/site/solutions/66777

No comments:

Post a Comment