[MEDIUM] measure and report session rate on frontend, backends and servers

With this change, all frontends, backends, and servers maintain a session
counter and a timer to compute a session rate over the last second. This
value will be very useful because it varies instantly and can be used to
check thresholds. This value is also reported in the stats in a new "rate"
column.
diff --git a/include/types/freq_ctr.h b/include/types/freq_ctr.h
new file mode 100644
index 0000000..a8cfbd7
--- /dev/null
+++ b/include/types/freq_ctr.h
@@ -0,0 +1,40 @@
+/*
+  include/types/freq_ctr.h
+  This file contains structure declarations for frequency counters.
+
+  Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation, version 2.1
+  exclusively.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef _TYPES_FREQ_CTR_H
+#define _TYPES_FREQ_CTR_H
+
+#include <common/config.h>
+
+struct freq_ctr {
+	unsigned int curr_sec; /* start date of current period (seconds from now.tv_sec) */
+	unsigned int curr_ctr; /* cumulated value for current period */
+	unsigned int prev_ctr; /* value for last period */
+};
+
+#endif /* _TYPES_FREQ_CTR_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 9adf5cd..87b6f14 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -2,7 +2,7 @@
   include/types/proxy.h
   This file defines everything related to proxies.
 
-  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
+  Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,7 @@
 
 #include <types/acl.h>
 #include <types/buffers.h>
+#include <types/freq_ctr.h>
 #include <types/httperr.h>
 #include <types/log.h>
 #include <types/protocols.h>
@@ -220,6 +221,8 @@
 	int totpend;				/* total number of pending connections on this instance (for stats) */
 	unsigned int feconn, feconn_max;	/* # of active frontend sessions */
 	unsigned int beconn, beconn_max;	/* # of active backend sessions */
+	struct freq_ctr fe_sess_per_sec;	/* sessions per second on the frontend */
+	struct freq_ctr be_sess_per_sec;	/* sessions per second on the backend */
 	unsigned int cum_feconn, cum_beconn;	/* cumulated number of processed sessions */
 	unsigned int cum_lbconn;		/* cumulated number of sessions processed by load balancing */
 	unsigned int maxconn;			/* max # of active sessions on the frontend */
diff --git a/include/types/server.h b/include/types/server.h
index 5c0186a..8fb8a1f 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -2,7 +2,7 @@
   include/types/server.h
   This file defines everything related to servers.
 
-  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
+  Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,7 @@
 #include <common/mini-clist.h>
 
 #include <types/buffers.h>
+#include <types/freq_ctr.h>
 #include <types/proxy.h>
 #include <types/queue.h>
 #include <types/task.h>
@@ -122,6 +123,7 @@
 	unsigned failed_conns, failed_resp;	/* failed connect() and responses */
 	unsigned retries, redispatches;		/* retried and redispatched connections */
 	unsigned failed_secu;			/* blocked responses because of security concerns */
+	struct freq_ctr sess_per_sec;		/* sessions per second on this server */
 	unsigned cum_sess;			/* cumulated number of sessions really sent to this server */
 	unsigned cum_lbconn;			/* cumulated number of sessions directed by load balancing */