]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: set the appctx flags when initializing the applet only
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Oct 2019 09:00:22 +0000 (11:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Oct 2019 09:30:07 +0000 (11:30 +0200)
When "show stat" is emitted on the CLI, we need to set the relevant
flags on the appctx. We must not re-adjust them while dumping a proxy.

src/stats.c

index 7063ad0f05e93caf0b25cc25e1d1baa47dc4e77b..afa2e305f899ad8d65659560d4c8aa86924c6c44 100644 (file)
@@ -2084,14 +2084,6 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
        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 = appctx->ctx.stats.flags;
-       else if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER)
-               flags = STAT_SHLGNDS | STAT_SHNODE | STAT_SHDESC;
-       else
-               flags = STAT_SHNODE | STAT_SHDESC;
 
        chunk_reset(&trash);
 
@@ -2186,7 +2178,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
                        }
 
                        /* print the frontend */
-                       if (stats_dump_li_stats(si, px, l, flags)) {
+                       if (stats_dump_li_stats(si, px, l, appctx->ctx.stats.flags)) {
                                if (!stats_putchk(rep, htx, &trash))
                                        goto full;
                        }
@@ -2232,7 +2224,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
                                continue;
                        }
 
-                       if (stats_dump_sv_stats(si, px, flags, sv)) {
+                       if (stats_dump_sv_stats(si, px, appctx->ctx.stats.flags, sv)) {
                                if (!stats_putchk(rep, htx, &trash))
                                        goto full;
                        }
@@ -2243,7 +2235,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
 
        case STAT_PX_ST_BE:
                /* print the backend */
-               if (stats_dump_be_stats(si, px, flags)) {
+               if (stats_dump_be_stats(si, px, appctx->ctx.stats.flags)) {
                        if (!stats_putchk(rep, htx, &trash))
                                goto full;
                }
@@ -3812,7 +3804,10 @@ static int cli_parse_show_stat(char **args, char *payload, struct appctx *appctx
 {
        appctx->ctx.stats.scope_str = 0;
        appctx->ctx.stats.scope_len = 0;
-       appctx->ctx.stats.flags = 0;
+       appctx->ctx.stats.flags = STAT_SHNODE | STAT_SHDESC;
+
+       if ((strm_li(si_strm(appctx->owner))->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER)
+               appctx->ctx.stats.flags |= STAT_SHLGNDS;
 
        if (*args[2] && *args[3] && *args[4]) {
                struct proxy *px;