From: Willy Tarreau Date: Fri, 25 Nov 2016 07:50:58 +0000 (+0100) Subject: MINOR: cli: make "show stat" support a proxy name X-Git-Tag: v1.7.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1b1ed53e7d58c927a6fd6bb6629bb7bbbea233c;p=thirdparty%2Fhaproxy.git MINOR: cli: make "show stat" support a proxy name Till now it was needed to know the proxy's ID while we do have the ability to look up a proxy by its name now. --- diff --git a/doc/management.txt b/doc/management.txt index f42c071201..04b0d40f56 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1957,12 +1957,14 @@ show sess The special id "all" dumps the states of all sessions, which must be avoided as much as possible as it is highly CPU intensive and can take a lot of time. -show stat [ ] [typed] +show stat [{|} ] [typed] Dump statistics using the CSV format, or using the extended typed output format described in the section above if "typed" is passed after the other arguments. By passing , and , it is possible to dump only selected items : - - is a proxy ID, -1 to dump everything + - is a proxy ID, -1 to dump everything. Alternatively, a proxy name + may be specified. In this case, this proxy's ID will be used as + the ID selector. - selects the type of dumpable objects : 1 for frontends, 2 for backends, 4 for servers, -1 for everything. These values can be ORed, for example: diff --git a/src/stats.c b/src/stats.c index 1d5b39c271..bfd16994d6 100644 --- a/src/stats.c +++ b/src/stats.c @@ -3103,8 +3103,21 @@ static int cli_parse_show_info(char **args, struct appctx *appctx, void *private static int cli_parse_show_stat(char **args, struct appctx *appctx, void *private) { if (*args[2] && *args[3] && *args[4]) { + struct proxy *px; + + px = proxy_find_by_name(args[2], 0, 0); + if (px) + appctx->ctx.stats.iid = px->uuid; + else + appctx->ctx.stats.iid = atoi(args[2]); + + if (!appctx->ctx.stats.iid) { + appctx->ctx.cli.msg = "No such proxy.\n"; + appctx->st0 = CLI_ST_PRINT; + return 1; + } + appctx->ctx.stats.flags |= STAT_BOUND; - appctx->ctx.stats.iid = atoi(args[2]); appctx->ctx.stats.type = atoi(args[3]); appctx->ctx.stats.sid = atoi(args[4]); if (strcmp(args[5], "typed") == 0)