Server Clock Drift (Perl)

The template allows you to check server clock drift by comparing the target server time with internet time.

Prerequisites: Perl must be installed on the target server. Ntp package should be installed on the target server.
Credentials: Root on the target server.

Component Monitors

Clock Drift (Internet Time Service)

This monitor shows the clock drift between the target client (target node) and the target Internet Time Service server (argument) in seconds. Positive values of clock drift in the message field indicates that time on the target server is running faster than it should. Negative values indicates time on the target server is running slower than it should. This monitor also returns the current time on the target server. 

In the Scripts Arguments field you should provide the hostname of the time server. Time servers can be found here: http://tf.nist.gov/tf-cgi/servers.cgi.

Following is an example of how to use the Scripts Arguments field:

perl ${SCRIPT} time.nist.gov

Clock Drift (NTP)

This monitor shows the clock drift between the target client (target node) and the target NTP server (argument) in seconds. Positive values of clock drift in the message field indicates that time on the target server is running faster than it should. Negative values indicates time on the target server is running slower than it should. This monitor also returns the current time on the target server. 

In the Scripts Arguments field you should provide full path to ntpdate (ntp package should be installed on the target server) command and hostname of the NTP server. Time servers can be found here: http://www.pool.ntp.org/.

Following is an example of how to use the Scripts Arguments field:

perl ${SCRIPT} /sbin/ntpdate pool.ntp.org

Last updated: 2/5/2016

  • Can this script use more then one target NTP server (argument) as backup? To explain, we are using internal NTP server which is hardware device and couple days ago it went dead. We had to manually repoint our servers to different NTP server (time.nist.gov) and once device was fixed repoint them again to internal NTP server. 

  • Correct. Positive values of clock drift in the message field indicates that time on the target server is running faster than it should. Negative values indicates time on the target server is running slower than it should.

  • or perhaps either of you could help me when it comes to this script. Do either of you know why i get a different offset output for the ntpq -p and ntpq -c commands?

    [svcorion@ascntp ~]$ ntpq -p

         remote           refid      st t when poll reach   delay   offset  jitter

    ==============================================================================

    +time.apple.com  17.168.198.148   2 u  119 1024  377   28.333   -2.252   1.411

    +isis.johnwparke 132.239.1.6      2 u  68m 1024  370   14.765    2.041   1.730

    -sisdb01.muskego 129.6.15.28      2 u  521 1024  377   35.131    6.119   8.335

    *tick.usno.navy. .IRIG.           1 u  847 1024  377   23.762   1.660   0.596

    [svcorion@ascntp ~]$ ntpq -c rv

    associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,

    version="ntpd 4.2.6p5@1.2349-o Fri Apr 27 08:36:47 UTC 2012 (1)",

    processor="x86_64", system="Linux/3.8.12-100.fc17.x86_64", leap=00,

    stratum=2, precision=-24, rootdelay=23.762, rootdisp=43.137,

    refid=192.5.41.40,

    reftime=d5586be1.a9096ee8  Tue, Jun  4 2013  9:36:33.660,

    clock=d5586f44.7dcf32ba  Tue, Jun  4 2013  9:51:00.491, peer=39486,

    tc=10, mintc=3, offset=1.549, frequency=9.171, sys_jitter=2.574,

    clk_jitter=0.952, clk_wander=0.070

  • So i ran it like this, where 10.66.1.5 is the NTP time server.

    ny4prdsrv-span2 ~]$ perl TD_1.pl 10.66.1.5

    Statistic.1: 4789

    Statistic.2: 0

    Statistic.3: 0

    If i run without the NTP time server, i get the following:

    ny4prdsrv-span2 ~]$ perl TD_1.pl

    Statistic.1: 0

    Statistic.2: 2996

    Statistic.3: 0

  • Also, how can I setup our internal NTP time server IP to the script? Currently, I do not see how it is providing a drift to sync with.