From 5126b0422a63de838cf6fb7cf0e7dcd9bcc658e7 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 23 Feb 2017 15:50:46 +0100 Subject: [PATCH] chrony: use time_offset type for last measured offset The last measured offset from the source report should be more useful for monitoring than the current estimated offset from the sourcestats report. --- src/chrony.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/chrony.c b/src/chrony.c index a4dd59f8..988fc3ba 100644 --- a/src/chrony.c +++ b/src/chrony.c @@ -892,6 +892,8 @@ static int chrony_request_source_data(int p_src_idx, char *src_addr, ntohs(chrony_resp.body.source_data.f_reachability)); chrony_push_data_valid("clock_last_meas", src_addr, is_reachable, ntohl(chrony_resp.body.source_data.f_since_sample)); + chrony_push_data_valid("time_offset", src_addr, is_reachable, + ntohf(chrony_resp.body.source_data.f_origin_latest_meas)); return CHRONY_RC_OK; } @@ -903,12 +905,11 @@ static int chrony_request_source_stats(int p_src_idx, const char *src_addr, size_t chrony_resp_size; tChrony_Request chrony_req; tChrony_Response chrony_resp; - double skew_ppm, frequency_error, time_offset; + double skew_ppm, frequency_error; if (*p_is_reachable == 0) { skew_ppm = 0; frequency_error = 0; - time_offset = 0; } else { chrony_init_req(&chrony_req); chrony_req.body.source_stats.f_index = htonl(p_src_idx); @@ -923,7 +924,6 @@ static int chrony_request_source_stats(int p_src_idx, const char *src_addr, skew_ppm = ntohf(chrony_resp.body.source_stats.f_skew_ppm); frequency_error = ntohf(chrony_resp.body.source_stats.f_rtc_gain_rate_ppm); - time_offset = ntohf(chrony_resp.body.source_stats.f_est_offset); DEBUG(PLUGIN_NAME ": Source[%d] stat: .addr = %s, .ref_id= %u, .n_samples = %u, " @@ -935,7 +935,8 @@ static int chrony_request_source_stats(int p_src_idx, const char *src_addr, ntohl(chrony_resp.body.source_stats.f_n_runs), ntohl(chrony_resp.body.source_stats.f_span_seconds), ntohf(chrony_resp.body.source_stats.f_rtc_seconds_fast), - frequency_error, skew_ppm, time_offset, + frequency_error, skew_ppm, + ntohf(chrony_resp.body.source_stats.f_est_offset), ntohf(chrony_resp.body.source_stats.f_est_offset_err)); } /* if (*is_reachable) */ @@ -944,8 +945,6 @@ static int chrony_request_source_stats(int p_src_idx, const char *src_addr, chrony_push_data_valid("clock_skew_ppm", src_addr, *p_is_reachable, skew_ppm); chrony_push_data_valid("frequency_error", src_addr, *p_is_reachable, frequency_error); /* unit: ppm */ - chrony_push_data_valid("time_offset", src_addr, *p_is_reachable, - time_offset); /* unit: s */ return CHRONY_RC_OK; } -- 2.11.0