]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stats: expose the same flags for CLI and HTTP accesses
authorWilly Tarreau <w@1wt.eu>
Fri, 8 Jan 2016 14:33:18 +0000 (15:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Mar 2016 16:08:05 +0000 (17:08 +0100)
The HTML dump over HTTP request may have several flags including
ST_SHLGNDS (to show legends), ST_SHNODE (to show node name),
ST_SHDESC (to show some descriptions).

There's no such thing over the CLI so we need to have an equivalent.
Let's compute the flags earlier so that we can make use of these flags
regardless of the call point.

src/dumpstats.c

index 3fe6c5016f73cf657b5d5cd4ff10e09be7467b6c..90b1b11955ac903264647bda0cd83566ce9123d9 100644 (file)
@@ -4441,6 +4441,14 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
        struct channel *rep = si_ic(si);
        struct server *sv, *svs;        /* server and server-state, server-state=server or server->track */
        struct listener *l;
+       unsigned int flags;
+
+       if (uri)
+               flags = uri->flags;
+       else if (strm_li(s)->bind_conf->level >= ACCESS_LVL_OPER)
+               flags = ST_SHLGNDS | ST_SHNODE | ST_SHDESC;
+       else
+               flags = ST_SHNODE | ST_SHDESC;
 
        chunk_reset(&trash);
 
@@ -4532,7 +4540,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
                        }
 
                        /* print the frontend */
-                       if (stats_dump_li_stats(si, px, l, uri ? uri->flags : 0)) {
+                       if (stats_dump_li_stats(si, px, l, flags)) {
                                if (bi_putchk(rep, &trash) == -1) {
                                        si_applet_cant_put(si);
                                        return 0;
@@ -4576,7 +4584,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
                                continue;
                        }
 
-                       if (stats_dump_sv_stats(si, px, uri ? uri->flags : 0, sv)) {
+                       if (stats_dump_sv_stats(si, px, flags, sv)) {
                                if (bi_putchk(rep, &trash) == -1) {
                                        si_applet_cant_put(si);
                                        return 0;
@@ -4589,7 +4597,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
 
        case STAT_PX_ST_BE:
                /* print the backend */
-               if (stats_dump_be_stats(si, px, uri ? uri->flags : 0)) {
+               if (stats_dump_be_stats(si, px, flags)) {
                        if (bi_putchk(rep, &trash) == -1) {
                                si_applet_cant_put(si);
                                return 0;