From 24657794594693a7e933716cd79bcbb266572d39 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 26 Feb 2010 10:30:28 +0100 Subject: [PATCH] [STATS] separate frontend and backend HTTP stats It is wrong to merge FE and BE stats for a proxy because when we consult a BE's stats, it reflects the FE's stats eventhough the BE has received no traffic. The most common example happens with listen instances, where the backend gets credited for all the trafic even when a use_backend rule makes use of another backend. --- include/types/counters.h | 6 +++--- src/dumpstats.c | 16 ++++++++-------- src/proto_http.c | 6 +++--- src/session.c | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/types/counters.h b/include/types/counters.h index 2b4820783..33fbb5cde 100644 --- a/include/types/counters.h +++ b/include/types/counters.h @@ -42,9 +42,9 @@ struct pxcounters { union { struct { - long long rsp[6]; /* http resonse codes */ + long long rsp[6]; /* http response codes */ } http; - } p; + } fe, be; /* FE and BE stats */ long long failed_conns, failed_resp; /* failed connect() and responses */ long long retries, redispatches; /* retried and redispatched connections */ @@ -79,7 +79,7 @@ struct srvcounters { union { struct { - long long rsp[6]; /* http resonse codes */ + long long rsp[6]; /* http response codes */ } http; } p; diff --git a/src/dumpstats.c b/src/dumpstats.c index 5f62dff77..c861ee58a 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1435,9 +1435,9 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri) chunk_printf(&msg, " title=\"rsp codes:"); for (i = 1; i < 6; i++) - chunk_printf(&msg, " %dxx=%lld,", i, px->counters.p.http.rsp[i]); + chunk_printf(&msg, " %dxx=%lld,", i, px->counters.fe.http.rsp[i]); - chunk_printf(&msg, " other=%lld\"", px->counters.p.http.rsp[0]); + chunk_printf(&msg, " other=%lld\"", px->counters.fe.http.rsp[0]); } chunk_printf(&msg, @@ -1504,9 +1504,9 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri) int i; for (i=1; i<6; i++) - chunk_printf(&msg, "%lld,", px->counters.p.http.rsp[i]); + chunk_printf(&msg, "%lld,", px->counters.fe.http.rsp[i]); - chunk_printf(&msg, "%lld,", px->counters.p.http.rsp[0]); + chunk_printf(&msg, "%lld,", px->counters.fe.http.rsp[0]); } else { chunk_printf(&msg, ",,,,,,"); } @@ -2097,9 +2097,9 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri) chunk_printf(&msg, " title=\"rsp codes:"); for (i = 1; i < 6; i++) - chunk_printf(&msg, " %dxx=%lld", i, px->counters.p.http.rsp[i]); + chunk_printf(&msg, " %dxx=%lld", i, px->counters.be.http.rsp[i]); - chunk_printf(&msg, " other=%lld\"", px->counters.p.http.rsp[0]); + chunk_printf(&msg, " other=%lld\"", px->counters.be.http.rsp[0]); } chunk_printf(&msg, @@ -2194,9 +2194,9 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri) int i; for (i=1; i<6; i++) - chunk_printf(&msg, "%lld,", px->counters.p.http.rsp[i]); + chunk_printf(&msg, "%lld,", px->counters.be.http.rsp[i]); - chunk_printf(&msg, "%lld,", px->counters.p.http.rsp[0]); + chunk_printf(&msg, "%lld,", px->counters.be.http.rsp[0]); } else { chunk_printf(&msg, ",,,,,,"); } diff --git a/src/proto_http.c b/src/proto_http.c index 0820be5bd..cb5120526 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3644,11 +3644,11 @@ void http_end_txn_clean_session(struct session *s) n = 0; if (s->fe->mode == PR_MODE_HTTP) - s->fe->counters.p.http.rsp[n]++; + s->fe->counters.fe.http.rsp[n]++; - if ((s->flags & SN_BE_ASSIGNED) && (s->fe != s->be) && + if ((s->flags & SN_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP)) - s->be->counters.p.http.rsp[n]++; + s->be->counters.be.http.rsp[n]++; } /* don't count other requests' data */ diff --git a/src/session.c b/src/session.c index c05cc8b8e..91edd736e 100644 --- a/src/session.c +++ b/src/session.c @@ -1575,11 +1575,11 @@ resync_stream_interface: n = 0; if (s->fe->mode == PR_MODE_HTTP) - s->fe->counters.p.http.rsp[n]++; + s->fe->counters.fe.http.rsp[n]++; - if ((s->flags & SN_BE_ASSIGNED) && (s->fe != s->be) && + if ((s->flags & SN_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP)) - s->be->counters.p.http.rsp[n]++; + s->be->counters.be.http.rsp[n]++; } /* let's do a final log if we need it */