diff --git a/include/haproxy/counters-t.h b/include/haproxy/counters-t.h index 5b7842ae3..d9bb5cfb4 100644 --- a/include/haproxy/counters-t.h +++ b/include/haproxy/counters-t.h @@ -88,10 +88,13 @@ struct fe_counters { unsigned int cps_max; /* maximum of new connections received per second */ unsigned int sps_max; /* maximum of new connections accepted per second (sessions) */ + struct freq_ctr _sess_per_sec; /* sessions per second on this frontend, used to compute sps_max (internal use only) */ + struct freq_ctr _conn_per_sec; /* connections per second on this frontend, used to compute cps_max (internal use only) */ union { struct { unsigned int rps_max; /* maximum of new HTTP requests second observed */ + struct freq_ctr _req_per_sec; /* HTTP requests per second on the frontend, only used to compute rps_max */ } http; } p; /* protocol-specific stats */ }; @@ -136,6 +139,8 @@ struct be_counters { unsigned int nbpend_max; /* max number of pending connections with no server assigned yet */ unsigned int cur_sess_max; /* max number of currently active sessions */ + struct freq_ctr _sess_per_sec; /* sessions per second on this frontend, used to compute sps_max (internal use only) */ + unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */ unsigned int qtime_max, ctime_max, dtime_max, ttime_max; /* maximum of conn_time, queue_time, data_time, total_time observed */ diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index e2eaa2bac..0c8d5446c 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -139,8 +139,9 @@ static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe) _HA_ATOMIC_INC(&fe->fe_counters.shared->cum_conn); if (l && l->counters) _HA_ATOMIC_INC(&l->counters->shared->cum_conn); + update_freq_ctr(&fe->fe_counters.shared->conn_per_sec, 1); HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.cps_max, - update_freq_ctr(&fe->fe_counters.shared->conn_per_sec, 1)); + update_freq_ctr(&fe->fe_counters._conn_per_sec, 1)); } /* increase the number of cumulated connections accepted by the designated frontend */ @@ -150,8 +151,9 @@ static inline void proxy_inc_fe_sess_ctr(struct listener *l, struct proxy *fe) _HA_ATOMIC_INC(&fe->fe_counters.shared->cum_sess); if (l && l->counters) _HA_ATOMIC_INC(&l->counters->shared->cum_sess); + update_freq_ctr(&fe->fe_counters.shared->sess_per_sec, 1); HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.sps_max, - update_freq_ctr(&fe->fe_counters.shared->sess_per_sec, 1)); + update_freq_ctr(&fe->fe_counters._sess_per_sec, 1)); } /* increase the number of cumulated HTTP sessions on the designated frontend. @@ -173,8 +175,9 @@ static inline void proxy_inc_fe_cum_sess_ver_ctr(struct listener *l, struct prox static inline void proxy_inc_be_ctr(struct proxy *be) { _HA_ATOMIC_INC(&be->be_counters.shared->cum_sess); + update_freq_ctr(&be->be_counters.shared->sess_per_sec, 1); HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max, - update_freq_ctr(&be->be_counters.shared->sess_per_sec, 1)); + update_freq_ctr(&be->be_counters._sess_per_sec, 1)); } /* increase the number of cumulated requests on the designated frontend. @@ -190,8 +193,9 @@ static inline void proxy_inc_fe_req_ctr(struct listener *l, struct proxy *fe, _HA_ATOMIC_INC(&fe->fe_counters.shared->p.http.cum_req[http_ver]); if (l && l->counters) _HA_ATOMIC_INC(&l->counters->shared->p.http.cum_req[http_ver]); + update_freq_ctr(&fe->fe_counters.shared->req_per_sec, 1); HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.p.http.rps_max, - update_freq_ctr(&fe->fe_counters.shared->req_per_sec, 1)); + update_freq_ctr(&fe->fe_counters.p.http._req_per_sec, 1)); } /* Returns non-zero if the proxy is configured to retry a request if we got that status, 0 otherwise */ diff --git a/include/haproxy/server.h b/include/haproxy/server.h index 61ece11a2..14f8ea342 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -182,8 +182,9 @@ const struct mux_ops *srv_get_ws_proto(struct server *srv); static inline void srv_inc_sess_ctr(struct server *s) { _HA_ATOMIC_INC(&s->counters.shared->cum_sess); + update_freq_ctr(&s->counters.shared->sess_per_sec, 1); HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max, - update_freq_ctr(&s->counters.shared->sess_per_sec, 1)); + update_freq_ctr(&s->counters._sess_per_sec, 1)); } /* set the time of last session on the designated server */