[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%.
This commit is contained in:
Willy Tarreau 2007-11-30 18:16:29 +01:00
parent 5764b38c38
commit 4bab24d955

View File

@ -153,6 +153,22 @@ int stats_parse_global(const char **args, char *err, int errlen)
return 0; 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 <s>. Expects to be called with * Produces statistics data for the session <s>. Expects to be called with
* s->cli_state == CL_STSHUTR. It *may* make use of informations from <uri> * s->cli_state == CL_STSHUTR. It *may* make use of informations from <uri>
@ -179,19 +195,7 @@ int stats_dump_raw(struct session *s, struct uri_auth *uri, int flags)
/* fall through */ /* fall through */
case DATA_ST_HEAD: case DATA_ST_HEAD:
chunk_printf(&msg, sizeof(trash), print_csv_header(&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");
if (buffer_write_chunk(rep, &msg) != 0) if (buffer_write_chunk(rep, &msg) != 0)
return 0; return 0;
@ -369,18 +373,7 @@ int stats_dump_http(struct session *s, struct uri_auth *uri, int flags)
"-->\n" "-->\n"
"</style></head>\n"); "</style></head>\n");
} else { } else {
chunk_printf(&msg, sizeof(trash), print_csv_header(&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");
} }
if (buffer_write_chunk(rep, &msg) != 0) if (buffer_write_chunk(rep, &msg) != 0)
return 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) { if (flags & STAT_FMT_HTML) {
/* print a new table */ /* print a new table */
chunk_printf(&msg, sizeof(trash), chunk_printf(&msg, sizeof(trash),
"<table cols=\"24\" class=\"tbl\" width=\"100%%\">\n" "<table cols=\"25\" class=\"tbl\" width=\"100%%\">\n"
"<tr align=\"center\" class=\"titre\">" "<tr align=\"center\" class=\"titre\">"
"<th colspan=2 class=\"pxname\">%s</th>" "<th colspan=2 class=\"pxname\">%s</th>"
"<th colspan=21 class=\"empty\"></th>" "<th colspan=22 class=\"empty\"></th>"
"</tr>\n" "</tr>\n"
"<tr align=\"center\" class=\"titre\">" "<tr align=\"center\" class=\"titre\">"
"<th rowspan=2></th>" "<th rowspan=2></th>"
"<th colspan=3>Queue</th><th colspan=4>Sessions</th>" "<th colspan=3>Queue</th><th colspan=4>Sessions</th>"
"<th colspan=2>Bytes</th><th colspan=2>Denied</th>" "<th colspan=2>Bytes</th><th colspan=2>Denied</th>"
"<th colspan=3>Errors</th><th colspan=2>Warnings</th>" "<th colspan=3>Errors</th><th colspan=2>Warnings</th>"
"<th colspan=7>Server</th>" "<th colspan=8>Server</th>"
"</tr>\n" "</tr>\n"
"<tr align=\"center\" class=\"titre\">" "<tr align=\"center\" class=\"titre\">"
"<th>Cur</th><th>Max</th><th>Limit</th><th>Cur</th><th>Max</th>" "<th>Cur</th><th>Max</th><th>Limit</th><th>Cur</th><th>Max</th>"
@ -608,7 +601,8 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
"<th>Req</th><th>Resp</th><th>Req</th><th>Conn</th>" "<th>Req</th><th>Resp</th><th>Req</th><th>Conn</th>"
"<th>Resp</th><th>Retr</th><th>Redis</th>" "<th>Resp</th><th>Retr</th><th>Redis</th>"
"<th>Status</th><th>Wght</th><th>Act</th>" "<th>Status</th><th>Wght</th><th>Act</th>"
"<th>Bck</th><th>Chk</th><th>Dwn</th><th>Dwntme</th>\n" "<th>Bck</th><th>Chk</th><th>Dwn</th><th>Dwntme</th>"
"<th>Thrtle</th>\n"
"</tr>", "</tr>",
px->id); 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 */ /* server status : reflect frontend status */
"<td align=center>%s</td>" "<td align=center>%s</td>"
/* rest of server: nothing */ /* rest of server: nothing */
"<td align=center colspan=6></td></tr>" "<td align=center colspan=7></td></tr>"
"", "",
px->feconn, px->feconn_max, px->maxconn, px->cum_feconn, px->feconn, px->feconn_max, px->maxconn, px->cum_feconn,
px->bytes_in, px->bytes_out, 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," "%s,"
/* rest of server: nothing */ /* rest of server: nothing */
",,,,,,,," ",,,,,,,,"
/* pid, iid, sid, */ /* pid, iid, sid, throttle, */
"%d,%d,0," "%d,%d,0,,"
"\n", "\n",
px->id, px->id,
px->feconn, px->feconn_max, px->maxconn, px->cum_feconn, 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), chunk_printf(&msg, sizeof(trash),
"<td align=right>%d</td><td align=right>%d</td>" "<td align=right>%d</td><td align=right>%d</td>"
"<td nowrap align=right>%s</td>" "<td nowrap align=right>%s</td>"
"</tr>\n", "",
sv->failed_checks, sv->down_trans, sv->failed_checks, sv->down_trans,
human_time(srv_downtime(sv), 1)); human_time(srv_downtime(sv), 1));
else else
chunk_printf(&msg, sizeof(trash), chunk_printf(&msg, sizeof(trash),
"<td colspan=3></td></tr>\n"); "<td colspan=3></td>");
/* 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),
"<td>%d %%</td></tr>\n", ratio);
} else {
chunk_printf(&msg, sizeof(trash),
"<td>-</td></tr>\n");
}
} else { } else {
static char *srv_hlt_st[7] = { "DOWN,", "DOWN %d/%d,", static char *srv_hlt_st[7] = { "DOWN,", "DOWN %d/%d,",
"UP %d/%d,", "UP,", "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), chunk_printf(&msg, sizeof(trash),
",,,,"); ",,,,");
/* queue limit, pid, iid, sid and EOL */ /* queue limit, pid, iid, sid, */
chunk_printf(&msg, sizeof(trash), chunk_printf(&msg, sizeof(trash),
"%s," "%s,"
"%d,%d,%d," "%d,%d,%d,",
"\n",
LIM2A0(sv->maxqueue, ""), LIM2A0(sv->maxqueue, ""),
relative_pid, px->uuid, sv->puid); 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) if (buffer_write_chunk(rep, &msg) != 0)
return 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); px->srv_act, px->srv_bck);
chunk_printf(&msg, sizeof(trash), chunk_printf(&msg, sizeof(trash),
/* rest of backend: nothing, down transformations, total downtime */ /* rest of backend: nothing, down transitions, total downtime, throttle */
"<td align=center>&nbsp;</td><td align=\"right\">%d</td>" "<td align=center>&nbsp;</td><td align=\"right\">%d</td>"
"<td align=\"right\" nowrap>%s</td>" "<td align=\"right\" nowrap>%s</td>"
"<td></td>"
"</tr>", "</tr>",
px->down_trans, px->down_trans,
px->srv?human_time(be_downtime(px), 1):"&nbsp;"); px->srv?human_time(be_downtime(px), 1):"&nbsp;");
@ -918,11 +937,10 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
* active and backups. */ * active and backups. */
"%s," "%s,"
"%d,%d,%d," "%d,%d,%d,"
/* rest of backend: nothing, down transformations, /* rest of backend: nothing, down transitions, last change, total downtime */
* last change, total downtime. */
",%d,%d,%d,," ",%d,%d,%d,,"
/* pid, iid, sid, */ /* pid, iid, sid, throttle, */
"%d,%d,0," "%d,%d,0,,"
"\n", "\n",
px->id, px->id,
px->nbpend /* or px->totpend ? */, px->nbpend_max, px->nbpend /* or px->totpend ? */, px->nbpend_max,