Skip to content

Fix ntpdig.py #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix ntpdig.py #8

wants to merge 2 commits into from

Conversation

alevesely
Copy link

The most important change is sorting by offset. This provides greater stability to those who run the client from cron. I used to see logs like this:

Sep  8 00:00:02 14 north cron_sntp: Time offset= +0.022322; +/- 0.006090 pool.ntp.org 80.88.90.14 s2 no-leap
Sep  8 00:30:01 14 north cron_sntp: Time offset= +0.023896; +/- 0.013601 pool.ntp.org 85.199.214.99 s1 no-leap
Sep  8 01:00:02 14 north cron_sntp: Time offset= +0.023296; +/- 0.006103 pool.ntp.org 80.88.90.14 s2 no-leap
Sep  8 01:30:09 10 north cron_sntp: CLOCK: time stepped by 2.528809, rtc=0
Sep  8 01:30:09 10 north cron_sntp: Time offset= +2.528809; +/- 2.503697 pool.ntp.org 185.19.184.35 s2 no-leap
Sep  8 02:00:06 14 north cron_sntp: Time offset= +0.029088; +/- 2.508656 pool.ntp.org 185.157.229.254 s2 no-leap
Sep  8 02:29:59 10 north cron_sntp: CLOCK: time stepped by -2.484406, rtc=0
Sep  8 02:29:59 10 north cron_sntp: Time offset= -2.484406; +/- 0.001504 pool.ntp.org 162.159.200.123 s3 no-leap
Sep  8 03:00:03 14 north cron_sntp: Time offset= +0.020611; +/- 0.013354 pool.ntp.org 93.94.88.51 s3 no-leap
Sep  8 03:30:02 14 north cron_sntp: Time offset= +0.027958; +/- 0.001613 pool.ntp.org 162.159.200.1 s3 no-leap

The new sorting gives less importance to the stratum and almost none to the distance. In addition, option -M can be given even without -S, so that I now have logs like so:

Sep 13 23:30:07 14 north cron_sntp: Time offset= +0.019521; +/- 0.007942 pool.ntp.org 162.159.200.123 s3 no-leap
Sep 14 00:00:07 14 north cron_sntp: Time offset= +0.027320; +/- 0.001725 pool.ntp.org 185.19.184.35 s2 no-leap
Sep 14 00:30:13 10 north cron_sntp: Time offset= +3.520828; +/- 3.504331 pool.ntp.org 162.159.200.123 s3 no-leap
Sep 14 00:30:13 10 north cron_sntp: ntpdig: Adjustment of 3520.828485ms not done (step limit = 256.000000ms)
Sep 14 01:00:08 14 north cron_sntp: Time offset= +0.037637; +/- 0.001469 pool.ntp.org 162.159.200.1 s3 no-leap
Sep 14 01:30:12 10 north cron_sntp: Time offset= +3.524691; +/- 3.515389 pool.ntp.org 93.94.88.50 s2 no-leap
Sep 14 01:30:12 10 north cron_sntp: ntpdig: Adjustment of 3524.691105ms not done (step limit = 256.000000ms)
Sep 14 02:00:08 14 north cron_sntp: Time offset= +0.041852; +/- 0.012898 pool.ntp.org 93.94.88.50 s2 no-leap
Sep 14 02:30:07 14 north cron_sntp: Time offset= +0.016553; +/- 0.001517 pool.ntp.org 162.159.200.123 s3 no-leap
Sep 14 03:00:08 14 north cron_sntp: Time offset= +0.025660; +/- 0.006478 pool.ntp.org 185.157.229.254 s2 no-leap

Besides, this pull request includes a number of minor fixes:

  • Using concurrent hosts now works as intended, collecting replies after all queries,
  • querying localhost only if neither argument nor concurrent hosts given,
  • default gap is 2 seconds, as the man page says,
  • debug level 2 for sleeping, dumps moved to level 3,
  • use sender address and server name in read_append() (only affects debug output),
  • display all replies at debug level 1, and
  • steplimit displayed in help and accepting decimals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant