network time synchronization status with ntpq

There is a handy program called


, which shows the network time synchronization status of your server under Ubuntu 16, but the older version or other linux distros do not have this program. The output of the program is:

srv@local # ntpstat
synchronised to NTP server ( at stratum 3 
   time correct to within 133 ms
   polling server every 1024 s

As you can see the time is correct within some interval of milliseconds. In other words your time in the server could be trusted only within these milliseconds! If your server is synchronized with the program ntp your time of the server will be correct within a tiny fractions of a second, closer to a time server much smaller interval of correctness. The interval is computed according to how away the server is and how much the latency of the network of the server is.
ntpstats compute the output with the formula:

rootdisp + rootdelay / 2.0

  • rootdisp – indicating the maximum error relative to the primary reference source. If your server gets the time from an external source (GPS, radio, high precise clock external device), this value is the estimated maximum error of that clock and if your server gets the time from another NTP server (in most cases), this value is the current NTP server’s root dispersion (to which your server is synced) plus the dispersion added by the network link between your server and the NTP server
  • rootdelay – indicating the total roundtrip delay to the primary reference source. Because it is a roundtrip we divide it to 2 to get the single trip delay of the network

You can get these two values with the ntpq program:

srv@local # ntpq -c "rv 0 rootdisp,rootdelay"
rootdelay=202.882, rootdisp=31.816

So the time correct to within 31.816+(202.882/2) = 133.257 ms, which is the output of ntpstat.

Leave a Reply

Your email address will not be published. Required fields are marked *