mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 20:45:07 -05:00
cmdmon: add serverstats command
Add a new command to obtain a server report with the new clientlog statistics.
This commit is contained in:
21
cmdmon.c
21
cmdmon.c
@@ -130,6 +130,7 @@ static const char permissions[] = {
|
||||
PERMIT_OPEN, /* SMOOTHING */
|
||||
PERMIT_AUTH, /* SMOOTHTIME */
|
||||
PERMIT_AUTH, /* REFRESH */
|
||||
PERMIT_AUTH, /* SERVER_STATS */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
@@ -1146,6 +1147,22 @@ handle_refresh(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
NSR_RefreshAddresses();
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_server_stats(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
RPT_ServerStatsReport report;
|
||||
|
||||
CLG_GetServerStatsReport(&report);
|
||||
tx_message->reply = htons(RPY_SERVER_STATS);
|
||||
tx_message->data.server_stats.ntp_hits = htonl(report.ntp_hits);
|
||||
tx_message->data.server_stats.cmd_hits = htonl(report.cmd_hits);
|
||||
tx_message->data.server_stats.ntp_drops = htonl(report.ntp_drops);
|
||||
tx_message->data.server_stats.cmd_drops = htonl(report.cmd_drops);
|
||||
tx_message->data.server_stats.log_drops = htonl(report.log_drops);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
/* Read a packet and process it */
|
||||
|
||||
@@ -1534,6 +1551,10 @@ read_from_cmd_socket(void *anything)
|
||||
handle_refresh(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_SERVER_STATS:
|
||||
handle_server_stats(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user