]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[STATS] separate frontend and backend HTTP stats
authorWilly Tarreau <w@1wt.eu>
Fri, 26 Feb 2010 09:30:28 +0000 (10:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 26 Feb 2010 09:30:28 +0000 (10:30 +0100)
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
src/dumpstats.c
src/proto_http.c
src/session.c

index 2b4820783c7a3ee6aed397029bf04f4ad3c3f61c..33fbb5cde7d8fbaa2bd236ce48679ea98296dd91 100644 (file)
@@ -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;
 
index 5f62dff77617673c602b87a5fa9be1ff4438fd2a..c861ee58a52b20e85ac80942f68c554357a7ec60 100644 (file)
@@ -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, ",,,,,,");
                                }
index 0820be5bd470abf674d42b61f7fad1129a6fb1cf..cb5120526c5b9c335d1c7ebd94b140977e14e5a8 100644 (file)
@@ -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 */
index c05cc8b8ef8d2840820e315e3fff0351e9b5b3eb..91edd736e5a842605a330c3f381595aa06ca333e 100644 (file)
@@ -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 */