MINOR: cli: make "show errors" 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:39:10 +01:00
parent a1b1ed53e7
commit 234ba2d8eb
2 changed files with 22 additions and 7 deletions

View File

@ -1684,12 +1684,13 @@ show env [<name>]
ensure that they contain the expected values. This command is restricted and ensure that they contain the expected values. This command is restricted and
can only be issued on sockets configured for levels "operator" or "admin". can only be issued on sockets configured for levels "operator" or "admin".
show errors [<iid>] show errors [<iid>|<proxy>]
Dump last known request and response errors collected by frontends and Dump last known request and response errors collected by frontends and
backends. If <iid> is specified, the limit the dump to errors concerning backends. If <iid> is specified, the limit the dump to errors concerning
either frontend or backend whose ID is <iid>. This command is restricted either frontend or backend whose ID is <iid>. Proxy ID "-1" will cause
and can only be issued on sockets configured for levels "operator" or all instances to be dumped. If a proxy name is specified instead, its ID
"admin". will be used as the filter. This command is restricted and can only be
issued on sockets configured for levels "operator" or "admin".
The errors which may be collected are the last request and response errors The errors which may be collected are the last request and response errors
caused by protocol violations, often due to invalid characters in header caused by protocol violations, often due to invalid characters in header

View File

@ -12907,10 +12907,24 @@ static int cli_parse_show_errors(char **args, struct appctx *appctx, void *priva
if (!cli_has_level(appctx, ACCESS_LVL_OPER)) if (!cli_has_level(appctx, ACCESS_LVL_OPER))
return 1; return 1;
if (*args[2]) if (*args[2]) {
appctx->ctx.errors.iid = atoi(args[2]); struct proxy *px;
px = proxy_find_by_name(args[2], 0, 0);
if (px)
appctx->ctx.errors.iid = px->uuid;
else
appctx->ctx.errors.iid = atoi(args[2]);
if (!appctx->ctx.errors.iid) {
appctx->ctx.cli.msg = "No such proxy.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
}
else else
appctx->ctx.errors.iid = -1; appctx->ctx.errors.iid = -1; // dump all proxies
appctx->ctx.errors.px = NULL; appctx->ctx.errors.px = NULL;
return 0; return 0;
} }