From 5c571bbbe7ca3f36d34a6b18c2d9b9b67d67ffa0 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 22 Aug 2017 15:36:43 +0200 Subject: [PATCH] reference: add new fields to tracking log Add the root delay, root dispersion and maximum estimated error in the interval since the previous update to the tracking log. --- doc/chrony.conf.adoc | 35 ++++++++++++++++++++++------------- reference.c | 26 ++++++++++++++++++-------- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 7b2ee75..3003637 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -1690,33 +1690,42 @@ actually appears as a single line in the file) from the log file is shown below. + ---- -2015-02-23 05:40:50 203.0.113.15 3 340.529 1.606 1.046e-03 N \ - 4 6.849e-03 -4.670e-04 +2017-08-22 13:22:36 203.0.113.15 2 -3.541 0.075 -8.621e-06 N \ + 2 2.940e-03 -2.084e-04 1.534e-02 3.472e-04 8.304e-03 ---- + The columns are as follows (the quantities in square brackets are the values from the example line above) : + -. Date [2015-02-03] +. Date [2017-08-22] . Hour:Minute:Second. Note that the date-time pair is expressed in UTC, not the - local time zone. [05:40:50] + local time zone. [13:22:36] . The IP address of the server or peer to which the local system is synchronised. [203.0.113.15] -. The stratum of the local system. [3] +. The stratum of the local system. [2] . The local system frequency (in ppm, positive means the local system runs fast - of UTC). [340.529] -. The error bounds on the frequency (in ppm). [1.606] -. The estimated local offset at the epoch (which is rapidly corrected by - slewing the local clock. (In seconds, positive indicates the local system - is fast of UTC). [1.046e-3] + of UTC). [-3.541] +. The error bounds on the frequency (in ppm). [0.075] +. The estimated local offset at the epoch, which is normally corrected by + slewing the local clock (in seconds, positive indicates the clock is fast of + UTC). [-8.621e-06] . Leap status (_N_ means normal, _+_ means that the last minute of this month has 61 seconds, _-_ means that the last minute of the month has 59 seconds, _?_ means the clock is not currently synchronised.) [N] -. The number of combined sources. [4] +. The number of combined sources. [2] . The estimated standard deviation of the combined offset (in seconds). - [6.849e-03] + [2.940e-03] . The remaining offset correction from the previous update (in seconds, - positive means the system clock is slow of UTC). [-4.670e-04] + positive means the system clock is slow of UTC). [-2.084e-04] +. The total of the network path delays to the reference clock to which + the local clock is ultimately synchronised (in seconds). [1.534e-02] +. The total dispersion accumulated through all the servers back to the + reference clock to which the local clock is ultimately synchronised + (in seconds). [3.472e-04] +. The maximum estimated error of the system clock in the interval since the + previous update (in seconds). It includes the offset, remaining offset + correction, root delay, and dispersion from the previous update with the + dispersion which accumulated in the interval. [8.304e-03] + *rtc*::: This option logs information about the system's real-time clock. An example diff --git a/reference.c b/reference.c index c0d1277..520ff28 100644 --- a/reference.c +++ b/reference.c @@ -226,7 +226,7 @@ REF_Initialise(void) } logfileid = CNF_GetLogTracking() ? LOG_FileOpen("tracking", - " Date (UTC) Time IP Address St Freq ppm Skew ppm Offset L Co Offset sd Rem. corr.") + " Date (UTC) Time IP Address St Freq ppm Skew ppm Offset L Co Offset sd Rem. corr. Root delay Root disp. Max. error") : -1; max_update_skew = fabs(CNF_GetMaxUpdateSkew()) * 1.0e-6; @@ -837,21 +837,28 @@ get_root_dispersion(struct timespec *ts) static void write_log(struct timespec *now, int combined_sources, double freq, - double offset, double offset_sd, double uncorrected_offset) + double offset, double offset_sd, double uncorrected_offset, + double orig_root_distance) { const char leap_codes[4] = {'N', '+', '-', '?'}; + double root_dispersion, max_error; + static double last_sys_offset = 0.0; if (logfileid == -1) return; + max_error = orig_root_distance + fabs(last_sys_offset); + root_dispersion = get_root_dispersion(now); + last_sys_offset = offset - uncorrected_offset; + LOG_FileWrite(logfileid, - "%s %-15s %2d %10.3f %10.3f %10.3e %1c %2d %10.3e %10.3e", + "%s %-15s %2d %10.3f %10.3f %10.3e %1c %2d %10.3e %10.3e %10.3e %10.3e %10.3e", UTI_TimeToLogForm(now->tv_sec), our_ref_ip.family != IPADDR_UNSPEC ? UTI_IPToString(&our_ref_ip) : UTI_RefidToString(our_ref_id), our_stratum, freq, 1.0e6 * our_skew, offset, leap_codes[our_leap_status], combined_sources, offset_sd, - uncorrected_offset); + uncorrected_offset, our_root_delay, root_dispersion, max_error); } /* ================================================== */ @@ -935,8 +942,7 @@ REF_SetReference(int stratum, double our_frequency; double abs_freq_ppm; double update_interval; - double elapsed; - double correction_rate; + double elapsed, correction_rate, orig_root_distance; double uncorrected_offset, accumulate_offset, step_offset; struct timespec now, raw_now; NTP_int64 ref_fuzz; @@ -963,6 +969,8 @@ REF_SetReference(int stratum, if (!is_offset_ok(our_offset)) return; + orig_root_distance = our_root_delay / 2.0 + get_root_dispersion(&now); + are_we_synchronised = leap != LEAP_Unsynchronised ? 1 : 0; our_stratum = stratum + 1; our_ref_id = ref_id; @@ -1073,7 +1081,8 @@ REF_SetReference(int stratum, abs_freq_ppm = LCL_ReadAbsoluteFrequency(); - write_log(&now, combined_sources, abs_freq_ppm, our_offset, offset_sd, uncorrected_offset); + write_log(&now, combined_sources, abs_freq_ppm, our_offset, offset_sd, + uncorrected_offset, orig_root_distance); if (drift_file) { /* Update drift file at most once per hour */ @@ -1154,7 +1163,8 @@ REF_SetUnsynchronised(void) LCL_SetSyncStatus(0, 0.0, 0.0); - write_log(&now, 0, LCL_ReadAbsoluteFrequency(), 0.0, 0.0, uncorrected_offset); + write_log(&now, 0, LCL_ReadAbsoluteFrequency(), 0.0, 0.0, uncorrected_offset, + our_root_delay / 2.0 + get_root_dispersion(&now)); } /* ================================================== */