I had the joy earlier today of having to rewrite a Scout plugin that reports NTP status on a Debian box. The problem was that the plugin depended on the output of ntpstat, and that program isn’t available on Debian or Ubuntu. I didn’t feel that repackaging ntpstat for Debian was the right way to go, so I dug around in ntpq and ntpdc trying to get the same info.
Unfortunately, the on- and off-line documentation for these programs sucks. It took me forever, but I finally figured out how to get that same information that ntpstat gives you from ntpq. It’s not that it was that hard, just that it took a while to discern what output meant what.
The output of ntpstat looks like this (borrowed from http://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/):
synchronised to NTP server (126.96.36.199) at stratum 3 time correct to within 42 ms polling server every 1024 s
While the output from ntpq -p looks like:
remote refid st t when poll reach delay offset jitter ============================================================================== +ntp2.ResComp.Be 188.8.131.52 2 u 779 1024 377 20.535 0.431 7.072 *pool-test.ntp.o 184.108.40.206 2 u 1039 1024 377 16.482 -0.400 3.094 +ntp1.linuxhoste 220.127.116.11 2 u 778 1024 377 30.393 0.720 4.114 -stratum-2-core- 18.104.22.168 2 u 915 1024 377 104.704 -17.882 20.483
The line with the asterisk at the beginning is the one you want. it’s telling you that your server is synced to 22.214.171.124, correct to within 0.4 milliseconds, and it repolls every 1024 seconds. It took me way too long to figure out which program and which set of options would tell me this, so if I can ease anyone else’s pain in the future I will have succeeded.comments powered by Disqus