[ntp:questions] empty refid in ntpq output

Greg.Dowd at microchip.com Greg.Dowd at microchip.com
Thu May 2 15:05:30 UTC 2019

I have seen this myself.  IIRC, when the input for refid ID is exactly \0\0\0\0 then it is displayed as "blank" in ntpq output.  And maybe only if it is stratum 1?  Anything else gets at least a . char in the string conversion routine.  And if it is s2 or higher, I think it is parsed differently with an addr string for 4 and a hash print for 6.  NTPd is fine, this is only the string formatting code for ntpq where this is introduced.  You might be able to count fields and stuff, or used fixed length parse, or you could change that 1 piece of code around line 1707 in ntpq-subs.c
                } else if (!strcmp("refid", name)) {
                        if (   (pvl == peervarlist)
                            && (drefid == REFID_IPV4)) {
                                have_da_rid = TRUE;
                                drlen = strlen(value);
>>>>                                if (0 == drlen) {
>>>>                                        dstadr_refid = "";
                                } else if (drlen <= 4) {
                                        memcpy(&u32, value, drlen);
                                        dstadr_refid = refid_str(u32, 1);

Greg Dowd
Principal Engineering Technologist, FTD
3870 N. First St. | San Jose | CA 95134 | USA
Office: 408.964.7643
Email: greg.dowd at microchip.com
Company Website:  www.microsemi.com

-----Original Message-----
From: questions [mailto:questions-bounces+greg.dowd=microsemi.com at lists.ntp.org] On Behalf Of Daniel Nelson
Sent: Tuesday, April 30, 2019 10:43 AM
To: questions at lists.ntp.org
Subject: [ntp:questions] empty refid in ntpq output

External E-Mail

I'm working on a project that attempts to parse the output of `ntpq -p`, and have heard a report that sometimes the refid is empty.  Here is the output I'm seeing, the indention was mangled by the logging system, so I've attempted to realign things below:

remote            refid     st t when poll reach delay offset jitter
 0.ubuntu.pool.n .POOL.     16 p -      64   0  0.000   0.000 0.000
+                  16 u 1048 1024 376 15.384  -0.538 0.943

My question is, what does an empty refid indicate and are there any tips for machine parsing the output correctly given that the lines may have a differing number of columns.
questions mailing list
questions at lists.ntp.org

More information about the questions mailing list