From c73810f94f5760f68ba6a6d1e3a6ff8ec7cadc7f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 11 Jan 2016 13:52:04 +0100 Subject: [PATCH] MINOR: stats: add 3 fields to report the frontend-specific connection stats Frontends have extra information compared to other entities, they can report some statistics at the connection level while the other ones are limited to the session level. This patch adds 3 more fields for this : - conn_rate - conn_rate_max - conn_tot It's worth noting that listeners theorically have such statistics, except that the distinction between connections and sessions is not clearly made in the code, so that will have to be improved later. --- doc/management.txt | 5 ++++- src/dumpstats.c | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/management.txt b/doc/management.txt index 5edfaab9c..5e1fa3c57 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -899,7 +899,7 @@ S (Servers). 4. scur [LFBS]: current sessions 5. smax [LFBS]: max sessions 6. slim [LFBS]: configured session limit - 7. stot [LFBS]: cumulative number of connections + 7. stot [LFBS]: cumulative number of sessions 8. bin [LFBS]: bytes in 9. bout [LFBS]: bytes out 10. dreq [LFB.]: requests denied because of security concerns. @@ -1026,6 +1026,9 @@ S (Servers). 74: cookie [..BS]: server's cookie value or backend's cookie name 75: mode [LFBS]: proxy mode (tcp, http, health, unknown) 76: algo [..B.]: load balancing algorithm + 77: conn_rate [.F..]: number of connections over the last elapsed second + 78: conn_rate_max [.F..]: highest known conn_rate + 79: conn_tot [.F..]: cumulative number of connections 9.2. Unix Socket commands diff --git a/src/dumpstats.c b/src/dumpstats.c index 386c46440..e61bf0e31 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -337,6 +337,9 @@ enum stat_field { ST_F_COOKIE, ST_F_MODE, ST_F_ALGO, + ST_F_CONN_RATE, + ST_F_CONN_RATE_MAX, + ST_F_CONN_TOT, /* must always be the last one */ ST_F_TOTAL_FIELDS @@ -424,6 +427,9 @@ const char *stat_field_names[ST_F_TOTAL_FIELDS] = { [ST_F_COOKIE] = "cookie", [ST_F_MODE] = "mode", [ST_F_ALGO] = "algo", + [ST_F_CONN_RATE] = "conn_rate", + [ST_F_CONN_RATE_MAX] = "conn_rate_max", + [ST_F_CONN_TOT] = "conn_tot", }; /* one line of stats */ @@ -3285,7 +3291,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned "Current session rate:%s/s" "", U2H(stats[ST_F_RATE].u.u32), - U2H(read_freq_ctr(&px->fe_conn_per_sec)), + U2H(stats[ST_F_CONN_RATE].u.u32), U2H(stats[ST_F_RATE].u.u32)); if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) @@ -3301,7 +3307,7 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned "Max session rate:%s/s" "", U2H(stats[ST_F_RATE_MAX].u.u32), - U2H(px->fe_counters.cps_max), + U2H(stats[ST_F_CONN_RATE_MAX].u.u32), U2H(stats[ST_F_RATE_MAX].u.u32)); if (strcmp(field_str(stats, ST_F_MODE), "http") == 0) @@ -3322,9 +3328,9 @@ static int stats_dump_fields_html(const struct field *stats, int admin, unsigned "Cum. connections:%s" "Cum. sessions:%s" "", - U2H(stats[ST_F_SCUR].u.u32), U2H(px->fe_counters.conn_max), U2H(stats[ST_F_SLIM].u.u32), + 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(px->fe_counters.cum_conn), + U2H(stats[ST_F_CONN_TOT].u.u64), U2H(stats[ST_F_STOT].u.u64)); /* http response (via hover): 1xx, 2xx, 3xx, 4xx, 5xx, other */ @@ -3947,6 +3953,11 @@ static int stats_dump_fe_stats(struct stream_interface *si, struct proxy *px) stats[ST_F_COMP_BYP] = mkf_u64(FN_COUNTER, px->fe_counters.comp_byp); stats[ST_F_COMP_RSP] = mkf_u64(FN_COUNTER, px->fe_counters.p.http.comp_rsp); + /* connections : conn_rate, conn_rate_max, conn_tot, conn_max */ + stats[ST_F_CONN_RATE] = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_conn_per_sec)); + stats[ST_F_CONN_RATE_MAX] = mkf_u32(FN_MAX, px->fe_counters.cps_max); + stats[ST_F_CONN_TOT] = mkf_u64(FN_COUNTER, px->fe_counters.cum_conn); + if (appctx->ctx.stats.flags & STAT_FMT_HTML) { int admin;