mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
CLEANUP: counters: move from 3 types to 2 types
We used to have 3 types of counters with a huge overlap : - listener counters : stats collected for each bind line - proxy counters : union of the frontend and backend counters - server counters : stats collected per server It happens that quite a good part was common between listeners and proxies due to the frontend counters being updated at the two locations, and that similarly the server and proxy counters were overlapping and being updated together. This patch cleans this up to propose only two types of counters : - fe_counters: used by frontends and listeners, related to incoming connections activity - be_counters: used by backends and servers, related to outgoing connections activity This allowed to remove some non-sensical counters from both parts. For frontends, the following entries were removed : cum_lbconn, last_sess, nbpend_max, failed_conns, failed_resp, retries, redispatches, q_time, c_time, d_time, t_time For backends, this ones was removed : intercepted_req. While doing this it was discovered that we used to incorrectly report intercepted_req for backends in the HTML stats, which was always zero since it's never updated. Also it revealed a few inconsistencies (which were not fixed as they are harmless). For example, backends count connections (cum_conn) instead of sessions while servers count sessions and not connections. Over the long term, some extra cleanups may be performed by having some counters update functions touching both the server and backend at the same time, as well as both the frontend and listener, to ensure that all sides have all their stats properly filled. The stats dump will also be able to factor the dump functions by counter types.
This commit is contained in:
parent
3758581e19
commit
ae9bea0591
@ -23,8 +23,44 @@
|
||||
#ifndef _TYPES_COUNTERS_H
|
||||
#define _TYPES_COUNTERS_H
|
||||
|
||||
/* maybe later we might thing about having a different struct for FE and BE */
|
||||
struct pxcounters {
|
||||
/* counters used by listeners and frontends */
|
||||
struct fe_counters {
|
||||
unsigned int conn_max; /* max # of active sessions */
|
||||
long long cum_conn; /* cumulated number of received connections */
|
||||
long long cum_sess; /* cumulated number of accepted connections */
|
||||
|
||||
unsigned int cps_max; /* maximum of new connections received per second */
|
||||
unsigned int sps_max; /* maximum of new connections accepted per second (sessions) */
|
||||
|
||||
long long bytes_in; /* number of bytes transferred from the client to the server */
|
||||
long long bytes_out; /* number of bytes transferred from the server to the client */
|
||||
|
||||
long long comp_in; /* input bytes fed to the compressor */
|
||||
long long comp_out; /* output bytes emitted by the compressor */
|
||||
long long comp_byp; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */
|
||||
|
||||
long long denied_req; /* blocked requests because of security concerns */
|
||||
long long denied_resp; /* blocked responses because of security concerns */
|
||||
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
||||
long long denied_conn; /* denied connection requests (tcp-req-conn rules) */
|
||||
long long denied_sess; /* denied session requests (tcp-req-sess rules) */
|
||||
|
||||
long long cli_aborts; /* aborted responses during DATA phase caused by the client */
|
||||
long long srv_aborts; /* aborted responses during DATA phase caused by the server */
|
||||
long long intercepted_req; /* number of monitoring or stats requests intercepted by the frontend */
|
||||
|
||||
union {
|
||||
struct {
|
||||
long long cum_req; /* cumulated number of processed HTTP requests */
|
||||
long long comp_rsp; /* number of compressed responses */
|
||||
unsigned int rps_max; /* maximum of new HTTP requests second observed */
|
||||
long long rsp[6]; /* http response codes */
|
||||
} http;
|
||||
} p; /* protocol-specific stats */
|
||||
};
|
||||
|
||||
/* counters used by listeners and frontends */
|
||||
struct be_counters {
|
||||
unsigned int conn_max; /* max # of active sessions */
|
||||
long long cum_conn; /* cumulated number of received connections */
|
||||
long long cum_sess; /* cumulated number of accepted connections */
|
||||
@ -34,6 +70,7 @@ struct pxcounters {
|
||||
unsigned int cps_max; /* maximum of new connections received per second */
|
||||
unsigned int sps_max; /* maximum of new connections accepted per second (sessions) */
|
||||
unsigned int nbpend_max; /* max number of pending connections with no server assigned yet (BE only) */
|
||||
unsigned int cur_sess_max; /* max number of currently active sessions */
|
||||
|
||||
long long bytes_in; /* number of bytes transferred from the client to the server */
|
||||
long long bytes_out; /* number of bytes transferred from the server to the client */
|
||||
@ -42,11 +79,8 @@ struct pxcounters {
|
||||
long long comp_out; /* output bytes emitted by the compressor */
|
||||
long long comp_byp; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */
|
||||
|
||||
long long denied_req; /* blocked requests/responses because of security concerns */
|
||||
long long denied_resp; /* blocked requests/responses because of security concerns */
|
||||
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
||||
long long denied_conn; /* denied connection requests (tcp-req-conn rules) */
|
||||
long long denied_sess; /* denied session requests (tcp-req-sess rules) */
|
||||
long long denied_req; /* blocked requests because of security concerns */
|
||||
long long denied_resp; /* blocked responses because of security concerns */
|
||||
|
||||
long long failed_conns; /* failed connect() attempts (BE only) */
|
||||
long long failed_resp; /* failed responses (BE only) */
|
||||
@ -54,7 +88,10 @@ struct pxcounters {
|
||||
long long srv_aborts; /* aborted responses during DATA phase caused by the server */
|
||||
long long retries; /* retried and redispatched connections (BE only) */
|
||||
long long redispatches; /* retried and redispatched connections (BE only) */
|
||||
long long intercepted_req; /* number of monitoring or stats requests intercepted by the frontend */
|
||||
long long failed_secu; /* blocked responses because of security concerns */
|
||||
|
||||
long long failed_checks, failed_hana; /* failed health checks and health analyses for servers */
|
||||
long long down_trans; /* up->down transitions */
|
||||
|
||||
unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */
|
||||
|
||||
@ -68,50 +105,6 @@ struct pxcounters {
|
||||
} p; /* protocol-specific stats */
|
||||
};
|
||||
|
||||
struct licounters {
|
||||
unsigned int conn_max; /* max # of active listener sessions */
|
||||
|
||||
long long cum_conn; /* cumulated number of received connections */
|
||||
long long cum_sess; /* cumulated number of accepted sessions */
|
||||
|
||||
long long bytes_in; /* number of bytes transferred from the client to the server */
|
||||
long long bytes_out; /* number of bytes transferred from the server to the client */
|
||||
|
||||
long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */
|
||||
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
||||
long long denied_conn; /* denied connection requests (tcp-req-conn rules) */
|
||||
long long denied_sess; /* denied session requests (tcp-req-sess rules) */
|
||||
};
|
||||
|
||||
struct srvcounters {
|
||||
unsigned int cur_sess_max; /* max number of currently active sessions */
|
||||
unsigned int nbpend_max; /* max number of pending connections reached */
|
||||
unsigned int sps_max; /* maximum of new sessions per second seen on this server */
|
||||
|
||||
long long cum_sess; /* cumulated number of sessions really sent to this server */
|
||||
long long cum_lbconn; /* cumulated number of sessions directed by load balancing */
|
||||
unsigned long last_sess; /* last session time */
|
||||
|
||||
long long bytes_in; /* number of bytes transferred from the client to the server */
|
||||
long long bytes_out; /* number of bytes transferred from the server to the client */
|
||||
|
||||
long long failed_conns, failed_resp; /* failed connect() and responses */
|
||||
long long cli_aborts, srv_aborts; /* aborted responses during DATA phase due to client or server */
|
||||
long long retries, redispatches; /* retried and redispatched connections */
|
||||
long long failed_secu; /* blocked responses because of security concerns */
|
||||
|
||||
unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */
|
||||
|
||||
union {
|
||||
struct {
|
||||
long long rsp[6]; /* http response codes */
|
||||
} http;
|
||||
} p;
|
||||
|
||||
long long failed_checks, failed_hana; /* failed health checks and health analyses */
|
||||
long long down_trans; /* up->down transitions */
|
||||
};
|
||||
|
||||
#endif /* _TYPES_COUNTERS_H */
|
||||
|
||||
/*
|
||||
|
@ -39,7 +39,7 @@ struct task;
|
||||
struct protocol;
|
||||
struct xprt_ops;
|
||||
struct proxy;
|
||||
struct licounters;
|
||||
struct fe_counters;
|
||||
|
||||
/* listener state */
|
||||
enum li_state {
|
||||
@ -171,7 +171,7 @@ struct listener {
|
||||
char *name; /* listener's name */
|
||||
int luid; /* listener universally unique ID, used for SNMP */
|
||||
int options; /* socket options : LI_O_* */
|
||||
struct licounters *counters; /* statistics counters */
|
||||
struct fe_counters *counters; /* statistics counters */
|
||||
struct protocol *proto; /* protocol this listener belongs to */
|
||||
struct xprt_ops *xprt; /* transport-layer operations for this socket */
|
||||
int nbconn; /* current number of connections on this listener */
|
||||
|
@ -362,8 +362,8 @@ struct proxy {
|
||||
struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the streams */
|
||||
*rsp_cap_pool;
|
||||
struct list req_add, rsp_add; /* headers to be added */
|
||||
struct pxcounters be_counters; /* backend statistics counters */
|
||||
struct pxcounters fe_counters; /* frontend statistics counters */
|
||||
struct be_counters be_counters; /* backend statistics counters */
|
||||
struct fe_counters fe_counters; /* frontend statistics counters */
|
||||
|
||||
struct list listener_queue; /* list of the temporarily limited listeners because of lack of a proxy resource */
|
||||
struct stktable table; /* table for storing sticking streams */
|
||||
|
@ -192,7 +192,7 @@ struct server {
|
||||
int nbpend; /* number of pending connections */
|
||||
int maxqueue; /* maximum number of pending connections allowed */
|
||||
struct freq_ctr sess_per_sec; /* sessions per second on this server */
|
||||
struct srvcounters counters; /* statistics counters */
|
||||
struct be_counters counters; /* statistics counters */
|
||||
|
||||
struct list pendconns; /* pending connections */
|
||||
struct list actconns; /* active connections */
|
||||
|
@ -9009,7 +9009,7 @@ out_uri_auth_compat:
|
||||
|
||||
/* enable separate counters */
|
||||
if (curproxy->options2 & PR_O2_SOCKSTAT) {
|
||||
listener->counters = calloc(1, sizeof(struct licounters));
|
||||
listener->counters = calloc(1, sizeof(*listener->counters));
|
||||
if (!listener->name)
|
||||
memprintf(&listener->name, "sock-%d", listener->luid);
|
||||
}
|
||||
|
@ -929,7 +929,6 @@ static int stats_dump_fields_html(struct chunk *out, const struct field *stats,
|
||||
"<tr><th>- HTTP 4xx responses:</th><td>%s</td></tr>"
|
||||
"<tr><th>- HTTP 5xx responses:</th><td>%s</td></tr>"
|
||||
"<tr><th>- other responses:</th><td>%s</td></tr>"
|
||||
"<tr><th>Intercepted requests:</th><td>%s</td></tr>"
|
||||
"<tr><th colspan=3>Avg over last 1024 success. conn.</th></tr>"
|
||||
"",
|
||||
U2H(stats[ST_F_REQ_TOT].u.u64),
|
||||
@ -941,8 +940,7 @@ static int stats_dump_fields_html(struct chunk *out, const struct field *stats,
|
||||
U2H(stats[ST_F_HRSP_3XX].u.u64),
|
||||
U2H(stats[ST_F_HRSP_4XX].u.u64),
|
||||
U2H(stats[ST_F_HRSP_5XX].u.u64),
|
||||
U2H(stats[ST_F_HRSP_OTHER].u.u64),
|
||||
U2H(stats[ST_F_INTERCEPTED].u.u64));
|
||||
U2H(stats[ST_F_HRSP_OTHER].u.u64));
|
||||
}
|
||||
|
||||
chunk_appendf(out, "<tr><th>- Queue time:</th><td>%s</td><td>ms</td></tr>", U2H(stats[ST_F_QTIME].u.u32));
|
||||
@ -1547,7 +1545,6 @@ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int le
|
||||
stats[ST_F_HRSP_4XX] = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[4]);
|
||||
stats[ST_F_HRSP_5XX] = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[5]);
|
||||
stats[ST_F_HRSP_OTHER] = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[0]);
|
||||
stats[ST_F_INTERCEPTED] = mkf_u64(FN_COUNTER, px->be_counters.intercepted_req);
|
||||
}
|
||||
|
||||
stats[ST_F_CLI_ABRT] = mkf_u64(FN_COUNTER, px->be_counters.cli_aborts);
|
||||
@ -3065,7 +3062,6 @@ static int cli_parse_clear_counters(char **args, struct appctx *appctx, void *pr
|
||||
px->fe_counters.p.http.rps_max = 0;
|
||||
px->fe_counters.sps_max = 0;
|
||||
px->fe_counters.cps_max = 0;
|
||||
px->fe_counters.nbpend_max = 0;
|
||||
}
|
||||
|
||||
for (sv = px->srv; sv; sv = sv->next)
|
||||
|
Loading…
Reference in New Issue
Block a user