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.
This commit is contained in:
Willy Tarreau 2016-11-25 08:50:58 +01:00
parent b5cff60ef5
commit a1b1ed53e7
2 changed files with 18 additions and 3 deletions

View File

@ -1957,12 +1957,14 @@ show sess <id>
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 [<iid> <type> <sid>] [typed]
show stat [{<iid>|<proxy>} <type> <sid>] [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 <id>, <type> and <sid>, it is possible to dump only
selected items :
- <iid> is a proxy ID, -1 to dump everything
- <iid> is a proxy ID, -1 to dump everything. Alternatively, a proxy name
<proxy> may be specified. In this case, this proxy's ID will be used as
the ID selector.
- <type> 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:

View File

@ -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)