[collectd] ntp-plugin: wrong use of refclock_id in ntpd_read

Wolfgang Walter wolfgang.walter at stusta.mhn.de
Sun Jan 6 06:03:51 CET 2013


Hello,

ntpd_read() (in  src / ntpd.c) sets

	refclock_id = ntpd_get_refclock_id (ptr);

and then uses it to decide if the time source is a reference clock:


                 if (refclock_id != 1) /* not the system clock (offset will always be zero.. */
                         ntpd_submit_reach ("time_offset", peername, ptr->reach,
                                         offset);
                 ntpd_submit_reach ("time_dispersion", peername, ptr->reach,
                                 ntpd_read_fp (ptr->dispersion));
                 if (refclock_id == 0) /* not a reference clock */
                         ntpd_submit_reach ("delay", peername, ptr->reach,
                                         ntpd_read_fp (ptr->delay));


this seems to be wrong, as ntpd_get_refclock_id() is meaningless if it is a real peer.
Symptom is that ipv4 peers a.b.c.d with c != 0 will not appear in "delay" and ipv4 peers
a.b.c.d with c == 1 will be missing.


Probably there should be a function

static int ntpd_is_refclock(struct info_peer_summary const *peer_info)
{
	uint32_t addr = ntohl (peer_info->srcadr);
	return !peer_info->v6_flag && ((addr & REFCLOCK_MASK) == REFCLOCK_ADDR);
}

and ntpd_read() should be changed to:

                if (ntpd_is_refclock(ptr) && refclock_id != 1)  /* not the system clock (offset will always be zero.. */
                         ntpd_submit_reach ("time_offset", peername, ptr->reach,
                                         offset);
                 ntpd_submit_reach ("time_dispersion", peername, ptr->reach,
                                 ntpd_read_fp (ptr->dispersion));
                 if (! ntpd_is_refclock(ptr)) /* not a reference clock */
                         ntpd_submit_reach ("delay", peername, ptr->reach,
                                         ntpd_read_fp (ptr->delay));
			

Regards,

Wolfgang Walter



More information about the collectd mailing list