]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: set logchange to 1 second by default
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Jan 2016 14:35:55 +0000 (15:35 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 29 Jan 2016 16:55:58 +0000 (17:55 +0100)
logchange is now always enabled, with 1 second threshold by default.

chrony.texi.in
conf.c
conf.h
reference.c

index 3d629e3364345ea36e4bbbd70aff4acac0d44369..77266241a254af07fb650a1b49fe2a3befaed893 100644 (file)
@@ -2251,24 +2251,22 @@ used to disable it entirely.
 @c {{{ logchange
 @node logchange directive
 @subsection logchange
-This directive forces @code{chronyd} to send a message to syslog if it
-makes a system clock adjustment larger than a threshold value.  An
-example of use is
+This directive sets the threshold for the adjustment of the system clock
+that will generate a syslog message.
+
+By default, the threshold is 1 second.
+
+An example of use is
 
 @example
-logchange 0.5
+logchange 0.1
 @end example
 
 which would cause a syslog message to be generated a system clock error
-of over 0.5 seconds starts to be compensated.
+of over 0.1 seconds starts to be compensated.
 
-Clock errors detected either via NTP packets or via timestamps entered
+Clock errors detected via NTP packets, reference clocks, or timestamps entered
 via the @code{settime} command of @code{chronyc} are logged.
-
-This directive assumes that syslog messages are appearing where somebody
-can see them.  This allows that person to see if a large error has
-arisen, e.g. because of a fault, or because of faulty timezone handling,
-for example when summer time (daylight saving) starts or ends.
 @c }}}
 @c {{{ logdir
 @node logdir directive
diff --git a/conf.c b/conf.c
index df3d0806d379e6466827e8e254ccc4484b37451d..a23d1ae7f8e837a8b384205d9c4a40e9bf5dd538 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -146,10 +146,8 @@ static double max_offset;
 static int max_samples = 0; /* no limit */
 static int min_samples = 0;
 
-/* Flag set if we should log to syslog when a time adjustment
-   exceeding the threshold is initiated */
-static int do_log_change = 0;
-static double log_change_threshold = 0.0;
+/* Threshold for a time adjustment to be logged to syslog */
+static double log_change_threshold = 1.0;
 
 static char *mail_user_on_change = NULL;
 static double mail_change_threshold = 0.0;
@@ -476,7 +474,7 @@ CNF_ParseLine(const char *filename, int number, char *line)
   } else if (!strcasecmp(command, "logbanner")) {
     parse_int(p, &log_banner);
   } else if (!strcasecmp(command, "logchange")) {
-    do_log_change = parse_double(p, &log_change_threshold);
+    parse_double(p, &log_change_threshold);
   } else if (!strcasecmp(command, "logdir")) {
     parse_string(p, &logdir);
   } else if (!strcasecmp(command, "mailonchange")) {
@@ -1607,11 +1605,10 @@ CNF_GetMaxChange(int *delay, int *ignore, double *offset)
 
 /* ================================================== */
 
-void
-CNF_GetLogChange(int *enabled, double *threshold)
+double
+CNF_GetLogChange(void)
 {
-  *enabled = do_log_change;
-  *threshold = log_change_threshold;
+  return log_change_threshold;
 }
 
 /* ================================================== */
diff --git a/conf.h b/conf.h
index fd79c602d94ece012996ea1aa1c59fabdcde74ff..b5ac5cfaec01bfeed0c33b273e7cf1482b38be6e 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -67,7 +67,7 @@ extern int CNF_GetRtcOnUtc(void);
 extern int CNF_GetRtcSync(void);
 extern void CNF_GetMakeStep(int *limit, double *threshold);
 extern void CNF_GetMaxChange(int *delay, int *ignore, double *offset);
-extern void CNF_GetLogChange(int *enabled, double *threshold);
+extern double CNF_GetLogChange(void);
 extern void CNF_GetMailOnChange(int *enabled, double *threshold, char **user);
 extern int CNF_GetNoClientLog(void);
 extern unsigned long CNF_GetClientLogLimit(void);
index bea923b2fbd9b8844e7436a69fcc67076703aa78..f9b4ad40862cfc4913da4d3b11d3027d673edc28 100644 (file)
@@ -80,8 +80,7 @@ static int max_offset_delay;
 static int max_offset_ignore;
 static double max_offset;
 
-/* Flag and threshold for logging clock changes to syslog */
-static int do_log_change;
+/* Threshold for logging clock changes to syslog */
 static double log_change_threshold;
 
 /* Flag, threshold and user for sending mail notification on large clock changes */
@@ -254,8 +253,8 @@ REF_Initialise(void)
 
   CNF_GetMakeStep(&make_step_limit, &make_step_threshold);
   CNF_GetMaxChange(&max_offset_delay, &max_offset_ignore, &max_offset);
-  CNF_GetLogChange(&do_log_change, &log_change_threshold);
   CNF_GetMailOnChange(&do_mail_change, &mail_change_threshold, &mail_change_user);
+  log_change_threshold = CNF_GetLogChange();
 
   CNF_GetFallbackDrifts(&fb_drift_min, &fb_drift_max);
 
@@ -272,11 +271,6 @@ REF_Initialise(void)
 
   LCL_AddParameterChangeHandler(handle_slew, NULL);
 
-  /* And just to prevent anything wierd ... */
-  if (do_log_change) {
-    log_change_threshold = fabs(log_change_threshold);
-  }
-
   /* Make first entry in tracking log */
   REF_SetUnsynchronised();
 }
@@ -536,8 +530,7 @@ maybe_log_offset(double offset, time_t now)
 
   abs_offset = fabs(offset);
 
-  if (do_log_change &&
-      (abs_offset > log_change_threshold)) {
+  if (abs_offset > log_change_threshold) {
     LOG(LOGS_WARN, LOGF_Reference,
         "System clock wrong by %.6f seconds, adjustment started",
         -offset);