From 0deb85acd1ef242f145629c60a5fdc32aabb255e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 8 Jan 2016 15:33:18 +0100 Subject: [PATCH] MEDIUM: stats: expose the same flags for CLI and HTTP accesses 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dumpstats.c b/src/dumpstats.c index 3fe6c5016f..90b1b11955 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -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; -- 2.47.3