]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: support the "up" output modifier for "show stat"
authorWilly Tarreau <w@1wt.eu>
Fri, 23 Oct 2020 15:19:48 +0000 (17:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Oct 2020 16:11:24 +0000 (18:11 +0200)
We already had it on the HTTP interface but it was not accessible on the
CLI. It can be very convenient to hide servers which are down, do not
resolve, or are in maintenance.

doc/management.txt
src/stats.c

index a5fecffeb2057228bb246da707f02b45b20be15b..2411405613001f1688873eda2e9994322f008e0a 100644 (file)
@@ -2123,7 +2123,7 @@ show fd [<fd>]
   that the output format may evolve over time so this output must not be parsed
   by tools designed to be durable.
 
-show info [typed|json] [desc]
+show info [typed|json] [desc] [up]
   Dump info about haproxy status on current process. If "typed" is passed as an
   optional argument, field numbers, names and types are emitted as well so that
   external monitoring products can easily retrieve, possibly aggregate, then
@@ -2136,6 +2136,10 @@ show info [typed|json] [desc]
   format, the dump for a single object is contiguous so that there is no
   need for a consumer to store everything at once.
 
+  The "up" modifier will result in listing only servers which reportedly up or
+  not checked. Those down, unresolved, or in maintenance will not be listed.
+  This is analogous to the ";up" option on the HTTP stats.
+
   When using the typed output format, each line is made of 4 columns delimited
   by colons (':'). The first column is a dot-delimited series of 3 elements. The
   first element is the numeric position of the field in the list (starting at
index 033ed16e95eb56a2a447d70c019b3a87a5c46a1d..f6417b9f83360948c54ff19c2559c66b5e61a6cf 100644 (file)
@@ -4310,6 +4310,8 @@ static int cli_parse_show_stat(char **args, char *payload, struct appctx *appctx
                        appctx->ctx.stats.flags = (appctx->ctx.stats.flags & ~STAT_FMT_MASK) | STAT_FMT_JSON;
                else if (strcmp(args[arg], "desc") == 0)
                        appctx->ctx.stats.flags |= STAT_SHOW_FDESC;
+               else if (strcmp(args[arg], "up") == 0)
+                       appctx->ctx.stats.flags |= STAT_HIDE_DOWN;
                arg++;
        }
 
@@ -4502,7 +4504,7 @@ REGISTER_CONFIG_POSTPARSER("allocate-stats-dns", allocate_stats_dns_postcheck);
 static struct cli_kw_list cli_kws = {{ },{
        { { "clear", "counters",  NULL }, "clear counters : clear max statistics counters (add 'all' for all counters)", cli_parse_clear_counters, NULL, NULL },
        { { "show", "info",  NULL }, "show info      : report information about the running process [desc|json|typed]*", cli_parse_show_info, cli_io_handler_dump_info, NULL },
-       { { "show", "stat",  NULL }, "show stat      : report counters for each proxy and server [desc|json|typed]*", cli_parse_show_stat, cli_io_handler_dump_stat, NULL },
+       { { "show", "stat",  NULL }, "show stat      : report counters for each proxy and server [desc|json|typed|up]*", cli_parse_show_stat, cli_io_handler_dump_stat, NULL },
        { { "show", "schema",  "json", NULL }, "show schema json : report schema used for stats", NULL, cli_io_handler_dump_json_schema, NULL },
        {{},}
 }};