diff --git a/chrony.texi.in b/chrony.texi.in index 3d629e3..7726624 100644 --- a/chrony.texi.in +++ b/chrony.texi.in @@ -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 df3d080..a23d1ae 100644 --- 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 fd79c60..b5ac5cf 100644 --- 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); diff --git a/reference.c b/reference.c index bea923b..f9b4ad4 100644 --- a/reference.c +++ b/reference.c @@ -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);