diff --git a/include/types/proxy.h b/include/types/proxy.h index 71f0f5c2a..a709ada5b 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -74,6 +74,8 @@ struct proxy { struct listener *listen; /* the listen addresses and sockets */ struct in_addr mon_net, mon_mask; /* don't forward connections from this net (network order) FIXME: should support IPv6 */ int state; /* proxy state */ + int options; /* PR_O_REDISP, PR_O_TRANSP, ... */ + int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */ struct sockaddr_in dispatch_addr; /* the default address to connect to */ struct proxy *fiprm, *beprm; /* proxy we find filter and backend params from (default: self) */ union { @@ -114,9 +116,9 @@ struct proxy { unsigned failed_conns, failed_resp; /* failed connect() and responses */ unsigned denied_req, denied_resp; /* blocked requests/responses because of security concerns */ unsigned failed_req; /* failed requests (eg: invalid or timeout) */ + long long bytes_in; /* number of bytes transferred from the client to the server */ + long long bytes_out; /* number of bytes transferred from the server to the client */ int conn_retries; /* maximum number of connect retries */ - int options; /* PR_O_REDISP, PR_O_TRANSP, ... */ - int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */ int cap; /* supported capabilities (PR_CAP_*) */ struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */ #ifdef CONFIG_HAP_CTTPROXY diff --git a/include/types/server.h b/include/types/server.h index 70e1f8fdb..620965c73 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -82,6 +82,8 @@ struct server { unsigned failed_checks, down_trans; /* failed checks and up-down transitions */ unsigned failed_conns, failed_resp; /* failed connect() and responses */ unsigned failed_secu; /* blocked responses because of security concerns */ + long long bytes_in; /* number of bytes transferred from the client to the server */ + long long bytes_out; /* number of bytes transferred from the server to the client */ struct proxy *proxy; /* the proxy this server belongs to */ }; diff --git a/include/types/session.h b/include/types/session.h index 3800b4b5e..03a03bc48 100644 --- a/include/types/session.h +++ b/include/types/session.h @@ -154,7 +154,8 @@ struct session { char *cli_cookie; /* cookie presented by the client, in capture mode */ char *srv_cookie; /* cookie presented by the server, in capture mode */ int status; /* HTTP status from the server, negative if from proxy */ - long long bytes; /* number of bytes transferred from the server */ + long long bytes_in; /* number of bytes transferred from the client to the server */ + long long bytes_out; /* number of bytes transferred from the server to the client */ } logs; short int data_source; /* where to get the data we generate ourselves */ short int data_state; /* where to get the data we generate ourselves */ diff --git a/src/buffers.c b/src/buffers.c index def985623..1ac38afdd 100644 --- a/src/buffers.c +++ b/src/buffers.c @@ -35,6 +35,7 @@ int buffer_write(struct buffer *buf, const char *msg, int len) memcpy(buf->r, msg, len); buf->l += len; buf->r += len; + buf->total += len; if (buf->r == buf->data + BUFSIZE) buf->r = buf->data; return 0; @@ -59,6 +60,7 @@ int buffer_write_chunk(struct buffer *buf, struct chunk *chunk) memcpy(buf->r, chunk->str, chunk->len); buf->l += chunk->len; buf->r += chunk->len; + buf->total += chunk->len; if (buf->r == buf->data + BUFSIZE) buf->r = buf->data; chunk->len = 0; diff --git a/src/client.c b/src/client.c index 8e26a9542..f0e698d4c 100644 --- a/src/client.c +++ b/src/client.c @@ -188,7 +188,7 @@ int event_accept(int fd) { s->logs.cli_cookie = NULL; s->logs.srv_cookie = NULL; s->logs.status = -1; - s->logs.bytes = 0; + s->logs.bytes_in = s->logs.bytes_out = 0; s->logs.prx_queue_size = 0; /* we get the number of pending conns before us */ s->logs.srv_queue_size = 0; /* we will get this number soon */ diff --git a/src/log.c b/src/log.c index ba795dc2a..5079185a5 100644 --- a/src/log.c +++ b/src/log.c @@ -396,7 +396,7 @@ void sess_log(struct session *s) (s->logs.t_data >= 0) ? s->logs.t_data - s->logs.t_connect : -1, (tolog & LW_BYTES) ? "" : "+", s->logs.t_close, s->logs.status, - (tolog & LW_BYTES) ? "" : "+", s->logs.bytes, + (tolog & LW_BYTES) ? "" : "+", s->logs.bytes_in, s->logs.cli_cookie ? s->logs.cli_cookie : "-", s->logs.srv_cookie ? s->logs.srv_cookie : "-", sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT], @@ -420,7 +420,7 @@ void sess_log(struct session *s) (s->logs.t_queue >= 0) ? s->logs.t_queue : -1, (s->logs.t_connect >= 0) ? s->logs.t_connect - s->logs.t_queue : -1, (tolog & LW_BYTES) ? "" : "+", s->logs.t_close, - (tolog & LW_BYTES) ? "" : "+", s->logs.bytes, + (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->beprm->beconn, s->srv ? s->srv->cur_sess : 0, diff --git a/src/proto_http.c b/src/proto_http.c index 0202ba226..6e9cd88f1 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -396,8 +396,21 @@ int process_session(struct task *t) } s->logs.t_close = tv_diff(&s->logs.tv_accept, &now); + if (s->req != NULL) + s->logs.bytes_in = s->req->total; if (s->rep != NULL) - s->logs.bytes = s->rep->total; + s->logs.bytes_out = s->rep->total; + + s->fe->bytes_in += s->logs.bytes_in; + s->fe->bytes_out += s->logs.bytes_out; + if (s->be->beprm != s->fe) { + s->be->beprm->bytes_in += s->logs.bytes_in; + s->be->beprm->bytes_out += s->logs.bytes_out; + } + if (s->srv) { + s->srv->bytes_in += s->logs.bytes_in; + s->srv->bytes_out += s->logs.bytes_out; + } /* let's do a final log if we need it */ if (s->logs.logwait && @@ -1947,7 +1960,7 @@ int process_srv(struct session *t) bytes from the server, then this is the right moment. */ if (t->fe->to_log && !(t->logs.logwait & LW_BYTES)) { t->logs.t_close = t->logs.t_data; /* to get a valid end date */ - t->logs.bytes = rep->h - rep->data; + t->logs.bytes_in = rep->h - rep->data; sess_log(t); } break; @@ -2860,7 +2873,7 @@ int produce_content_stats(struct session *s) ".backup3 {background: #b0d0ff;}\n" ".backup4 {background: #e0e0e0;}\n" "table.tbl { border-collapse: collapse; border-style: none;}\n" - "table.tbl td { border-width: 1px 1px 1px 1px; border-style: solid solid solid solid; border-color: gray;}\n" + "table.tbl td { border-width: 1px 1px 1px 1px; border-style: solid solid solid solid; padding: 2px 3px; border-color: gray;}\n" "table.tbl th { border-width: 1px; border-style: solid solid solid solid; border-color: gray;}\n" "table.tbl th.empty { border-style: none; empty-cells: hide;}\n" "table.lgd { border-collapse: collapse; border-width: 1px; border-style: none none none solid; border-color: black;}\n" @@ -3042,8 +3055,8 @@ int produce_content_stats_proxy(struct session *s, struct proxy *px) "