cmdmon: add serverstats command

Add a new command to obtain a server report with the new clientlog
statistics.
This commit is contained in:
Miroslav Lichvar
2016-01-18 17:09:36 +01:00
parent f52a738660
commit 9b019a03e7
6 changed files with 62 additions and 2 deletions

View File

@@ -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;