From: Willy Tarreau Date: Wed, 6 Jan 2016 14:49:26 +0000 (+0100) Subject: MEDIUM: stats: make stats_dump_li_stats() use stats fields for HTML dump X-Git-Tag: v1.7-dev2~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7e27230bda2d5b3d014b4767ca47cb50f1d4692;p=thirdparty%2Fhaproxy.git MEDIUM: stats: make stats_dump_li_stats() use stats fields for HTML dump The conversion still requires some elements which are not present in the current fields : - the HTML status may emit "WAITING"/"OPEN"/"FULL" while the CSV format doesn't propose "WAITING", so this last one will have to be added. - the HTML output emits the listening adresses when the ST_SHLGNDS flag is set but this address field doesn't exist in the CSV format - it's interesting to note that when the ST_SHLGNDS flag is not set, the HTML output doesn't provide the listener's ID while it's present in the CSV output accessible from the same interface. --- diff --git a/src/dumpstats.c b/src/dumpstats.c index d7691ffa0e..8c307e2348 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3463,9 +3463,9 @@ static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, st "%s" "%s" "", - px->id, l->name, + field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), (flags & ST_SHLGNDS)?"":"", - px->id, l->name, l->name); + field_str(stats, ST_F_PXNAME), field_str(stats, ST_F_SVNAME), field_str(stats, ST_F_SVNAME)); if (flags & ST_SHLGNDS) { char str[INET6_ADDRSTRLEN]; @@ -3490,7 +3490,7 @@ static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, st } /* id */ - chunk_appendf(&trash, "id: %d", l->luid); + chunk_appendf(&trash, "id: %d", stats[ST_F_SID].u.u32); } chunk_appendf(&trash, @@ -3505,8 +3505,8 @@ static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, st "%s%s" "", (flags & ST_SHLGNDS)?"":"", - U2H(l->nbconn), U2H(l->counters->conn_max), U2H(l->maxconn), - U2H(l->counters->cum_conn), U2H(l->counters->bytes_in), U2H(l->counters->bytes_out)); + U2H(stats[ST_F_SCUR].u.u32), U2H(stats[ST_F_SMAX].u.u32), U2H(stats[ST_F_SLIM].u.u32), + U2H(stats[ST_F_STOT].u.u64), U2H(stats[ST_F_BIN].u.u64), U2H(stats[ST_F_BOUT].u.u64)); chunk_appendf(&trash, /* denied: req, resp */ @@ -3520,9 +3520,9 @@ static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, st /* rest of server: nothing */ "" "", - U2H(l->counters->denied_req), U2H(l->counters->denied_resp), - U2H(l->counters->failed_req), - (l->nbconn < l->maxconn) ? (l->state == LI_LIMITED) ? "WAITING" : "OPEN" : "FULL"); + U2H(stats[ST_F_DREQ].u.u64), U2H(stats[ST_F_DRESP].u.u64), + U2H(stats[ST_F_EREQ].u.u64), + (stats[ST_F_SCUR].u.u32 < stats[ST_F_SLIM].u.u32) ? (l->state == LI_LIMITED) ? "WAITING" : "OPEN" : "FULL"); } else { /* CSV mode */ /* dump everything */