cmdmon: add timestamp counters to serverstats report

Add the new RX/TX daemon/kernel/hardware timestamp counters to the
serverstats report.
This commit is contained in:
Miroslav Lichvar 2023-03-16 16:59:18 +01:00
parent 2f961ab36a
commit 0845df7684
8 changed files with 79 additions and 11 deletions

10
candm.h
View file

@ -530,7 +530,8 @@ typedef struct {
#define RPY_SERVER_STATS2 22 #define RPY_SERVER_STATS2 22
#define RPY_SELECT_DATA 23 #define RPY_SELECT_DATA 23
#define RPY_SERVER_STATS3 24 #define RPY_SERVER_STATS3 24
#define N_REPLY_TYPES 25 #define RPY_SERVER_STATS4 25
#define N_REPLY_TYPES 26
/* Status codes */ /* Status codes */
#define STT_SUCCESS 0 #define STT_SUCCESS 0
@ -676,6 +677,13 @@ typedef struct {
uint32_t ntp_interleaved_hits; uint32_t ntp_interleaved_hits;
uint32_t ntp_timestamps; uint32_t ntp_timestamps;
uint32_t ntp_span_seconds; 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; int32_t EOR;
} RPY_ServerStats; } RPY_ServerStats;

View file

@ -2478,7 +2478,7 @@ process_cmd_serverstats(char *line)
CMD_Reply reply; CMD_Reply reply;
request.command = htons(REQ_SERVER_STATS); 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; return 0;
print_report("NTP packets received : %U\n" print_report("NTP packets received : %U\n"
@ -2491,7 +2491,13 @@ process_cmd_serverstats(char *line)
"Authenticated NTP packets : %U\n" "Authenticated NTP packets : %U\n"
"Interleaved NTP packets : %U\n" "Interleaved NTP packets : %U\n"
"NTP timestamps held : %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_hits),
(unsigned long)ntohl(reply.data.server_stats.ntp_drops), (unsigned long)ntohl(reply.data.server_stats.ntp_drops),
(unsigned long)ntohl(reply.data.server_stats.cmd_hits), (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_interleaved_hits),
(unsigned long)ntohl(reply.data.server_stats.ntp_timestamps), (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_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); REPORT_END);
return 1; return 1;

View file

@ -1177,7 +1177,7 @@ handle_server_stats(CMD_Request *rx_message, CMD_Reply *tx_message)
RPT_ServerStatsReport report; RPT_ServerStatsReport report;
CLG_GetServerStatsReport(&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.ntp_hits = htonl(report.ntp_hits);
tx_message->data.server_stats.nke_hits = htonl(report.nke_hits); tx_message->data.server_stats.nke_hits = htonl(report.nke_hits);
tx_message->data.server_stats.cmd_hits = htonl(report.cmd_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_interleaved_hits = htonl(report.ntp_interleaved_hits);
tx_message->data.server_stats.ntp_timestamps = htonl(report.ntp_timestamps); 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_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));
} }
/* ================================================== */ /* ================================================== */

View 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. feature is available on Linux 5.14 and newer.
+ +
If the kernel supports software timestamping, it will be enabled for all If the kernel supports software timestamping, it will be enabled for all
interfaces. The source of timestamps (i.e. hardware, kernel, or daemon) is interfaces automatically.
indicated in the _measurements.log_ file if enabled by the <<log,*log +
measurements*>> directive, and the <<chronyc.adoc#ntpdata,*ntpdata*>> report in The source of timestamps (i.e. hardware, kernel, or daemon) is indicated on the
*chronyc*. 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 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 interfaces. If the specified interface is _*_, *chronyd* will try to enable HW

View file

@ -1158,6 +1158,12 @@ Authenticated NTP packets : 189
Interleaved NTP packets : 43 Interleaved NTP packets : 43
NTP timestamps held : 44 NTP timestamps held : 44
NTP timestamp span : 120 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: 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. currently holding in memory for clients using the interleaved mode.
*NTP timestamp span*::: *NTP timestamp span*:::
The interval (in seconds) covered by the currently held NTP timestamps. 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}:: {blank}::
+ +
Note that the numbers reported by this command overflow to zero after Note that the numbers reported by this command overflow to zero after

View file

@ -157,7 +157,8 @@ static const uint16_t reply_lengths[] = {
RPY_LENGTH_ENTRY(client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX3 */ RPY_LENGTH_ENTRY(client_accesses_by_index), /* CLIENT_ACCESSES_BY_INDEX3 */
0, /* SERVER_STATS2 - not supported */ 0, /* SERVER_STATS2 - not supported */
RPY_LENGTH_ENTRY(select_data), /* SELECT_DATA */ 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 */
}; };
/* ================================================== */ /* ================================================== */

View file

@ -260,7 +260,13 @@ NTS-KE connections dropped : 0
Authenticated NTP packets : 0 Authenticated NTP packets : 0
Interleaved NTP packets : 0 Interleaved NTP packets : 0
NTP timestamps held : 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=" chronyc_conf="
deny all deny all

View file

@ -115,7 +115,13 @@ NTS-KE connections dropped : 0
Authenticated NTP packets : 0 Authenticated NTP packets : 0
Interleaved NTP packets : 0 Interleaved NTP packets : 0
NTP timestamps held : 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 run_chronyc "manual on" || test_fail
check_chronyc_output "^200 OK$" || test_fail check_chronyc_output "^200 OK$" || test_fail