]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: add rawmeasurements log option
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 30 Jan 2017 08:22:51 +0000 (09:22 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 31 Jan 2017 10:22:10 +0000 (11:22 +0100)
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.

conf.c
conf.h
doc/chrony.conf.adoc
ntp_core.c

diff --git a/conf.c b/conf.c
index 5904b91135c6577ee237fc1eb223a8a8a21af38a..9aa034c86aed6eb15726dfa66bf6d3bd63a3e53f 100644 (file)
--- 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 22e654297a75b1358baa7a3583fdee7ab1343633..7ff1dba04986c3668f7cbb7de88f0cc35aea21fc 100644 (file)
--- 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);
index 793e222ce019a954680e3063d6d2cd2dce0a4507..7a3bedb58e46e3ac596e718c01f45a614f926502 100644 (file)
@@ -1518,10 +1518,12 @@ The log files are written to the directory specified by the <<logdir,*logdir*>>
 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
index 014f999d7e2b9b4172179c644355e0ad9de6788d..cb38af60da82127d6b12147bdb3f943f05237108 100644 (file)
@@ -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),