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

index f42c0712012e586a18bd02c382409671bb43f4d9..04b0d40f56f0bf1d0148be241eabf2babfe94689 100644 (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:
index 1d5b39c271f9c2fea2da2bb35f2b464ab72063b4..bfd16994d6d29396a0fcac4dfd3d4f3c047d5c99 100644 (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)