From: Miroslav Lichvar Date: Mon, 30 Jan 2017 08:22:51 +0000 (+0100) Subject: conf: add rawmeasurements log option X-Git-Tag: 3.1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a0aff14d8b2ba0bbf328c1fbaddcbbededf91ae;p=thirdparty%2Fchrony.git conf: add rawmeasurements log option While the measurements log can be useful for debugging problems in NTP configuration (e.g. authentication failures with symmetric keys), it seems most users are interested only in valid measurements (e.g. for producing graphs) and don't expect/handle entries where some of the RFC 5905 tests 1-7 failed. Modify the measurements log option to log only valid measurements, and for debugging purposes add a new rawmeasurements option. --- diff --git a/conf.c b/conf.c index 5904b911..9aa034c8 100644 --- a/conf.c +++ b/conf.c @@ -97,6 +97,7 @@ static double combine_limit = 3.0; static int cmd_port = DEFAULT_CANDM_PORT; +static int raw_measurements = 0; static int do_log_measurements = 0; static int do_log_statistics = 0; static int do_log_tracking = 0; @@ -814,7 +815,10 @@ parse_log(char *line) log_name = line; line = CPS_SplitWord(line); if (*log_name) { - if (!strcmp(log_name, "measurements")) { + if (!strcmp(log_name, "rawmeasurements")) { + do_log_measurements = 1; + raw_measurements = 1; + } else if (!strcmp(log_name, "measurements")) { do_log_measurements = 1; } else if (!strcmp(log_name, "statistics")) { do_log_statistics = 1; @@ -1468,8 +1472,9 @@ CNF_GetDumpDir(void) /* ================================================== */ int -CNF_GetLogMeasurements(void) +CNF_GetLogMeasurements(int *raw) { + *raw = raw_measurements; return do_log_measurements; } diff --git a/conf.h b/conf.h index 22e65429..7ff1dba0 100644 --- a/conf.h +++ b/conf.h @@ -52,7 +52,7 @@ extern char *CNF_GetDriftFile(void); extern char *CNF_GetLogDir(void); extern char *CNF_GetDumpDir(void); extern int CNF_GetLogBanner(void); -extern int CNF_GetLogMeasurements(void); +extern int CNF_GetLogMeasurements(int *raw); extern int CNF_GetLogStatistics(void); extern int CNF_GetLogTracking(void); extern int CNF_GetLogRtc(void); diff --git a/doc/chrony.conf.adoc b/doc/chrony.conf.adoc index 793e222c..7a3bedb5 100644 --- a/doc/chrony.conf.adoc +++ b/doc/chrony.conf.adoc @@ -1518,10 +1518,12 @@ The log files are written to the directory specified by the <> directive. A banner is periodically written to the files to indicate the meanings of the columns. + -*measurements*::: +*rawmeasurements*::: This option logs the raw NTP measurements and related information to a file -called _measurements.log_. An example line (which actually appears as a single -line in the file) from the log file is shown below. +called _measurements.log_. An entry is made for each packet received from the +source. This can be useful when debugging a problem. An example line (which +actually appears as a single line in the file) from the log file is shown +below. + ---- 2016-11-09 05:40:50 203.0.113.15 N 2 111 111 1111 10 10 1.0 \ @@ -1563,6 +1565,12 @@ from the example line above): . Source of the local receive timestamp (_D_=daemon, _K_=kernel, _H_=hardware). [K] + +*measurements*::: +This option is identical to the *rawmeasurements* option, except it logs only +valid measurements from synchronised sources, i.e. measurements which passed +the RFC 5905 tests 1 through 7. This can be useful for producing graphs of the +source's performance. ++ *statistics*::: This option logs information about the regression processing to a file called _statistics.log_. An example line (which actually appears as a single line in diff --git a/ntp_core.c b/ntp_core.c index 014f999d..cb38af60 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -49,6 +49,7 @@ /* ================================================== */ static LOG_FileID logfileid; +static int log_raw_measurements; /* ================================================== */ /* Enumeration used for remembering the operating mode of one of the @@ -353,7 +354,7 @@ NCR_Initialise(void) do_size_checks(); do_time_checks(); - logfileid = CNF_GetLogMeasurements() ? LOG_FileOpen("measurements", + logfileid = CNF_GetLogMeasurements(&log_raw_measurements) ? LOG_FileOpen("measurements", " Date (UTC) Time IP Address L St 123 567 ABCD LP RP Score Offset Peer del. Peer disp. Root del. Root disp. Refid MTxRx") : -1; @@ -1687,7 +1688,7 @@ receive_packet(NCR_Instance inst, NTP_Local_Address *local_addr, } /* Do measurement logging */ - if (logfileid != -1) { + if (logfileid != -1 && (log_raw_measurements || synced_packet)) { LOG_FileWrite(logfileid, "%s %-15s %1c %2d %1d%1d%1d %1d%1d%1d %1d%1d%1d%d %2d %2d %4.2f %10.3e %10.3e %10.3e %10.3e %10.3e %08"PRIX32" %1d%1c %1c %1c", UTI_TimeToLogForm(sample_time.tv_sec), UTI_IPToString(&inst->remote_addr.ip_addr),