MINOR: cli: Dump all resolvers stats if no resolver section is given

This commit adds support for dumping all resolver stats. Specifically
if a command 'show stats resolvers' is issued withOUT a resolver section
id, we dump all known resolver sections. If none are configured, a
message is displayed indicating that.
This commit is contained in:
Andrew Hayworth 2015-10-02 20:33:01 +00:00 committed by Willy Tarreau
parent 49795eb00c
commit 68d0534885
2 changed files with 43 additions and 36 deletions

View File

@ -16025,8 +16025,10 @@ show stat [<iid> <type> <sid>]
A similar empty line appears at the end of the second block (stats) so that
the reader knows the output has not been truncated.
show stat resolvers <resolvers section id>
Dump statistics for the given resolvers section.
show stat resolvers [<resolvers section id>]
Dump statistics for the given resolvers section, or all resolvers sections
if no section is supplied.
For each name server, the following counters are reported:
sent: number of DNS requests sent to this server
valid: number of DNS valid responses received from this server

View File

@ -1166,12 +1166,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
if (strcmp(args[2], "resolvers") == 0) {
struct dns_resolvers *presolvers;
if (!*args[3]) {
appctx->ctx.cli.msg = "Missing resolver section identifier.\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
}
if (*args[3]) {
appctx->ctx.resolvers.ptr = NULL;
list_for_each_entry(presolvers, &dns_resolvers, list) {
if (strcmp(presolvers->id, args[3]) == 0) {
@ -1180,10 +1175,11 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
}
}
if (appctx->ctx.resolvers.ptr == NULL) {
appctx->ctx.cli.msg = "Can't find resolvers section.\n";
appctx->ctx.cli.msg = "Can't find that resolvers section\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
}
}
appctx->st2 = STAT_ST_INIT;
appctx->st0 = STAT_CLI_O_RESOLVERS;
@ -6400,7 +6396,14 @@ static int stats_dump_resolvers_to_buffer(struct stream_interface *si)
/* fall through */
case STAT_ST_LIST:
presolvers = appctx->ctx.resolvers.ptr;
if (LIST_ISEMPTY(&dns_resolvers)) {
chunk_appendf(&trash, "No resolvers found\n");
}
else {
list_for_each_entry(presolvers, &dns_resolvers, list) {
if (appctx->ctx.resolvers.ptr != NULL && appctx->ctx.resolvers.ptr != presolvers)
continue;
chunk_appendf(&trash, "Resolvers section %s\n", presolvers->id);
list_for_each_entry(pnameserver, &presolvers->nameserver_list, list) {
chunk_appendf(&trash, " nameserver %s:\n", pnameserver->id);
@ -6419,6 +6422,8 @@ static int stats_dump_resolvers_to_buffer(struct stream_interface *si)
chunk_appendf(&trash, " truncated: %ld\n", pnameserver->counters.truncated);
chunk_appendf(&trash, " outdated: %ld\n", pnameserver->counters.outdated);
}
}
}
/* display response */
if (bi_putchk(si_ic(si), &trash) == -1) {