From: Willy Tarreau Date: Fri, 25 Nov 2016 07:39:10 +0000 (+0100) Subject: MINOR: cli: make "show errors" support a proxy name X-Git-Tag: v1.7.0~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=234ba2d8eb56354a882f5544d6d0cfe225410ba9;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/doc/management.txt b/doc/management.txt index 04b0d40f56..0bfefcd987 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1684,12 +1684,13 @@ show env [] ensure that they contain the expected values. This command is restricted and can only be issued on sockets configured for levels "operator" or "admin". -show errors [] +show errors [|] Dump last known request and response errors collected by frontends and backends. If is specified, the limit the dump to errors concerning - either frontend or backend whose ID is . This command is restricted - and can only be issued on sockets configured for levels "operator" or - "admin". + either frontend or backend whose ID is . Proxy ID "-1" will cause + all instances to be dumped. If a proxy name is specified instead, its ID + 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 caused by protocol violations, often due to invalid characters in header diff --git a/src/proto_http.c b/src/proto_http.c index 6dfc8f9c9d..e0459c23e2 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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)) return 1; - if (*args[2]) - appctx->ctx.errors.iid = atoi(args[2]); + if (*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 - appctx->ctx.errors.iid = -1; + appctx->ctx.errors.iid = -1; // dump all proxies + appctx->ctx.errors.px = NULL; return 0; }