[ntp:questions] NTPQ -P shows both IP and DNS name (parsing problem)

Dan Geist dan at polter.net
Wed Jun 21 12:55:15 UTC 2017

----- On Jun 21, 2017, at 7:49 AM, roman mescheryakov roman.mescheryakov at gmail.com wrote:

> вторник, 20 июня 2017 г., 19:38:53 UTC+3 пользователь David Woolley написал:
>> I think you are expected to use the relevant management request
>> directly, rather than parse output intended for humans.  That would
>> avoid process startup, filtering, and DNS costs.
> What does it mean to “use the relevant management request directly”? I’m new to
> NTP and Linux and this phrase is not clear to me. If it makes any difference,
> my program is written on Python and running under Raspbian OS.

I believe David is suggesting looking at the raw statistics for the ntpd application (usually found in /var/log/ntpstats and enabled in ntp.conf) if you're going to have a program doing something useful with it. The ntpq application is really meant more for "human" consumption and makes assumptions about things and have a high overhead that may not be right for you.

Here's a sample of my peerstats log:

root at catl1w66dgeist:/var/log/ntpstats# tail -f /var/log/ntpstats/peerstats
57925 45005.219 2001:XXXX:15:1109::10 141a 0.000005074 0.001475794 0.015326216 0.000123019
57925 45065.271 2001:XXXX:2:1109::11 133a -0.000035581 0.053438858 0.019286290 0.000082599
57925 45203.271 184.XXX.140.10 1424 -0.000008371 0.053683156 0.015259027 0.000232662
57925 45273.271 2001:XXXX:2:1109::10 1324 0.000186344 0.053677174 0.019365864 0.000155594

You can get all the useful raw data and present/use it however you like. Here's a good reference to the available monitoring statistics:


Dan Geist dan(@)polter.net

More information about the questions mailing list