<dd>The broadcast and multicast modes require a special calibration to determine the network delay between the local and remote servers. Ordinarily, this is done automatically by the initial protocol exchanges between the client and server. In some cases, the calibration procedure may fail due to network or server access controls, for example. This command specifies the default delay to be used under these circumstances. Typically (for Ethernet), a number between 0.003 and 0.007 seconds is appropriate. The default when this command is not used is 0.004 seconds.
<dt><tt>calldelay <i>delay</i></tt>
<dd>This option controls the delay in seconds between the first and second packets sent in burst or iburst mode to allow additional time for a modem or ISDN call to complete.
- <dt><tt>driftfile <i>driftfile</i></tt>
+ <dt><tt>driftfile <i>driftfile</i> [<i>
+ minutes </i> [<i> tolerance </i>] ]</tt>
<dd>This command specifies the complete path and name of the file used to record the frequency of the local clock oscillator. This is the same operation as the <tt>-f</tt> command linke option. If the file exists, it is read at startup in order to set the initial frequency and then updated once per hour with the current frequency computed by the daemon. If the file name is specified, but the file itself does not exist, the starts with an initial frequency of zero and creates the file when writing it for the first time. If this command is not given, the daemon will always start with an initial frequency of zero.
<p>The file format consists of a single line containing a single floating point number, which records the frequency offset measured in parts-per-million (PPM). The file is updated by first writing the current drift value into a temporary file and then renaming this file to replace the old version. This implies that <tt>ntpd</tt> must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided.</p>
- <dt><tt>enable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats]</tt><br>
+
+<p>The two optional values determine how often the file is written, and
+are particuarly useful when is it desirable to avoid spinning up the
+disk unnecessarily. The parameter <tt>minutes</tt> is how often the file will be written. If omitted or less
+than 1, the interval will be 60 minutes (one hour). The parameter <tt>tolerance</tt> is the
+threshold to skip writing the new value. If the new value is within
+<tt>tolerance</tt> percent of the last value written (compared out to 3
+decimal places), the write will be
+skipped. The default is 0.0, which means that the write will occur
+unless the current and previous values are the same. A tolerance of
+.1 equates roughly to a difference in the 2nd decimal place.</p>
+<dt><tt>enable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats]</tt><br>
<tt>disable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats ]</tt>
<dd>Provides a way to enable or disable various system options. Flags not mentioned are unaffected. Note that all of these flags can be controlled remotely using the <a href="ntpdc.html"><tt>ntpdc</tt></a> utility program.
<dl>
<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
</body>
-</html>
\ No newline at end of file
+</html>
/* ntp_util.c */
extern void init_util P((void));
-extern void hourly_stats P((void));
+extern void write_stats P((void));
extern void stats_config P((int, char *));
extern void record_peer_stats P((struct sockaddr_storage *, int, double, double, double, double));
extern void record_loop_stats P((double, double, double, double, int));
/* ntp_util.c */
extern int stats_control; /* write stats to fileset? */
+extern int stats_write_period; /* # of seconds between writes. */
+extern double stats_write_tolerance;
/* ntpd.c */
extern volatile int debug; /* debugging flag */
stats_config(STATS_FREQ_FILE, tokens[1]);
else
stats_config(STATS_FREQ_FILE, (char *)0);
+ stats_write_period = stats_write_tolerance = 0;
+ if (ntokens >= 3)
+ stats_write_period = 60 * atol(tokens[2]);
+ if (stats_write_period <= 0)
+ stats_write_period = 3600;
+ if (ntokens >= 4) {
+ double ftemp;
+ sscanf(tokens[3], "%lf", &ftemp);
+ stats_write_tolerance = ftemp / 100;
+ }
break;
case CONFIG_PIDFILE:
*/
static u_long adjust_timer; /* second timer */
static u_long keys_timer; /* minute timer */
-static u_long hourly_timer; /* hour timer */
+static u_long stats_timer; /* stats timer */
static u_long huffpuff_timer; /* huff-n'-puff timer */
#ifdef OPENSSL
static u_long revoke_timer; /* keys revoke timer */
alarm_flag = 0;
alarm_overflow = 0;
adjust_timer = 1;
- hourly_timer = HOUR;
+ stats_timer = 0;
huffpuff_timer = 0;
current_time = 0;
timer_overflows = 0;
#endif /* OPENSSL */
/*
- * Finally, call the hourly routine.
+ * Finally, periodically write stats.
*/
- if (hourly_timer <= current_time) {
- hourly_timer += HOUR;
- hourly_stats();
+ if (stats_timer <= current_time) {
+ if (stats_timer != 0)
+ write_stats();
+ stats_timer += stats_write_period;
}
}
*/
static char *stats_drift_file;
static char *stats_temp_file;
+int stats_write_period = 3600; /* # of seconds between writes. */
+double stats_write_tolerance = 0;
+static double prev_drift_comp = 99999.;
/*
* Statistics file stuff
* hourly_stats - print some interesting stats
*/
void
-hourly_stats(void)
+write_stats(void)
{
FILE *fp;
record_sys_stats();
+ if ((u_long)(fabs(prev_drift_comp - drift_comp) * 1e9) <=
+ (u_long)(fabs(stats_write_tolerance * drift_comp) * 1e9)) {
+ return;
+ }
+ prev_drift_comp = drift_comp;
if (stats_drift_file != 0) {
if ((fp = fopen(stats_temp_file, "w")) == NULL) {
msyslog(LOG_ERR, "can't open %s: %m",
break;
}
fclose(fp);
+ prev_drift_comp = old_drift / 1e6;
msyslog(LOG_INFO,
"frequency initialized %.3f PPM from %s",
old_drift, stats_drift_file);
{
msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
+ write_stats();
#ifdef HAVE_DNSREGISTRATION
if (mdns != NULL)
DNSServiceRefDeallocate(mdns);