From: Willy Tarreau Date: Fri, 30 Nov 2007 17:16:29 +0000 (+0100) Subject: [MINOR] stats: report the server warm up status in a "throttle" column X-Git-Tag: v1.3.14~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bab24d955a60a698d3c8422df8742f54c209522;p=thirdparty%2Fhaproxy.git [MINOR] stats: report the server warm up status in a "throttle" column A new "throttle" column has been added to HTML and RAW stats to indicate in percent, the level of throttling due to server warmup. The column is empty at 100%. --- diff --git a/src/dumpstats.c b/src/dumpstats.c index 388a5f7ace..7454600f4b 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -153,6 +153,22 @@ int stats_parse_global(const char **args, char *err, int errlen) return 0; } +int print_csv_header(struct chunk *msg, int size) +{ + return chunk_printf(msg, size, + "# pxname,svname," + "qcur,qmax," + "scur,smax,slim,stot," + "bin,bout," + "dreq,dresp," + "ereq,econ,eresp," + "wretr,wredis," + "status,weight,act,bck," + "chkfail,chkdown,lastchg,downtime,qlimit," + "pid,iid,sid,throttle," + "\n"); +} + /* * Produces statistics data for the session . Expects to be called with * s->cli_state == CL_STSHUTR. It *may* make use of informations from @@ -179,19 +195,7 @@ int stats_dump_raw(struct session *s, struct uri_auth *uri, int flags) /* fall through */ case DATA_ST_HEAD: - chunk_printf(&msg, sizeof(trash), - "# pxname,svname," - "qcur,qmax," - "scur,smax,slim,stot," - "bin,bout," - "dreq,dresp," - "ereq,econ,eresp," - "wretr,wredis," - "status,weight,act,bck," - "chkfail,chkdown,lastchg,downtime,qlimit," - "pid,iid,sid," - "\n"); - + print_csv_header(&msg, sizeof(trash)); if (buffer_write_chunk(rep, &msg) != 0) return 0; @@ -369,18 +373,7 @@ int stats_dump_http(struct session *s, struct uri_auth *uri, int flags) "-->\n" "\n"); } else { - chunk_printf(&msg, sizeof(trash), - "# pxname,svname," - "qcur,qmax," - "scur,smax,slim,stot," - "bin,bout," - "dreq,dresp," - "ereq,econ,eresp," - "wretr,wredis," - "status,weight,act,bck," - "chkfail,chkdown,lastchg,downtime,qlimit," - "pid,iid,sid," - "\n"); + print_csv_header(&msg, sizeof(trash)); } if (buffer_write_chunk(rep, &msg) != 0) return 0; @@ -590,17 +583,17 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, if (flags & STAT_FMT_HTML) { /* print a new table */ chunk_printf(&msg, sizeof(trash), - "\n" + "
\n" "" "" - "" + "" "\n" "" "" "" "" "" - "" + "" "\n" "" "" @@ -608,7 +601,8 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, "" "" "" - "\n" + "" + "\n" "", px->id); @@ -640,7 +634,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, /* server status : reflect frontend status */ "" /* rest of server: nothing */ - "" + "" "", px->feconn, px->feconn_max, px->maxconn, px->cum_feconn, px->bytes_in, px->bytes_out, @@ -666,8 +660,8 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, "%s," /* rest of server: nothing */ ",,,,,,,," - /* pid, iid, sid, */ - "%d,%d,0," + /* pid, iid, sid, throttle, */ + "%d,%d,0,," "\n", px->id, px->feconn, px->feconn_max, px->maxconn, px->cum_feconn, @@ -776,12 +770,25 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, chunk_printf(&msg, sizeof(trash), "" "" - "\n", + "", sv->failed_checks, sv->down_trans, human_time(srv_downtime(sv), 1)); else chunk_printf(&msg, sizeof(trash), - "\n"); + ""); + + /* throttle */ + if ((sv->state & SRV_WARMINGUP) && + now.tv_sec < sv->last_change + sv->slowstart && + now.tv_sec >= sv->last_change) { + unsigned int ratio; + ratio = MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart); + chunk_printf(&msg, sizeof(trash), + "\n", ratio); + } else { + chunk_printf(&msg, sizeof(trash), + "\n"); + } } else { static char *srv_hlt_st[7] = { "DOWN,", "DOWN %d/%d,", "UP %d/%d,", "UP,", @@ -835,13 +842,24 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, chunk_printf(&msg, sizeof(trash), ",,,,"); - /* queue limit, pid, iid, sid and EOL */ + /* queue limit, pid, iid, sid, */ chunk_printf(&msg, sizeof(trash), "%s," - "%d,%d,%d," - "\n", + "%d,%d,%d,", LIM2A0(sv->maxqueue, ""), relative_pid, px->uuid, sv->puid); + + /* throttle */ + if ((sv->state & SRV_WARMINGUP) && + now.tv_sec < sv->last_change + sv->slowstart && + now.tv_sec >= sv->last_change) { + unsigned int ratio; + ratio = MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart); + chunk_printf(&msg, sizeof(trash), "%d", ratio); + } + + /* ',' then EOL */ + chunk_printf(&msg, sizeof(trash), ",\n"); } if (buffer_write_chunk(rep, &msg) != 0) return 0; @@ -890,9 +908,10 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, px->srv_act, px->srv_bck); chunk_printf(&msg, sizeof(trash), - /* rest of backend: nothing, down transformations, total downtime */ + /* rest of backend: nothing, down transitions, total downtime, throttle */ "" "" + "" "", px->down_trans, px->srv?human_time(be_downtime(px), 1):" "); @@ -918,11 +937,10 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri, * active and backups. */ "%s," "%d,%d,%d," - /* rest of backend: nothing, down transformations, - * last change, total downtime. */ + /* rest of backend: nothing, down transitions, last change, total downtime */ ",%d,%d,%d,," - /* pid, iid, sid, */ - "%d,%d,0," + /* pid, iid, sid, throttle, */ + "%d,%d,0,," "\n", px->id, px->nbpend /* or px->totpend ? */, px->nbpend_max,
%s
QueueSessionsBytesDeniedErrorsWarningsServerServer
CurMaxLimitCurMaxReqRespReqConnRespRetrRedisStatusWghtActBckChkDwnDwntmeBckChkDwnDwntmeThrtle
%s
%d%d%s
%d %%
-
 %d%s