From: Willy Tarreau Date: Fri, 8 Jan 2016 14:33:18 +0000 (+0100) Subject: MEDIUM: stats: expose the same flags for CLI and HTTP accesses X-Git-Tag: v1.7-dev2~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0deb85acd1ef242f145629c60a5fdc32aabb255e;p=thirdparty%2Fhaproxy.git 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. --- 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;