Main Menu

Search

Showing posts with label ntp settings. Show all posts
Showing posts with label ntp settings. Show all posts

LINUX: How To Check NTP Synchronization and Troubleshoot any issues with NTP? ("ntpq" command)

Following command can be used to check NTP synchronization and check and troubleshoot NTP issues.
ntpq -pn

For more accurate analysis of NTP synchronization, it is best to run above command in loop for 3 times and check the output. Below is command to run above command in loop for 3 times. Command can be modified based on how many times you want to run it in loop. Just change value 3 in below command to the number you want to run in loop.

for i in {1..3};  do echo $i && ntpq -pn  && echo "=============================" ; done

Below is example output of above command.


      remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+10.10.10.1    10.30.30.1      4 u  861 1024  377    1.323  -2.567   0.526
-10.10.10.2    10.30.30.3      4 u  902 1024  377    0.528   -3.709   0.046
+10.10.10.3    10.30.30.2     4 u  159 1024  377    1.279   -2.304   0.109
*10.10.10.4    10.30.30.1      4 u 1046 1024  377    0.350   -1.573   0.005

Important things to check in this output are reach, delay, offset and jitter. Below are details.


  • reach - value should be 377. contains the results of the most recent eight NTP updates.  If all eight are successful, this field will read 377. This number is in octal, so eight successes in octal will be represented by 377
  • delay - value should be lower which means there is minimal delay in communication between local machine and NTP server. Value is in milliseconds.
  • offset - time difference between local machine and NTP server. Lower the value, healthy is NTP. Value is in milliseconds.
  • jitter - Amount of variance in time between local machine and NTP server. Lower the value, healthy is NTP. Value is in milliseconds.

Products to which Article Applies


All Linux environments


Additional References

http://www.ntp.org/ntpfaq/NTP-s-trouble.htm#Q-MON-REACH
https://www.streetdirectory.com/travel_guide/126336/computers/common_ntp_server_terminology_explained.html


LINUX: How to Check if NTP Service Is Running in Linux? ("ntpd" command)

To Verify is NTP service is running on Linux machine, below command can be executed to check if ntpd service is running.
service ntpd status

If NTP daemon is running you should see output as follows:


ntpd (pid  <PID>b) is running...


Products to which Article Applies


All Linux environments

Additional References

https://www.thegeekdiary.com/linux-os-service-ntpd/

LINUX: How To Check NTP Status on Linux Machine? ("ntpstat" command)

Below "ntpstat" command can be used to check NTP status on Linux Machine.

ntpstat;echo $?

Below is sample output of above command.



# ntpstat;echo $?
synchronised to NTP server (192.168.20.1) at stratum 5
   time correct to within 132 ms
   polling server every 1024 s
0

From above command will report the synchronisation state of the NTP daemon running on the local machine. As seen from above output it is synchronized.


"echo $?" command will show the exit status of ntpstat command. Below are 3 exit status we can see.

  • exit status 0 – Clock is synchronised.
  • exit status 1 – Clock is not synchronised.
  • exit status 2 – If clock state is indeterminant, for example if ntpd is not contactable.

In the example shown above exit status is 0 as the clock is synchronized.

Products to which Article Applies


All Linux environments

Additional References

https://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/


LINUX: How To Check NTP Settings (NTP Servers Being Used, Poll, Delay, Offset, Jitter) on Linux Host? (How To Doc) ("ntpq" command)

Below command can be used to check NTP Settings on Linux host.

ntpq -p

Below is sample output of above command.

     remote           refid      st t when poll reach   delay   offset  jitter
=============================================================
ntpserver1.com    10.30.30.1      4 u  536 1024  377    7.470   -0.414   5.884
*ntpserver2.com   10.30.30.2      4 u  477 1024  377    6.701    4.599   5.964
ntpserver3.com   10.30.30.2      4 u  477 1024  377    6.701    4.599   5.964

From above output below is short description of each



  • remote -remote NTP servers from which time is retrieved.

    The line with * highlighted in bold is the NTP server in use.
  • refid - The IP under the refid is the IP from which the ntpserver is retrieving the time.
  • st - server’s stratum which shows how close the NTP server. Lower the number, the closer NTP server is.
  • t - refers to the type, specifically whether the server is using unicast (u), broadcast (b), multicast (m), or manycast.
  • when -  how long ago it was since the last time the server was polled
  • poll - how often the server will be polled
  • reach - contains the results of the most recent eight NTP updates.  If all eight are successful, this field will read 377. This number is in octal, so eight successes in octal will be represented by 377
  • delay  - delay in reaching the server
  • offset - difference between the local clock and the server’s clock
  • jitter - network latency between local server and NTP servers.

Products to which Article Applies


All Linux environments

Additional References


https://www.thegeekdiary.com/what-is-the-refid-in-ntpq-p-output/