From: Johan Kiviniemi Date: Thu, 4 Oct 2012 17:56:34 +0000 (+0300) Subject: src/ntpd.c: Add unit number to refclock name X-Git-Tag: collectd-5.2.0~46 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f2696c0e21e9226d3911457250ef64138900aa2b;p=collectd.git src/ntpd.c: Add unit number to refclock name There can be multiple instances of the same refclock with different unit numbers. The unit number needs to be a part of the peer name, otherwise the code will try to write the measurements from multiple peers to the same RRD file. --- diff --git a/src/ntpd.c b/src/ntpd.c index 8bbf74d7..15e60a5d 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -857,8 +857,11 @@ static int ntpd_read (void) if (refclock_id < refclock_names_num) { - sstrncpy (peername, refclock_names[refclock_id], - sizeof (peername)); + /* The unit number is in the lowest byte. */ + ssnprintf (peername, sizeof (peername), + "%s%i", + refclock_names[refclock_id], + ntohl (ptr->srcadr) & 0xFF); } else {