]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: make "show errors" support a proxy name
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Nov 2016 07:39:10 +0000 (08:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Nov 2016 07:56:55 +0000 (08:56 +0100)
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.

doc/management.txt
src/proto_http.c

index 04b0d40f56f0bf1d0148be241eabf2babfe94689..0bfefcd98731fdc12766ec1f259deabd9dd9bbe2 100644 (file)
@@ -1684,12 +1684,13 @@ show env [<name>]
   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 [<iid>]
+show errors [<iid>|<proxy>]
   Dump last known request and response errors collected by frontends and
   backends. If <iid> is specified, the limit the dump to errors concerning
-  either frontend or backend whose ID is <iid>. This command is restricted
-  and can only be issued on sockets configured for levels "operator" or
-  "admin".
+  either frontend or backend whose ID is <iid>. 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
index 6dfc8f9c9de942e6f86c5541b3f08f7c116a9c7f..e0459c23e291597d083231eef8a996064ac87efc 100644 (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))
                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;
 }