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 A similar empty line appears at the end of the second block (stats) so that
the reader knows the output has not been truncated. the reader knows the output has not been truncated.
show stat resolvers <resolvers section id> show stat resolvers [<resolvers section id>]
Dump statistics for the given resolvers section. 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: For each name server, the following counters are reported:
sent: number of DNS requests sent to this server sent: number of DNS requests sent to this server
valid: number of DNS valid responses received from this server valid: number of DNS valid responses received from this server

View File

@ -1166,23 +1166,19 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
if (strcmp(args[2], "resolvers") == 0) { if (strcmp(args[2], "resolvers") == 0) {
struct dns_resolvers *presolvers; struct dns_resolvers *presolvers;
if (!*args[3]) { if (*args[3]) {
appctx->ctx.cli.msg = "Missing resolver section identifier.\n"; appctx->ctx.resolvers.ptr = NULL;
appctx->st0 = STAT_CLI_PRINT; list_for_each_entry(presolvers, &dns_resolvers, list) {
return 1; if (strcmp(presolvers->id, args[3]) == 0) {
} appctx->ctx.resolvers.ptr = presolvers;
break;
appctx->ctx.resolvers.ptr = NULL; }
list_for_each_entry(presolvers, &dns_resolvers, list) { }
if (strcmp(presolvers->id, args[3]) == 0) { if (appctx->ctx.resolvers.ptr == NULL) {
appctx->ctx.resolvers.ptr = presolvers; appctx->ctx.cli.msg = "Can't find that resolvers section\n";
break; appctx->st0 = STAT_CLI_PRINT;
return 1;
} }
}
if (appctx->ctx.resolvers.ptr == NULL) {
appctx->ctx.cli.msg = "Can't find resolvers section.\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
} }
appctx->st2 = STAT_ST_INIT; appctx->st2 = STAT_ST_INIT;
@ -6400,24 +6396,33 @@ static int stats_dump_resolvers_to_buffer(struct stream_interface *si)
/* fall through */ /* fall through */
case STAT_ST_LIST: case STAT_ST_LIST:
presolvers = appctx->ctx.resolvers.ptr; if (LIST_ISEMPTY(&dns_resolvers)) {
chunk_appendf(&trash, "Resolvers section %s\n", presolvers->id); chunk_appendf(&trash, "No resolvers found\n");
list_for_each_entry(pnameserver, &presolvers->nameserver_list, list) { }
chunk_appendf(&trash, " nameserver %s:\n", pnameserver->id); else {
chunk_appendf(&trash, " sent: %ld\n", pnameserver->counters.sent); list_for_each_entry(presolvers, &dns_resolvers, list) {
chunk_appendf(&trash, " valid: %ld\n", pnameserver->counters.valid); if (appctx->ctx.resolvers.ptr != NULL && appctx->ctx.resolvers.ptr != presolvers)
chunk_appendf(&trash, " update: %ld\n", pnameserver->counters.update); continue;
chunk_appendf(&trash, " cname: %ld\n", pnameserver->counters.cname);
chunk_appendf(&trash, " cname_error: %ld\n", pnameserver->counters.cname_error); chunk_appendf(&trash, "Resolvers section %s\n", presolvers->id);
chunk_appendf(&trash, " any_err: %ld\n", pnameserver->counters.any_err); list_for_each_entry(pnameserver, &presolvers->nameserver_list, list) {
chunk_appendf(&trash, " nx: %ld\n", pnameserver->counters.nx); chunk_appendf(&trash, " nameserver %s:\n", pnameserver->id);
chunk_appendf(&trash, " timeout: %ld\n", pnameserver->counters.timeout); chunk_appendf(&trash, " sent: %ld\n", pnameserver->counters.sent);
chunk_appendf(&trash, " refused: %ld\n", pnameserver->counters.refused); chunk_appendf(&trash, " valid: %ld\n", pnameserver->counters.valid);
chunk_appendf(&trash, " other: %ld\n", pnameserver->counters.other); chunk_appendf(&trash, " update: %ld\n", pnameserver->counters.update);
chunk_appendf(&trash, " invalid: %ld\n", pnameserver->counters.invalid); chunk_appendf(&trash, " cname: %ld\n", pnameserver->counters.cname);
chunk_appendf(&trash, " too_big: %ld\n", pnameserver->counters.too_big); chunk_appendf(&trash, " cname_error: %ld\n", pnameserver->counters.cname_error);
chunk_appendf(&trash, " truncated: %ld\n", pnameserver->counters.truncated); chunk_appendf(&trash, " any_err: %ld\n", pnameserver->counters.any_err);
chunk_appendf(&trash, " outdated: %ld\n", pnameserver->counters.outdated); chunk_appendf(&trash, " nx: %ld\n", pnameserver->counters.nx);
chunk_appendf(&trash, " timeout: %ld\n", pnameserver->counters.timeout);
chunk_appendf(&trash, " refused: %ld\n", pnameserver->counters.refused);
chunk_appendf(&trash, " other: %ld\n", pnameserver->counters.other);
chunk_appendf(&trash, " invalid: %ld\n", pnameserver->counters.invalid);
chunk_appendf(&trash, " too_big: %ld\n", pnameserver->counters.too_big);
chunk_appendf(&trash, " truncated: %ld\n", pnameserver->counters.truncated);
chunk_appendf(&trash, " outdated: %ld\n", pnameserver->counters.outdated);
}
}
} }
/* display response */ /* display response */