summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53438c5)
raw | patch | inline | side by side (parent: 53438c5)
author | Florian Forster <octo@collectd.org> | |
Mon, 30 Nov 2015 19:02:23 +0000 (20:02 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 30 Nov 2015 19:02:58 +0000 (20:02 +0100) |
Also add note about STA_NANO.
Issue: #1314.
Issue: #1314.
src/ntpd.c | patch | blob | history |
diff --git a/src/ntpd.c b/src/ntpd.c
index 8e00734c77e7986c9b29aac0d0f500f4ea8c656e..f192a826847b6530d30166f9f2a01a4bc672c5db 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
return (0);
}
-static void ntpd_submit (char *type, char *type_inst, double value)
+static void ntpd_submit (char *type, char *type_inst, gauge_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
* sets the LSB based on whether the peer was reachable. If the LSB is zero,
* the values are out of date. */
static void ntpd_submit_reach (char *type, char *type_inst, uint8_t reach,
- double value)
+ gauge_t value)
{
if (!(reach & 1))
value = NAN;
int ps_num;
int ps_size;
+ gauge_t offset_loop;
+ gauge_t freq_loop;
+ gauge_t offset_error;
+
int status;
int i;
- double tscale = 1e-6;
+
+ /* On Linux, if the STA_NANO bit is set in ik->status, then ik->offset
+ * is is nanoseconds, otherwise it's microseconds.
+ * TODO(octo): STA_NANO is defined in the Linux specific <sys/timex.h> header. */
+ double scale_loop = 1e-6;
+ double scale_error = 1e-6;
ik = NULL;
ik_num = 0;
}
/* kerninfo -> estimated error */
+ offset_loop = scale_loop * ((gauge_t) ntohl (ik->offset));
+ freq_loop = ntpd_read_fp (ik->freq);
+ offset_error = scale_error * ((gauge_t) ntohl (ik->esterror));
DEBUG ("info_kernel:\n"
- " pll offset = %.8f\n"
- " pll frequency = %.8f\n" /* drift compensation */
- " est error = %.8f\n",
- (int32_t)ntohl(ik->offset) * tscale,
- ntpd_read_fp (ik->freq),
- (u_long)ntohl(ik->esterror) * 1e-6);
-
- ntpd_submit ("frequency_offset", "loop", ntpd_read_fp (ik->freq));
- ntpd_submit ("time_offset", "loop", (int32_t)ntohl(ik->offset) * tscale);
- ntpd_submit ("time_offset", "error", (u_long)ntohl(ik->esterror) * 1e-6);
+ " pll offset = %.8g\n"
+ " pll frequency = %.8g\n" /* drift compensation */
+ " est error = %.8g\n",
+ offset_loop, freq_loop, offset_error);
+
+ ntpd_submit ("frequency_offset", "loop", freq_loop);
+ ntpd_submit ("time_offset", "loop", offset_loop);
+ ntpd_submit ("time_offset", "error", offset_error);
free (ik);
ik = NULL;