]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: add timestamp counters to serverstats report
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 16 Mar 2023 15:59:18 +0000 (16:59 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 22 Mar 2023 09:47:22 +0000 (10:47 +0100)
Add the new RX/TX daemon/kernel/hardware timestamp counters to the
serverstats report.

candm.h
client.c
cmdmon.c
doc/chrony.conf.adoc
doc/chronyc.adoc
pktlength.c
test/simulation/110-chronyc
test/system/007-cmdmon

diff --git a/candm.h b/candm.h
index e7423233e5c9f2b10c03acc9a33ab0ff74d01f9e..2fba7f4716091d02ef9245d7017687f42f057dc5 100644 (file)
--- a/candm.h
+++ b/candm.h
@@ -530,7 +530,8 @@ typedef struct {
 #define RPY_SERVER_STATS2 22
 #define RPY_SELECT_DATA 23
 #define RPY_SERVER_STATS3 24
-#define N_REPLY_TYPES 25
+#define RPY_SERVER_STATS4 25
+#define N_REPLY_TYPES 26
 
 /* Status codes */
 #define STT_SUCCESS 0
@@ -676,6 +677,13 @@ typedef struct {
   uint32_t ntp_interleaved_hits;
   uint32_t ntp_timestamps;
   uint32_t ntp_span_seconds;
+  uint32_t ntp_daemon_rx_timestamps;
+  uint32_t ntp_daemon_tx_timestamps;
+  uint32_t ntp_kernel_rx_timestamps;
+  uint32_t ntp_kernel_tx_timestamps;
+  uint32_t ntp_hw_rx_timestamps;
+  uint32_t ntp_hw_tx_timestamps;
+  uint32_t reserved[4];
   int32_t EOR;
 } RPY_ServerStats;
 
index 414c761052e24e3f63c1b5b3c5396bbcbf11bbfc..44b875d594902abd39e78622acccd5cbd61f4051 100644 (file)
--- a/client.c
+++ b/client.c
@@ -2478,7 +2478,7 @@ process_cmd_serverstats(char *line)
   CMD_Reply reply;
 
   request.command = htons(REQ_SERVER_STATS);
-  if (!request_reply(&request, &reply, RPY_SERVER_STATS3, 0))
+  if (!request_reply(&request, &reply, RPY_SERVER_STATS4, 0))
     return 0;
 
   print_report("NTP packets received       : %U\n"
@@ -2491,7 +2491,13 @@ process_cmd_serverstats(char *line)
                "Authenticated NTP packets  : %U\n"
                "Interleaved NTP packets    : %U\n"
                "NTP timestamps held        : %U\n"
-               "NTP timestamp span         : %U\n",
+               "NTP timestamp span         : %U\n"
+               "NTP daemon RX timestamps   : %U\n"
+               "NTP daemon TX timestamps   : %U\n"
+               "NTP kernel RX timestamps   : %U\n"
+               "NTP kernel TX timestamps   : %U\n"
+               "NTP hardware RX timestamps : %U\n"
+               "NTP hardware TX timestamps : %U\n",
                (unsigned long)ntohl(reply.data.server_stats.ntp_hits),
                (unsigned long)ntohl(reply.data.server_stats.ntp_drops),
                (unsigned long)ntohl(reply.data.server_stats.cmd_hits),
@@ -2503,6 +2509,12 @@ process_cmd_serverstats(char *line)
                (unsigned long)ntohl(reply.data.server_stats.ntp_interleaved_hits),
                (unsigned long)ntohl(reply.data.server_stats.ntp_timestamps),
                (unsigned long)ntohl(reply.data.server_stats.ntp_span_seconds),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_daemon_rx_timestamps),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_daemon_tx_timestamps),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_kernel_rx_timestamps),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_kernel_tx_timestamps),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_hw_rx_timestamps),
+               (unsigned long)ntohl(reply.data.server_stats.ntp_hw_tx_timestamps),
                REPORT_END);
 
   return 1;
index cdb1d861892dfc4e7ad86b0f86e4083e3044ca05..96b66a72a268db78cafa828ccd7270ac5008e16c 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1177,7 +1177,7 @@ handle_server_stats(CMD_Request *rx_message, CMD_Reply *tx_message)
   RPT_ServerStatsReport report;
 
   CLG_GetServerStatsReport(&report);
-  tx_message->reply = htons(RPY_SERVER_STATS3);
+  tx_message->reply = htons(RPY_SERVER_STATS4);
   tx_message->data.server_stats.ntp_hits = htonl(report.ntp_hits);
   tx_message->data.server_stats.nke_hits = htonl(report.nke_hits);
   tx_message->data.server_stats.cmd_hits = htonl(report.cmd_hits);
@@ -1189,6 +1189,14 @@ handle_server_stats(CMD_Request *rx_message, CMD_Reply *tx_message)
   tx_message->data.server_stats.ntp_interleaved_hits = htonl(report.ntp_interleaved_hits);
   tx_message->data.server_stats.ntp_timestamps = htonl(report.ntp_timestamps);
   tx_message->data.server_stats.ntp_span_seconds = htonl(report.ntp_span_seconds);
+  tx_message->data.server_stats.ntp_daemon_rx_timestamps = htonl(report.ntp_daemon_rx_timestamps);
+  tx_message->data.server_stats.ntp_daemon_tx_timestamps = htonl(report.ntp_daemon_tx_timestamps);
+  tx_message->data.server_stats.ntp_kernel_rx_timestamps = htonl(report.ntp_kernel_rx_timestamps);
+  tx_message->data.server_stats.ntp_kernel_tx_timestamps = htonl(report.ntp_kernel_tx_timestamps);
+  tx_message->data.server_stats.ntp_hw_rx_timestamps = htonl(report.ntp_hw_rx_timestamps);
+  tx_message->data.server_stats.ntp_hw_tx_timestamps = htonl(report.ntp_hw_tx_timestamps);
+  memset(tx_message->data.server_stats.reserved, 0xff,
+         sizeof (tx_message->data.server_stats.reserved));
 }
 
 /* ================================================== */
index 49d5168ba57f565511051370820109c257790d17..852d6b910f230b10736ea96739ae5fc2f4781007 100644 (file)
@@ -2536,10 +2536,13 @@ physical clock created by writing to _/sys/class/ptp/ptpX/n_vclocks_. This
 feature is available on Linux 5.14 and newer.
 +
 If the kernel supports software timestamping, it will be enabled for all
-interfaces. The source of timestamps (i.e. hardware, kernel, or daemon) is
-indicated in the _measurements.log_ file if enabled by the <<log,*log
-measurements*>> directive, and the <<chronyc.adoc#ntpdata,*ntpdata*>> report in
-*chronyc*.
+interfaces automatically.
++
+The source of timestamps (i.e. hardware, kernel, or daemon) is indicated on the
+client side in the _measurements.log_ file (if enabled by the <<log,*log*>>
+directive) and the <<chronyc.adoc#ntpdata,*ntpdata*>> report. On the server
+side, the number of served timestamps from each source is provided in the
+<<chronyc.adoc#serverstats,*serverstats*>> report.
 +
 This directive can be used multiple times to enable HW timestamping on multiple
 interfaces. If the specified interface is _*_, *chronyd* will try to enable HW
index a1d2de2710f5f777133291ed146699773b51b4dd..b04aaeb61ee450e7a672d38bf9445f23f27515b9 100644 (file)
@@ -1158,6 +1158,12 @@ Authenticated NTP packets  : 189
 Interleaved NTP packets    : 43
 NTP timestamps held        : 44
 NTP timestamp span         : 120
+NTP daemon RX timestamps   : 0
+NTP daemon TX timestamps   : 1537
+NTP kernel RX timestamps   : 1590
+NTP kernel TX timestamps   : 43
+NTP hardware RX timestamps : 0
+NTP hardware TX timestamps : 0
 ----
 +
 The fields have the following meaning:
@@ -1192,6 +1198,24 @@ The number of pairs of receive and transmit timestamps that the server is
 currently holding in memory for clients using the interleaved mode.
 *NTP timestamp span*:::
 The interval (in seconds) covered by the currently held NTP timestamps.
+*NTP daemon RX timestamps*:::
+The number of NTP responses which included a receive timestamp captured by the
+daemon.
+*NTP daemon TX timestamps*:::
+The number of NTP responses which included a transmit timestamp captured by the
+daemon.
+*NTP kernel RX timestamps*:::
+The number of NTP responses which included a receive timestamp captured by the
+kernel.
+*NTP kernel TX timestamps*:::
+The number of NTP responses (in the interleaved mode) which included a transmit
+timestamp captured by the kernel.
+*NTP hardware RX timestamps*:::
+The number of NTP responses which included a receive timestamp captured by the
+NIC.
+*NTP hardware TX timestamps*:::
+The number of NTP responses (in the interleaved mode) which included a transmit
+timestamp captured by the NIC.
 {blank}::
 +
 Note that the numbers reported by this command overflow to zero after
index 263b16dcdaf84f79145f8be2e77feed84f513dec..d7ed2723ed3fa4ee2b62015c54ba3cbef5160ffa 100644 (file)
@@ -157,7 +157,8 @@ static const uint16_t reply_lengths[] = {
   RPY_LENGTH_ENTRY(client_accesses_by_index),   /* CLIENT_ACCESSES_BY_INDEX3 */
   0,                                            /* SERVER_STATS2 - not supported */
   RPY_LENGTH_ENTRY(select_data),                /* SELECT_DATA */
-  RPY_LENGTH_ENTRY(server_stats),               /* SERVER_STATS3 */
+  0,                                            /* SERVER_STATS3 - not supported */
+  RPY_LENGTH_ENTRY(server_stats),               /* SERVER_STATS4 */
 };
 
 /* ================================================== */
index 2529cec1b0634387b9e071ed34666f7a54482f65..33d204bb613c03c8fe9b353cd6fc5e6d9e1d7e49 100755 (executable)
@@ -260,7 +260,13 @@ NTS-KE connections dropped : 0
 Authenticated NTP packets  : 0
 Interleaved NTP packets    : 0
 NTP timestamps held        : 0
-NTP timestamp span         : 0$" || test_fail
+NTP timestamp span         : 0
+NTP daemon RX timestamps   : 0
+NTP daemon TX timestamps   : 1
+NTP kernel RX timestamps   : 1
+NTP kernel TX timestamps   : 0
+NTP hardware RX timestamps : 0
+NTP hardware TX timestamps : 0$" || test_fail
 
 chronyc_conf="
 deny all
index 301d01ceb694e27fb9f3097e480589d73a045e50..f9541d30fea0ec972a2176404532475829c1dc21 100755 (executable)
@@ -115,7 +115,13 @@ NTS-KE connections dropped : 0
 Authenticated NTP packets  : 0
 Interleaved NTP packets    : 0
 NTP timestamps held        : 0
-NTP timestamp span         : 0$"|| test_fail
+NTP timestamp span         : 0
+NTP daemon RX timestamps   : 0
+NTP daemon TX timestamps   : [0-9]+
+NTP kernel RX timestamps   : [0-9]+
+NTP kernel TX timestamps   : 0
+NTP hardware RX timestamps : 0
+NTP hardware TX timestamps : 0$"|| test_fail
 
 run_chronyc "manual on" || test_fail
 check_chronyc_output "^200 OK$" || test_fail