From: Willy Tarreau Date: Thu, 23 May 2019 10:23:55 +0000 (+0200) Subject: MINOR: stats: report the global output bit rate in human readable form X-Git-Tag: v2.0-dev5~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1713c03825668ad53f490cd110332627630208d3;p=thirdparty%2Fhaproxy.git MINOR: stats: report the global output bit rate in human readable form The stats page now reports the per-process output bit rate and applies the usual conversions needed to turn the TCP payload rate to an Ethernet bit rate in order to give a reasonably accurate estimate of how far from interface saturation we are. --- diff --git a/src/stats.c b/src/stats.c index cba9ffcd53..de7f856672 100644 --- a/src/stats.c +++ b/src/stats.c @@ -2381,6 +2381,18 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u unsigned int up = (now.tv_sec - start_date.tv_sec); char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN]; const char *scope_ptr = stats_scope_ptr(appctx, si); + unsigned long long bps = (unsigned long long)read_freq_ctr(&global.out_32bps) * 32; + + /* Turn the bytes per second to bits per second and take care of the + * usual ethernet overhead in order to help figure how far we are from + * interface saturation since it's the only case which usually matters. + * For this we count the total size of an Ethernet frame on the wire + * including preamble and IFG (1538) for the largest TCP segment it + * transports (1448 with TCP timestamps). This is not valid for smaller + * packets (under-estimated), but it gives a reasonably accurate + * estimation of how far we are from uplink saturation. + */ + bps = bps * 8 * 1538 / 1448; /* WARNING! this has to fit the first packet too. * We are around 3.5 kB, add adding entries will @@ -2397,7 +2409,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u "uptime = %dd %dh%02dm%02ds
\n" "system limits: memmax = %s%s; ulimit-n = %d
\n" "maxsock = %d; maxconn = %d; maxpipes = %d
\n" - "current conns = %d; current pipes = %d/%d; conn rate = %d/sec
\n" + "current conns = %d; current pipes = %d/%d; conn rate = %d/sec; bit rate = %.3f %cbps
\n" "Running tasks: %d/%d; idle = %d %%
\n" "\n" "\n" @@ -2435,6 +2447,8 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u global.rlimit_nofile, global.maxsock, global.maxconn, global.maxpipes, actconn, pipes_used, pipes_used+pipes_free, read_freq_ctr(&global.conn_per_sec), + bps >= 1000000000UL ? (bps / 1000000000.0) : bps >= 1000000UL ? (bps / 1000000.0) : (bps / 1000.0), + bps >= 1000000000UL ? 'G' : bps >= 1000000UL ? 'M' : 'k', tasks_run_queue_cur, nb_tasks_cur, ti->idle_pct );