]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: add serverstats command
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Jan 2016 16:13:26 +0000 (17:13 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 22 Jan 2016 13:40:29 +0000 (14:40 +0100)
chrony.texi.in
client.c

index e831b085c0b125b0ab18139acf43f1bf87d5585b..2fc780cb870ea62c736620e0cec47eeae200d166 100644 (file)
@@ -3396,6 +3396,7 @@ interface.
 * reselectdist command::        Set improvement in distance needed to reselect a source
 * retries command::             Set maximum number of retries
 * rtcdata command::             Display RTC parameters
+* serverstats command::         Display statistics of the server
 * settime command::             Provide a manual input of the current time
 * smoothing command::           Display current time smoothing state
 * smoothtime command::          Reset/activate server time smoothing
@@ -4314,6 +4315,24 @@ right when it crosses a particular second boundary.  Then it would be 1
 microsecond fast when it crosses its next second boundary.
 @end table
 @c }}}
+@c {{{ serverstats command
+@node serverstats command
+@subsubsection serverstats command
+The @code{serverstats} command displays how many valid NTP and command requests
+@code{chronyd} as a server received from clients, how many of them were dropped
+to limit the response rate as configured by the @code{ratelimit} and
+@code{cmdratelimit} directives, and how many client log records were dropped
+due to the memory limit configured by the @code{clientloglimit} directive.  An
+example of the output is shown below.
+
+@example
+NTP packets received       : 1598
+NTP packets dropped        : 8
+Command packets received   : 19
+Command packets dropped    : 0
+Client log records dropped : 0
+@end example
+@c }}}
 @c {{{ settime
 @node settime command
 @subsubsection settime
index c98ab5678417a09cf9781db8d9f6fc0f52dfc174..225776377cef0191cdd5e849e9da5b7571949e35 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1225,6 +1225,7 @@ give_help(void)
     "\0\0NTP access:\0\0"
     "accheck <address>\0Check whether address is allowed\0"
     "clients\0Report on clients that have accessed the server\0"
+    "serverstats\0Display statistics of the server\0"
     "allow [<subnet>]\0Allow access to subnet as a default\0"
     "allow all [<subnet>]\0Allow access to subnet and all children\0"
     "deny [<subnet>]\0Deny access to subnet as a default\0"
@@ -1962,6 +1963,29 @@ process_cmd_tracking(char *line)
   }
   return 0;
 }
+
+/* ================================================== */
+
+static int
+process_cmd_serverstats(char *line)
+{
+  CMD_Request request;
+  CMD_Reply reply;
+
+  request.command = htons(REQ_SERVER_STATS);
+
+  if (!request_reply(&request, &reply, RPY_SERVER_STATS, 0))
+    return 0;
+
+  printf("NTP packets received       : %"PRIu32"\n", ntohl(reply.data.server_stats.ntp_hits));
+  printf("NTP packets dropped        : %"PRIu32"\n", ntohl(reply.data.server_stats.ntp_drops));
+  printf("Command packets received   : %"PRIu32"\n", ntohl(reply.data.server_stats.cmd_hits));
+  printf("Command packets dropped    : %"PRIu32"\n", ntohl(reply.data.server_stats.cmd_drops));
+  printf("Client log records dropped : %"PRIu32"\n", ntohl(reply.data.server_stats.log_drops));
+
+  return 1;
+}
+
 /* ================================================== */
 
 static int
@@ -2590,6 +2614,9 @@ process_line(char *line)
   } else if (!strcmp(command, "rtcdata")) {
     do_normal_submit = 0;
     ret = process_cmd_rtcreport(line);
+  } else if (!strcmp(command, "serverstats")) {
+    do_normal_submit = 0;
+    ret = process_cmd_serverstats(line);
   } else if (!strcmp(command, "settime")) {
     do_normal_submit = 0;
     ret = process_cmd_settime(line);