From: Willy Tarreau Date: Mon, 11 Jan 2016 13:09:38 +0000 (+0100) Subject: MEDIUM: stats: add a new "mode" column to report the proxy mode X-Git-Tag: v1.7-dev2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8211dff8973b6af285d057794d50f03579c13c2;p=thirdparty%2Fhaproxy.git MEDIUM: stats: add a new "mode" column to report the proxy mode Now even CSV stats will see the proxy mode, and we can save the HTML stats dumps from accessing px->mode directly. --- diff --git a/doc/management.txt b/doc/management.txt index 8ce8e6a390..83c7a34397 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1024,6 +1024,7 @@ S (Servers). 72. agent_health [...S]: agent's health parameter, between 0 and rise+fall-1 73. addr [L..S]: address:port or "unix". IPv6 has brackets around the address. 74: cookie [..BS]: server's cookie value or backend's cookie name + 75: mode [LFBS]: proxy mode (tcp, http, health, unknown) 9.2. Unix Socket commands diff --git a/src/dumpstats.c b/src/dumpstats.c index 6b7d32e527..504bba1de8 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -335,6 +335,7 @@ enum stat_field { ST_F_AGENT_HEALTH, ST_F_ADDR, ST_F_COOKIE, + ST_F_MODE, /* must always be the last one */ ST_F_TOTAL_FIELDS @@ -420,6 +421,7 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = { [ST_F_AGENT_HEALTH] = "agent_health", [ST_F_ADDR] = "addr", [ST_F_COOKIE] = "cookie", + [ST_F_MODE] = "mode", }; /* one line of stats */ @@ -3284,7 +3286,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned U2H(read_freq_ctr(&px->fe_conn_per_sec)), U2H(stats[ST_F_RATE].u.u32)); - if (px->mode == PR_MODE_HTTP) + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) chunk_appendf(&trash, "Current request rate:%s/s", U2H(stats[ST_F_REQ_RATE].u.u32)); @@ -3300,7 +3302,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned U2H(px->fe_counters.cps_max), U2H(stats[ST_F_RATE_MAX].u.u32)); - if (px->mode == PR_MODE_HTTP) + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) chunk_appendf(&trash, "Max request rate:%s/s", U2H(stats[ST_F_REQ_RATE_MAX].u.u32)); @@ -3324,7 +3326,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned U2H(stats[ST_F_STOT].u.u64)); /* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */ - if (px->mode == PR_MODE_HTTP) { + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) { chunk_appendf(&trash, "Cum. HTTP requests:%s" "- HTTP 1xx responses:%s" @@ -3559,7 +3561,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned U2H(stats[ST_F_STOT].u.u64)); /* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */ - if (px->mode == PR_MODE_HTTP) { + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) { unsigned long long tot; tot = stats[ST_F_HRSP_OTHER].u.u64; @@ -3590,7 +3592,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned chunk_appendf(&trash, "Avg over last 1024 success. conn."); chunk_appendf(&trash, "- Queue time:%sms", U2H(stats[ST_F_QTIME].u.u32)); chunk_appendf(&trash, "- Connect time:%sms", U2H(stats[ST_F_CTIME].u.u32)); - if (px->mode == PR_MODE_HTTP) + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) chunk_appendf(&trash, "- Response time:%sms", U2H(stats[ST_F_RTIME].u.u32)); chunk_appendf(&trash, "- Total time:%sms", U2H(stats[ST_F_TTIME].u.u32)); @@ -3783,7 +3785,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned U2H(stats[ST_F_STOT].u.u64)); /* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */ - if (px->mode == PR_MODE_HTTP) { + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) { chunk_appendf(&trash, "Cum. HTTP requests:%s" "- HTTP 1xx responses:%s" @@ -3811,7 +3813,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned chunk_appendf(&trash, "- Queue time:%sms", U2H(stats[ST_F_QTIME].u.u32)); chunk_appendf(&trash, "- Connect time:%sms", U2H(stats[ST_F_QTIME].u.u32)); - if (px->mode == PR_MODE_HTTP) + if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) chunk_appendf(&trash, "- Response time:%sms", U2H(stats[ST_F_RTIME].u.u32)); chunk_appendf(&trash, "- Total time:%sms", U2H(stats[ST_F_TTIME].u.u32)); @@ -3903,6 +3905,7 @@ static int stats_dump_fe_stats(struct stream_interface *si, struct proxy *px) stats[ST_F_PXNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, px->id); stats[ST_F_SVNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, "FRONTEND"); + stats[ST_F_MODE] = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode)); stats[ST_F_SCUR] = mkf_u32(0, px->feconn); stats[ST_F_SMAX] = mkf_u32(FN_MAX, px->fe_counters.conn_max); stats[ST_F_SLIM] = mkf_u32(FO_CONFIG|FN_LIMIT, px->maxconn); @@ -3970,6 +3973,7 @@ static int stats_dump_li_stats(struct stream_interface *si, struct proxy *px, st stats[ST_F_PXNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, px->id); stats[ST_F_SVNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, l->name); + stats[ST_F_MODE] = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode)); stats[ST_F_SCUR] = mkf_u32(0, l->nbconn); stats[ST_F_SMAX] = mkf_u32(FN_MAX, l->counters->conn_max); stats[ST_F_SLIM] = mkf_u32(FO_CONFIG|FN_LIMIT, l->maxconn); @@ -4121,6 +4125,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in stats[ST_F_PXNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, px->id); stats[ST_F_SVNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, sv->id); + stats[ST_F_MODE] = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode)); stats[ST_F_QCUR] = mkf_u32(0, sv->nbpend); stats[ST_F_QMAX] = mkf_u32(FN_MAX, sv->counters.nbpend_max); stats[ST_F_SCUR] = mkf_u32(0, sv->cur_sess); @@ -4310,6 +4315,7 @@ static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px, in stats[ST_F_PXNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, px->id); stats[ST_F_SVNAME] = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, "BACKEND"); + stats[ST_F_MODE] = mkf_str(FO_CONFIG|FS_SERVICE, proxy_mode_str(px->mode)); stats[ST_F_QCUR] = mkf_u32(0, px->nbpend); stats[ST_F_QMAX] = mkf_u32(FN_MAX, px->be_counters.nbpend_max); stats[ST_F_SCUR] = mkf_u32(FO_CONFIG|FN_LIMIT, px->beconn);