From 9f3e91786298783690dd8b0a113b8a5c7f1ed137 Mon Sep 17 00:00:00 2001
From: Krzysztof Piotr Oledzki o...@ans.pl
Date: Tue, 29 Sep 2009 20:54:26 +0200
Subject: [MEDIUM] Collect provide separate statistics for sockets
This patch allows to collect provide separate statistics for each socket.
It can be very useful if you would like to distinguish between traffic
generate by local and remote users or between different types of remote
clients (peerings, domestic, foreign).
Currently only Sessions, Bytes, Denied and Req Errors stats are supported,
but adding Session rate or even Session Limit should be possible if
we found it useful.
---
doc/configuration.txt | 19 +++
include/proto/dumpstats.h |1 +
include/proto/proxy.h |8 ++-
include/types/proto_http.h |1 +
include/types/protocols.h |4 ++
include/types/proxy.h | 12 ++---
include/types/session.h|1 +
src/cfgparse.c | 96 +-
src/client.c | 19 +--
src/dumpstats.c| 112 +++-
src/haproxy.c |6 +-
src/log.c |2 +-
src/proto_http.c | 76 --
src/proto_tcp.c|6 ++-
src/proxy.c|4 +-
src/session.c | 29 ---
16 files changed, 327 insertions(+), 69 deletions(-)
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 1416386..c9c5caf 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -744,6 +744,7 @@ option httplog X X X X
option originalto X X X X
[no] option persist X - X X
[no] option redispatch X - X X
+[no] option socket-statsX X X -
option smtpchk X - X X
[no] option splice-auto X X X X
[no] option splice-request X X X X
@@ -1074,6 +1075,8 @@ bind [address]:port [, ...]
bind [address]:port [, ...] interface interface
bind [address]:port [, ...] mss maxseg
bind [address]:port [, ...] transparent
+bind [address]:port [, ...] id id
+bind [address]:port [, ...] name name
Define one or several listening addresses and/or ports in a frontend.
May be used in sections : defaults | frontend | listen | backend
no |yes | yes | no
@@ -1107,6 +1110,13 @@ bind [address]:port [, ...] transparent
work on other operating systems. The commonly advertised
value on Ethernet networks is 1460 = 1500(MTU) - 40(IP+TCP).
+id is a persistent value for socket ID. Must be unique and
+ larger than 1000, as smaller values are reserved for
+ auto-assigned ids. Can only be used when defining only
+ a single socket.
+
+nameis an optional name provided for stats
+
transparent is an optional keyword which is supported only on certain
Linux kernels. It indicates that the addresses will be bound
even if they do not belong to the local machine. Any packet
@@ -2665,6 +2675,15 @@ no option redispatch
See also : redispatch, retries
+option socket-stats
+no option socket-stats
+
+ Enable or disable collecting providing separate statistics for each socket.
+ May be used in sections:defaults | frontend | listen
+
+ Arguments : none
+
+
option smtpchk
option smtpchk hello domain
Use SMTP health checks for server testing
diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h
index a0167a7..81aae1a 100644
--- a/include/proto/dumpstats.h
+++ b/include/proto/dumpstats.h
@@ -38,6 +38,7 @@
#define STATS_TYPE_FE 0
#define STATS_TYPE_BE 1
#define STATS_TYPE_SV 2
+#define STATS_TYPE_SO 3
#define STATS_ST_INIT 0
#define STATS_ST_REQ 1
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 0ad1e7f..ce62b3f 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -66,9 +66,13 @@ static inline void proxy_reset_timeouts(struct proxy *proxy)
}
/* increase the number of cumulated connections on the designated frontend */
-static void inline proxy_inc_fe_ctr(struct proxy *fe)
+static void inline proxy_inc_fe_ctr(struct listener *l, struct proxy *fe)
{
- fe-cum_feconn++;
+ fe-counters.cum_feconn++;
+
+ if (l-counters)
+ l-counters-cum_feconn++;
+
update_freq_ctr(fe-fe_sess_per_sec, 1);
if (fe-fe_sess_per_sec.curr_ctr fe-fe_sps_max)
fe-fe_sps_max = fe-fe_sess_per_sec.curr_ctr;
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index c0350d2..b91228e 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -159,6 +159,7 @@ enum