mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 22:15:07 -05:00
cmdmon: limit reported clients by number of packets
Add a new field to the CLIENT_ACCESSES_BY_INDEX request to specify the minimum number of NTP or cmdmon packets for a client to be reported. Add -p option to the chronyc clients command to specify the threshold (by default 0). This option can be used to minimize the number of cmdmon requests when interested only in clients sending a large number of requests.
This commit is contained in:
18
client.c
18
client.c
@@ -1243,7 +1243,7 @@ give_help(void)
|
||||
"\0(e.g. Sep 25, 2015 16:30:05 or 16:30:05)\0"
|
||||
"\0\0NTP access:\0\0"
|
||||
"accheck <address>\0Check whether address is allowed\0"
|
||||
"clients [-r]\0Report on clients that have accessed the server\0"
|
||||
"clients [-p <packets>] [-r]\0Report on clients that 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"
|
||||
@@ -2673,18 +2673,27 @@ process_cmd_clients(char *line)
|
||||
CMD_Request request;
|
||||
CMD_Reply reply;
|
||||
IPAddr ip;
|
||||
uint32_t i, n_clients, next_index, n_indices, reset;
|
||||
uint32_t i, n_clients, next_index, n_indices, min_hits, reset;
|
||||
RPY_ClientAccesses_Client *client;
|
||||
char name[50], *opt;
|
||||
char name[50], *opt, *arg;
|
||||
|
||||
next_index = 0;
|
||||
min_hits = 0;
|
||||
reset = 0;
|
||||
|
||||
while (*line) {
|
||||
opt = line;
|
||||
line = CPS_SplitWord(line);
|
||||
if (strcmp(opt, "-r") == 0)
|
||||
if (strcmp(opt, "-p") == 0) {
|
||||
arg = line;
|
||||
line = CPS_SplitWord(line);
|
||||
if (sscanf(arg, "%"SCNu32, &min_hits) != 1) {
|
||||
LOG(LOGS_ERR, "Invalid syntax for clients command");
|
||||
return 0;
|
||||
}
|
||||
} else if (strcmp(opt, "-r") == 0) {
|
||||
reset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
print_header("Hostname NTP Drop Int IntL Last Cmd Drop Int Last");
|
||||
@@ -2693,6 +2702,7 @@ process_cmd_clients(char *line)
|
||||
request.command = htons(REQ_CLIENT_ACCESSES_BY_INDEX3);
|
||||
request.data.client_accesses_by_index.first_index = htonl(next_index);
|
||||
request.data.client_accesses_by_index.n_clients = htonl(MAX_CLIENT_ACCESSES);
|
||||
request.data.client_accesses_by_index.min_hits = htonl(min_hits);
|
||||
request.data.client_accesses_by_index.reset = htonl(reset);
|
||||
|
||||
if (!request_reply(&request, &reply, RPY_CLIENT_ACCESSES_BY_INDEX2, 0))
|
||||
|
||||
Reference in New Issue
Block a user