From 9a41d4f9155826cc9034af5adec13e3029b1dc2f Mon Sep 17 00:00:00 2001
From: Krzysztof Piotr Oledzki <ole#ans.pl>
Date: Mon, 3 Dec 2007 00:43:15 +0100
Subject: [MINOR]: Count retries and redispatches also for servers + extend logs + %d->%u cleanup
This patch extends a little previously added functionality to also count retries and redispatches for servers. Now it is possible to know which server causes redispatches as it is not alwas the same that takes most retries.
I also extended log to add how many retries are still possible and fixed a little the documentation (sorry, english only) about logs, as current version uses totally different format. BTW: examples are still outdated, maybe next time...
Finally, I changed %d -> %u for retries/redispatches as those variables are declared as unsigned. Similar cleanup also applies to other variables, will send additional patch if that is OK?
--- doc/haproxy-en.txt | 40 ++++++++++++++++++++-------------------- include/types/server.h | 2 +- include/types/session.h | 1 - src/backend.c | 4 +++- src/dumpstats.c | 12 ++++++------ src/log.c | 4 ++-- src/proto_http.c | 8 +++++--- 7 files changed, 37 insertions(+), 34 deletions(-) diff --git a/doc/haproxy-en.txt b/doc/haproxy-en.txt index 64a63ac..a66ce8e 100644 --- a/doc/haproxy-en.txt +++ b/doc/haproxy-en.txtReceived on 2007/12/03 01:15
@@ -1674,29 +1674,29 @@ Example of HTTP logging :
option dontlognull log 192.168.2.200 local3 ->>> haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57] relais-http Srv1 9/0/7/147/723 200 243 - - ---- 2/3/3 0/0 "HEAD / HTTP/1.0" +>>> haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57] relais-http Srv1 9/0/7/147/723 200 243 - - ---- 34/34/15/8/3 0/0 "HEAD / HTTP/1.0" More complete example - haproxy[18989]: 10.0.0.1:34552 [15/Oct/2003:15:26:31] relais-http Srv1 3183/-1/-1/-1/11215 503 0 - - SC-- 137/202/205 0/0 {w.ods.org|Mozilla} {} "HEAD / HTTP/1.0" + haproxy[18989]: 10.0.0.1:34552 [15/Oct/2003:15:26:31] relais-http Srv1 3183/-1/-1/-1/11215 503 0 - - SC-- 205/202/150/137/4 0/0 {w.ods.org|Mozilla} {} "HEAD / HTTP/1.0" - Field Format Example + Field Format Example - 1 process_name '[' pid ']:' haproxy[18989]: - 2 client_ip ':' client_port 10.0.0.1:34552 - 3 '[' date ']' [15/Oct/2003:15:26:31] - 4 listener_name relais-http - 5 server_name Srv1 - 6 Tq '/' Tw '/' Tc '/' Tr '/' Tt 3183/-1/-1/-1/11215 - 7 HTTP_return_code 503 - 8 bytes_read 0 - 9 captured_request_cookie - - 10 captured_response_cookie - - 11 termination_state SC-- - 12 srv_conn '/' listener_conn '/' process_conn 137/202/205 - 13 position in srv_queue / listener_queue 0/0 - 14 '{' captured_request_headers '}' {w.ods.org|Mozilla} - 15 '{' captured_response_headers '}' {} - 16 '"' HTTP_request '"' "HEAD / HTTP/1.0" + 1 process_name '[' pid ']:' haproxy[18989]: + 2 client_ip ':' client_port 10.0.0.1:34552 + 3 '[' date ']' [15/Oct/2003:15:26:31] + 4 listener_name relais-http + 5 server_name Srv1 + 6 Tq '/' Tw '/' Tc '/' Tr '/' Tt 3183/-1/-1/-1/11215 + 7 HTTP_return_code 503 + 8 bytes_read 0 + 9 captured_request_cookie - + 10 captured_response_cookie - + 11 termination_state SC-- + 12 actconn '/' feconn '/' beconn '/' srv_conn '/' retries_left 205/202/150/137/4 + 13 position in srv_queue / listener_queue 0/0 + 14 '{' captured_request_headers '}' {w.ods.org|Mozilla} + 15 '{' captured_response_headers '}' {} + 16 '"' HTTP_request '"' "HEAD / HTTP/1.0" Note for log parsers: the URI is ALWAYS the end of the line starting with the first double quote '"'.
@@ -1724,7 +1724,7 @@ Example :
option logasap log 192.168.2.200 local3 ->>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17] relais-http Srv1 9/10/7/14/+30 200 +243 - - ---- 1/1/3 1/0 "GET /image.iso HTTP/1.0" +>>> haproxy[674]: 127.0.0.1:33320 [15/Oct/2003:08:32:17] relais-http Srv1 9/10/7/14/+30 200 +243 - - ---- 3/1/1/1/3 1/0 "GET /image.iso HTTP/1.0" 4.2.3) Timing events -------------------- diff --git a/include/types/server.h b/include/types/server.h index 36ae7cb..8263221 100644 --- a/include/types/server.h +++ b/include/types/server.h
@@ -107,7 +107,7 @@ struct server {
time_t last_change; /* last time, when the state was changed */ unsigned failed_conns, failed_resp; /* failed connect() and responses */ - unsigned retries; /* retried connections */ + unsigned retries, redispatches; /* retried and redispatched connections */ unsigned failed_secu; /* blocked responses because of security concerns */ unsigned cum_sess; /* cumulated number of sessions really sent to this server */ diff --git a/include/types/session.h b/include/types/session.h index 347bbaa..76cd07d 100644 --- a/include/types/session.h +++ b/include/types/session.h
@@ -79,7 +79,6 @@
#define SN_STAT_NORFRSH 0x00020000 /* do not automatically refresh the stats page */ #define SN_STAT_FMTCSV 0x00040000 /* dump the stats in CSV format instead of HTML */ - /* WARNING: if new fields are added, they must be initialized in event_accept() * and freed in session_free() ! */ diff --git a/src/backend.c b/src/backend.c index 4dc2b9c..8619f7d 100644 --- a/src/backend.c +++ b/src/backend.c
@@ -1418,8 +1418,10 @@ int srv_retryable_connect(struct session *t)
if (may_dequeue_tasks(t->srv, t->be)) task_wakeup(t->srv->queue_mgt); - if (t->srv) + if (t->srv) { t->srv->failed_conns++; + t->srv->redispatches++; + } t->be->redispatches++; t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET); diff --git a/src/dumpstats.c b/src/dumpstats.c index 7454600..0bd18fb 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c
@@ -732,7 +732,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* errors : request, connect, response */ "<td align=right></td><td align=right>%d</td><td align=right>%d</td>\n" /* warnings: retries, redispatches */ - "<td align=right>%d</td><td align=right></td>" + "<td align=right>%u</td><td align=right>%u</td>" "", (sv->state & SRV_BACKUP) ? "backup" : "active", sv_state, sv->id,
@@ -741,7 +741,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
sv->bytes_in, sv->bytes_out, sv->failed_secu, sv->failed_conns, sv->failed_resp, - sv->retries); + sv->retries, sv->redispatches); /* status */ chunk_printf(&msg, sizeof(trash), "<td nowrap>");
@@ -808,7 +808,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* errors : request, connect, response */ ",%d,%d," /* warnings: retries, redispatches */ - "%d,," + "%u,%u," "", px->id, sv->id, sv->nbpend, sv->nbpend_max,
@@ -816,7 +816,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
sv->bytes_in, sv->bytes_out, sv->failed_secu, sv->failed_conns, sv->failed_resp, - sv->retries); + sv->retries, sv->redispatches); /* status */ chunk_printf(&msg, sizeof(trash),
@@ -888,7 +888,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* errors : request, connect, response */ "<td align=right></td><td align=right>%d</td><td align=right>%d</td>\n" /* warnings: retries, redispatches */ - "<td align=right>%d</td><td align=right>%d</td>" + "<td align=right>%u</td><td align=right>%u</td>" /* backend status: reflect backend status (up/down): we display UP * if the backend has known working servers or if it has no server at * all (eg: for stats). Then we display the total weight, number of
@@ -930,7 +930,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* errors : request, connect, response */ ",%d,%d," /* warnings: retries, redispatches */ - "%d,%d," + "%u,%u," /* backend status: reflect backend status (up/down): we display UP * if the backend has known working servers or if it has no server at * all (eg: for stats). Then we display the total weight, number of diff --git a/src/log.c b/src/log.c index 20f9bb4..024237e 100644 --- a/src/log.c +++ b/src/log.c
@@ -313,7 +313,7 @@ void tcp_sess_log(struct session *s)
send_log(prx_log, LOG_INFO, "%s:%d [%02d/%s/%04d:%02d:%02d:%02d.%03d]" " %s %s/%s %d/%d/%s%d %s%lld" - " %c%c %d/%d/%d/%d %d/%d\n", + " %c%c %d/%d/%d/%d/%d %d/%d\n", pn, (s->cli_addr.ss_family == AF_INET) ? ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port) :
@@ -327,7 +327,7 @@ void tcp_sess_log(struct session *s)
(tolog & LW_BYTES) ? "" : "+", s->logs.bytes_in, sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT], sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT], - actconn, fe->feconn, be->beconn, s->srv ? s->srv->cur_sess : 0, + actconn, fe->feconn, be->beconn, s->srv ? s->srv->cur_sess : 0, s->conn_retries, s->logs.srv_queue_size, s->logs.prx_queue_size); s->logs.logwait = 0; diff --git a/src/proto_http.c b/src/proto_http.c index 370fded..c5abc76 100644 --- a/src/proto_http.c +++ b/src/proto_http.c
@@ -769,7 +769,7 @@ static void http_sess_log(struct session *s)
send_log(prx_log, LOG_INFO, "%s:%d [%02d/%s/%04d:%02d:%02d:%02d.%03d]" " %s %s/%s %d/%d/%d/%d/%s%d %d %s%lld" - " %s %s %c%c%c%c %d/%d/%d/%d %d/%d%s\n", + " %s %s %c%c%c%c %d/%d/%d/%d/%d %d/%d%s\n", pn, (s->cli_addr.ss_family == AF_INET) ? ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port) :
@@ -790,7 +790,7 @@ static void http_sess_log(struct session *s)
sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT], (be->options & PR_O_COOK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-', (be->options & PR_O_COOK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-', - actconn, fe->feconn, be->beconn, s->srv ? s->srv->cur_sess : 0, + actconn, fe->feconn, be->beconn, s->srv ? s->srv->cur_sess : 0, s->conn_retries, s->logs.srv_queue_size, s->logs.prx_queue_size, tmpline); s->logs.logwait = 0;
@@ -2505,8 +2505,10 @@ int process_srv(struct session *t)
if (may_dequeue_tasks(t->srv, t->be)) task_wakeup(t->srv->queue_mgt); - if (t->srv) + if (t->srv) { t->srv->failed_conns++; + t->srv->redispatches++; + } t->be->redispatches++; t->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET); -- 1.5.3.6
This archive was generated by hypermail 2.2.0 : 2007/12/03 02:00 CET