]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: add smoothing command
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 9 Jun 2015 09:32:47 +0000 (11:32 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 9 Jun 2015 14:15:30 +0000 (16:15 +0200)
chrony.texi.in
client.c

index b4f6342fdfd500d95468c1662c76481e7ae30727..745e1033c18234b6cf7c21fe1f72b9e061bd8b2e 100644 (file)
@@ -3284,6 +3284,7 @@ password:
 @item @code{password}
 @item @code{quit}
 @item @code{rtcdata}
+@item @code{smoothing}
 @item @code{sources}
 @item @code{sourcestats}
 @item @code{tracking}
@@ -3344,6 +3345,7 @@ interface.
 * retries command::             Set maximum number of retries
 * rtcdata command::             Display RTC parameters
 * settime command::             Provide a manual input of the current time
+* smoothing command::           Display current time smoothing state
 * sources command::             Display information about the current set of sources
 * sourcestats command::         Display the rate & offset estimation performance of sources
 * timeout command::             Set initial response timeout
@@ -4321,6 +4323,51 @@ settime Nov 21, 1997 16:30:05
 For a full description of @code{getdate}, get hold of the getdate
 documentation (bundled, for example, with the source for GNU tar).
 @c }}}
+@c {{{ smoothing
+@node smoothing command
+@subsubsection smoothing
+The @code{smoothing} command displays the current state of the NTP server time
+smoothing. An example of the output is shown below.
+
+@example
+Active         : Yes
+Offset         : +1.000268817 seconds
+Frequency      : -0.142859 ppm
+Wander         : -0.010000 ppm per second
+Last update    : 17.8 seconds ago
+Remaining time : 19988.4 seconds
+@end example
+
+The fields are explained as follows.
+
+@table @code
+@item Active
+This shows if the server time smoothing is currently active.  Possible values
+are @code{Yes} and @code{No}.  If the @code{leaponly} option is included in the
+@code{smoothtime} directive, @code{(leap second only)} will be shown on the
+line.
+
+@item Offset
+This is the current offset applied to the time sent to NTP clients.  Positive
+value means the clients are getting time that's ahead of true time.
+
+@item Frequency
+The current frequency offset of the served time.  Negative value means the time
+observed by clients is running slower than true time.
+
+@item Wander
+The current frequency wander of the served time.  Negative value means the time
+observed by clients is slowing down.
+
+@item Last update
+This field shows how long ago was the time smoothing process updated, e.g.
+@code{chronyd} accumulated a new measurement.
+
+@item Remaining time
+The time it would take for the smoothing process to get to zero offset and
+frequency if there were no more updates.
+@end table
+@c }}}
 @c {{{ sources
 @node sources command
 @subsubsection sources
index 07161fb190f9fdaa4165da3ebd28a35dbf26b8b4..69f57549b67436e64a10f65444f69c38bb03e7d5 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1184,6 +1184,7 @@ give_help(void)
   printf("reselect : Reselect synchronisation source\n");
   printf("rtcdata : Print current RTC performance parameters\n");
   printf("settime <date/time (e.g. Nov 21, 1997 16:30:05 or 16:30:05)> : Manually set the daemon time\n");
+  printf("smoothing : Display current time smoothing state\n");
   printf("sources [-v] : Display information about current sources\n");
   printf("sourcestats [-v] : Display estimation information about current sources\n");
   printf("tracking : Display system time information\n");
@@ -1964,6 +1965,44 @@ process_cmd_tracking(char *line)
 }
 /* ================================================== */
 
+static int
+process_cmd_smoothing(char *line)
+{
+  CMD_Request request;
+  CMD_Reply reply;
+  uint32_t flags;
+  double offset;
+  double freq_ppm;
+  double wander_ppm;
+  double last_update_ago;
+  double remaining_time;
+
+  request.command = htons(REQ_SMOOTHING);
+
+  if (request_reply(&request, &reply, RPY_SMOOTHING, 0)) {
+    flags = ntohl(reply.data.smoothing.flags);
+    offset = UTI_FloatNetworkToHost(reply.data.smoothing.offset);
+    freq_ppm = UTI_FloatNetworkToHost(reply.data.smoothing.freq_ppm);
+    wander_ppm = UTI_FloatNetworkToHost(reply.data.smoothing.wander_ppm);
+    last_update_ago = UTI_FloatNetworkToHost(reply.data.smoothing.last_update_ago);
+    remaining_time = UTI_FloatNetworkToHost(reply.data.smoothing.remaining_time);
+
+    printf("Active         : %s%s\n",
+           flags & RPY_SMT_FLAG_ACTIVE ? "Yes" : "No",
+           flags & RPY_SMT_FLAG_LEAPONLY ? " (leap second only)" : "");
+    printf("Offset         : %+.9f seconds\n", offset);
+    printf("Frequency      : %+.6f ppm\n", freq_ppm);
+    printf("Wander         : %+.6f ppm per second\n", wander_ppm);
+    printf("Last update    : %.1f seconds ago\n", last_update_ago);
+    printf("Remaining time : %.1f seconds\n", remaining_time);
+    return 1;
+  }
+
+  return 0;
+}
+
+/* ================================================== */
+
 static int
 process_cmd_rtcreport(char *line)
 {
@@ -2535,6 +2574,9 @@ process_line(char *line, int *quit)
   } else if (!strcmp(command, "settime")) {
     do_normal_submit = 0;
     ret = process_cmd_settime(line);
+  } else if (!strcmp(command, "smoothing")) {
+    do_normal_submit = 0;
+    ret = process_cmd_smoothing(line);
   } else if (!strcmp(command, "sources")) {
     do_normal_submit = 0;
     ret = process_cmd_sources(line);