/* set the time of last session on the backend */
static inline void be_set_sess_last(struct proxy *be)
{
- be->be_counters.last_sess = ns_to_sec(now_ns);
+ HA_ATOMIC_STORE(&be->be_counters.shared->last_sess, ns_to_sec(now_ns));
}
/* This function returns non-zero if the designated server will be
#include <haproxy/freq_ctr-t.h>
/* counters used by listeners and frontends */
-struct fe_counters {
- unsigned int conn_max; /* max # of active sessions */
+struct fe_counters_shared {
+ long long internal_errors; /* internal processing errors */
+ long long failed_rewrites; /* failed rewrites (warning) */
+ long long denied_sess; /* denied session requests (tcp-req-sess rules) */
+ long long denied_conn; /* denied connection requests (tcp-req-conn rules) */
+ long long intercepted_req; /* number of monitoring or stats requests intercepted by the frontend */
long long cum_conn; /* cumulated number of received connections */
- long long cum_sess; /* cumulated number of accepted connections */
- long long cum_sess_ver[3]; /* cumulated number of h1/h2/h3 sessions */
-
- 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 */
+ struct freq_ctr conn_per_sec; /* received connections per second on the frontend */
/* compression counters, index 0 for requests, 1 for responses */
long long comp_in[2]; /* input bytes fed to the compressor */
long long comp_out[2]; /* output bytes emitted by the compressor */
long long comp_byp[2]; /* 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 failed_rewrites; /* failed rewrites (warning) */
- long long internal_errors; /* internal processing errors */
- 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 */
+ long long cli_aborts; /* aborted responses during DATA phase caused by the client */
+
+
+ struct freq_ctr req_per_sec; /* HTTP requests per second on the frontend */
+ long long cum_sess_ver[3]; /* cumulated number of h1/h2/h3 sessions */
union {
struct {
long long cum_req[4]; /* cumulated number of processed other/h1/h2/h3 requests */
+ long long cache_hits; /* cache hits */
+ long long cache_lookups;/* cache lookups */
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 */
- long long cache_lookups;/* cache lookups */
- long long cache_hits; /* cache hits */
+
+
} http;
} p; /* protocol-specific stats */
-
struct freq_ctr sess_per_sec; /* sessions per second on this server */
- struct freq_ctr req_per_sec; /* HTTP requests per second on the frontend */
- struct freq_ctr conn_per_sec; /* received connections per second on the frontend */
-
unsigned long last_change; /* last time, when the state was changed */
+
+ long long failed_req; /* failed requests (eg: invalid or timeout) */
+ long long denied_resp; /* blocked responses because of security concerns */
+ long long denied_req; /* blocked requests because of security concerns */
+
+ long long bytes_out; /* number of bytes transferred from the server to the client */
+ long long bytes_in; /* number of bytes transferred from the client to the server */
+ long long cum_sess; /* cumulated number of accepted connections */
};
-/* counters used by servers and backends */
-struct be_counters {
+struct fe_counters {
+ struct fe_counters_shared *shared; /* shared counters */
unsigned int conn_max; /* max # of active sessions */
- long long cum_sess; /* cumulated number of accepted connections */
- long long cum_lbconn; /* cumulated number of sessions processed by load balancing (BE only) */
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 */
- 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 */
+ union {
+ struct {
+ unsigned int rps_max; /* maximum of new HTTP requests second observed */
+ } http;
+ } p; /* protocol-specific stats */
+};
+
+struct be_counters_shared {
+ long long internal_errors; /* internal processing errors */
+
+ long long cum_lbconn; /* cumulated number of sessions processed by load balancing (BE only) */
+
+ long long connect; /* number of connection establishment attempts */
+ long long reuse; /* number of connection reuses */
+ long long failed_rewrites; /* failed rewrites (warning) */
+ unsigned long last_sess; /* last session time */
/* compression counters, index 0 for requests, 1 for responses */
long long comp_in[2]; /* input bytes fed to the compressor */
long long comp_out[2]; /* output bytes emitted by the compressor */
long long comp_byp[2]; /* 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 connect; /* number of connection establishment attempts */
- long long reuse; /* number of connection reuses */
- long long failed_conns; /* failed connect() attempts (BE only) */
- long long failed_resp; /* failed responses (BE only) */
- 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 retries; /* retried and redispatched connections (BE only) */
- long long redispatches; /* retried and redispatched connections (BE only) */
- long long failed_rewrites; /* failed rewrites (warning) */
- long long internal_errors; /* internal processing errors */
+ long long cli_aborts; /* aborted responses during DATA phase caused by the client */
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 */
- unsigned int qtime_max, ctime_max, dtime_max, ttime_max; /* maximum of conn_time, queue_time, data_time, total_time observed */
-
union {
struct {
long long cum_req; /* cumulated number of processed HTTP requests */
+
+ long long cache_hits; /* cache hits */
+ long long cache_lookups;/* cache lookups */
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 */
- long long cache_lookups;/* cache lookups */
- long long cache_hits; /* cache hits */
+
} http;
} p; /* protocol-specific stats */
-
struct freq_ctr sess_per_sec; /* sessions per second on this server */
- unsigned long last_sess; /* last session time */
+ long long redispatches; /* retried and redispatched connections (BE only) */
+ long long retries; /* retried and redispatched connections (BE only) */
+ long long failed_resp; /* failed responses (BE only) */
+
+ long long failed_conns; /* failed connect() attempts (BE only) */
+ long long denied_resp; /* blocked responses because of security concerns */
+
+ long long denied_req; /* blocked requests because of security concerns */
+ long long bytes_out; /* number of bytes transferred from the server to the client */
+ long long bytes_in; /* number of bytes transferred from the client to the server */
+
+ long long cum_sess; /* cumulated number of accepted connections */
+
unsigned long last_change; /* last time, when the state was changed */
};
+/* counters used by servers and backends */
+struct be_counters {
+ struct be_counters_shared *shared; /* shared counters */
+ unsigned int conn_max; /* max # of active sessions */
+
+ 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 */
+ unsigned int cur_sess_max; /* max number of currently active sessions */
+
+ 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 */
+
+ union {
+ struct {
+ unsigned int rps_max; /* maximum of new HTTP requests second observed */
+ } http;
+ } p; /* protocol-specific stats */
+};
+
#endif /* _HAPROXY_COUNTERS_T_H */
/*
/* increase the number of cumulated connections received on the designated frontend */
static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe)
{
- _HA_ATOMIC_INC(&fe->fe_counters.cum_conn);
+ _HA_ATOMIC_INC(&fe->fe_counters.shared->cum_conn);
if (l && l->counters)
- _HA_ATOMIC_INC(&l->counters->cum_conn);
+ _HA_ATOMIC_INC(&l->counters->shared->cum_conn);
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.cps_max,
- update_freq_ctr(&fe->fe_counters.conn_per_sec, 1));
+ update_freq_ctr(&fe->fe_counters.shared->conn_per_sec, 1));
}
/* increase the number of cumulated connections accepted by the designated frontend */
static inline void proxy_inc_fe_sess_ctr(struct listener *l, struct proxy *fe)
{
- _HA_ATOMIC_INC(&fe->fe_counters.cum_sess);
+ _HA_ATOMIC_INC(&fe->fe_counters.shared->cum_sess);
if (l && l->counters)
- _HA_ATOMIC_INC(&l->counters->cum_sess);
+ _HA_ATOMIC_INC(&l->counters->shared->cum_sess);
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.sps_max,
- update_freq_ctr(&fe->fe_counters.sess_per_sec, 1));
+ update_freq_ctr(&fe->fe_counters.shared->sess_per_sec, 1));
}
/* increase the number of cumulated HTTP sessions on the designated frontend.
unsigned int http_ver)
{
if (http_ver == 0 ||
- http_ver > sizeof(fe->fe_counters.cum_sess_ver) / sizeof(*fe->fe_counters.cum_sess_ver))
+ http_ver > sizeof(fe->fe_counters.shared->cum_sess_ver) / sizeof(*fe->fe_counters.shared->cum_sess_ver))
return;
- _HA_ATOMIC_INC(&fe->fe_counters.cum_sess_ver[http_ver - 1]);
+ _HA_ATOMIC_INC(&fe->fe_counters.shared->cum_sess_ver[http_ver - 1]);
if (l && l->counters)
- _HA_ATOMIC_INC(&l->counters->cum_sess_ver[http_ver - 1]);
+ _HA_ATOMIC_INC(&l->counters->shared->cum_sess_ver[http_ver - 1]);
}
/* increase the number of cumulated streams on the designated backend */
static inline void proxy_inc_be_ctr(struct proxy *be)
{
- _HA_ATOMIC_INC(&be->be_counters.cum_sess);
+ _HA_ATOMIC_INC(&be->be_counters.shared->cum_sess);
HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max,
- update_freq_ctr(&be->be_counters.sess_per_sec, 1));
+ update_freq_ctr(&be->be_counters.shared->sess_per_sec, 1));
}
/* increase the number of cumulated requests on the designated frontend.
static inline void proxy_inc_fe_req_ctr(struct listener *l, struct proxy *fe,
unsigned int http_ver)
{
- if (http_ver >= sizeof(fe->fe_counters.p.http.cum_req) / sizeof(*fe->fe_counters.p.http.cum_req))
+ if (http_ver >= sizeof(fe->fe_counters.shared->p.http.cum_req) / sizeof(*fe->fe_counters.shared->p.http.cum_req))
return;
- _HA_ATOMIC_INC(&fe->fe_counters.p.http.cum_req[http_ver]);
+ _HA_ATOMIC_INC(&fe->fe_counters.shared->p.http.cum_req[http_ver]);
if (l && l->counters)
- _HA_ATOMIC_INC(&l->counters->p.http.cum_req[http_ver]);
+ _HA_ATOMIC_INC(&l->counters->shared->p.http.cum_req[http_ver]);
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.p.http.rps_max,
- update_freq_ctr(&fe->fe_counters.req_per_sec, 1));
+ update_freq_ctr(&fe->fe_counters.shared->req_per_sec, 1));
}
/* Returns non-zero if the proxy is configured to retry a request if we got that status, 0 otherwise */
/* increase the number of cumulated streams on the designated server */
static inline void srv_inc_sess_ctr(struct server *s)
{
- _HA_ATOMIC_INC(&s->counters.cum_sess);
+ _HA_ATOMIC_INC(&s->counters.shared->cum_sess);
HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max,
- update_freq_ctr(&s->counters.sess_per_sec, 1));
+ update_freq_ctr(&s->counters.shared->sess_per_sec, 1));
}
/* set the time of last session on the designated server */
static inline void srv_set_sess_last(struct server *s)
{
- s->counters.last_sess = ns_to_sec(now_ns);
+ HA_ATOMIC_STORE(&s->counters.shared->last_sess, ns_to_sec(now_ns));
}
/* returns the current server throttle rate between 0 and 100% */
/* Flags for stat_col.flags */
#define STAT_COL_FL_NONE 0x00
#define STAT_COL_FL_GENERIC 0x01 /* stat is generic if set */
+#define STAT_COL_FL_SHARED 0x02 /* stat may be shared between co-processes if set */
/* Represent an exposed statistic. */
struct stat_col {
s->scb->state = SC_ST_REQ;
} else {
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.retries);
- _HA_ATOMIC_INC(&s->be->be_counters.retries);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->retries);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->retries);
s->scb->state = SC_ST_ASS;
}
goto out;
}
else if (srv != prev_srv) {
- _HA_ATOMIC_INC(&s->be->be_counters.cum_lbconn);
- _HA_ATOMIC_INC(&srv->counters.cum_lbconn);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cum_lbconn);
+ _HA_ATOMIC_INC(&srv->counters.shared->cum_lbconn);
}
s->target = &srv->obj_type;
}
s->txn->flags |= TX_CK_DOWN;
}
s->flags |= SF_REDISP;
- _HA_ATOMIC_INC(&prev_srv->counters.redispatches);
- _HA_ATOMIC_INC(&s->be->be_counters.redispatches);
+ _HA_ATOMIC_INC(&prev_srv->counters.shared->redispatches);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->redispatches);
} else {
- _HA_ATOMIC_INC(&prev_srv->counters.retries);
- _HA_ATOMIC_INC(&s->be->be_counters.retries);
+ _HA_ATOMIC_INC(&prev_srv->counters.shared->retries);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->retries);
}
}
}
s->scb->flags |= SC_FL_NOLINGER;
if (s->flags & SF_SRV_REUSED) {
- _HA_ATOMIC_INC(&s->be->be_counters.reuse);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->reuse);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.reuse);
+ _HA_ATOMIC_INC(&srv->counters.shared->reuse);
} else {
- _HA_ATOMIC_INC(&s->be->be_counters.connect);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->connect);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.connect);
+ _HA_ATOMIC_INC(&srv->counters.shared->connect);
}
err = do_connect_server(s, srv_conn);
s->conn_err_type = STRM_ET_QUEUE_ERR;
}
- _HA_ATOMIC_INC(&srv->counters.failed_conns);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&srv->counters.shared->failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
return 1;
case SRV_STATUS_NOSRV:
s->conn_err_type = STRM_ET_CONN_ERR;
}
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
return 1;
case SRV_STATUS_QUEUED:
if (srv)
srv_set_sess_last(srv);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.failed_conns);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&srv->counters.shared->failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
/* release other streams waiting for this server */
if (may_dequeue_tasks(srv, s->be))
if (srv)
srv_set_sess_last(srv);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.failed_conns);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&srv->counters.shared->failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
/* release other streams waiting for this server */
sess_change_server(s, NULL);
pendconn_cond_unlink(s->pend_pos);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.failed_conns);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&srv->counters.shared->failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
sc_abort(sc);
sc_shutdown(sc);
req->flags |= CF_WRITE_TIMEOUT;
}
if (objt_server(s->target))
- _HA_ATOMIC_INC(&objt_server(s->target)->counters.failed_conns);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_conns);
+ _HA_ATOMIC_INC(&objt_server(s->target)->counters.shared->failed_conns);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_conns);
sess_change_server(s, NULL);
if (may_dequeue_tasks(objt_server(s->target), s->be))
process_srv_queue(objt_server(s->target));
s->conn_err_type = STRM_ET_CONN_OTHER;
if (objt_server(s->target))
- _HA_ATOMIC_INC(&objt_server(s->target)->counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&objt_server(s->target)->counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
sess_change_server(s, NULL);
if (may_dequeue_tasks(objt_server(s->target), s->be))
process_srv_queue(objt_server(s->target));
*/
void set_backend_down(struct proxy *be)
{
- be->be_counters.last_change = ns_to_sec(now_ns);
- _HA_ATOMIC_INC(&be->be_counters.down_trans);
+ HA_ATOMIC_STORE(&be->be_counters.shared->last_change, ns_to_sec(now_ns));
+ _HA_ATOMIC_INC(&be->be_counters.shared->down_trans);
if (!(global.mode & MODE_STARTING)) {
ha_alert("%s '%s' has no server available!\n", proxy_type_str(be), be->id);
}
int be_downtime(struct proxy *px) {
- if (px->lbprm.tot_weight && px->be_counters.last_change < ns_to_sec(now_ns)) // ignore negative time
+ unsigned long last_change = HA_ATOMIC_LOAD(&px->be_counters.shared->last_change);
+
+ if (px->lbprm.tot_weight && last_change < ns_to_sec(now_ns)) // ignore negative time
return px->down_time;
- return ns_to_sec(now_ns) - px->be_counters.last_change + px->down_time;
+ return ns_to_sec(now_ns) - last_change + px->down_time;
}
/*
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = read_freq_ctr(&px->be_counters.sess_per_sec);
+ smp->data.u.sint = read_freq_ctr(&px->be_counters.shared->sess_per_sec);
return 1;
}
{
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = read_freq_ctr(&args->data.srv->counters.sess_per_sec);
+ smp->data.u.sint = read_freq_ctr(&args->data.srv->counters.shared->sess_per_sec);
return 1;
}
return ACT_RET_CONT;
if (px == strm_fe(s))
- _HA_ATOMIC_INC(&px->fe_counters.p.http.cache_lookups);
+ _HA_ATOMIC_INC(&px->fe_counters.shared->p.http.cache_lookups);
else
- _HA_ATOMIC_INC(&px->be_counters.p.http.cache_lookups);
+ _HA_ATOMIC_INC(&px->be_counters.shared->p.http.cache_lookups);
cache_tree = get_cache_tree_from_hash(cache, read_u32(s->txn->cache_hash));
should_send_notmodified_response(cache, htxbuf(&s->req.buf), res);
if (px == strm_fe(s))
- _HA_ATOMIC_INC(&px->fe_counters.p.http.cache_hits);
+ _HA_ATOMIC_INC(&px->fe_counters.shared->p.http.cache_hits);
else
- _HA_ATOMIC_INC(&px->be_counters.p.http.cache_hits);
+ _HA_ATOMIC_INC(&px->be_counters.shared->p.http.cache_hits);
return ACT_RET_CONT;
} else {
s->target = NULL;
/* enable separate counters */
if (curproxy->options2 & PR_O2_SOCKSTAT) {
listener->counters = calloc(1, sizeof(*listener->counters));
+ if (listener->counters) {
+ listener->counters->shared = calloc(1, sizeof(*listener->counters->shared));
+ if (!listener->counters->shared) {
+ ha_free(&listener->counters);
+ ha_alert("config: %s '%s': out of memory.\n",
+ proxy_type_str(curproxy), curproxy->id);
+ }
+
+ }
if (!listener->name)
memprintf(&listener->name, "sock-%d", listener->luid);
}
if ((!(check->state & CHK_ST_AGENT) ||
(check->status >= HCHK_STATUS_L57DATA)) &&
(check->health > 0)) {
- _HA_ATOMIC_INC(&s->counters.failed_checks);
+ _HA_ATOMIC_INC(&s->counters.shared->failed_checks);
report = 1;
check->health--;
if (check->health < check->rise)
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
HA_ATOMIC_STORE(&s->consecutive_errors, 0);
- _HA_ATOMIC_INC(&s->counters.failed_hana);
+ _HA_ATOMIC_INC(&s->counters.shared->failed_hana);
if (s->check.fastinter) {
/* timer might need to be advanced, it might also already be
"UP %d/%d", "UP",
"NOLB %d/%d", "NOLB",
"no check" };
+ unsigned long last_change = HA_ATOMIC_LOAD(&s->counters.shared->last_change);
if (!(s->check.state & CHK_ST_ENABLED))
sv_state = 6;
s->queueslength);
if ((s->cur_state == SRV_ST_STARTING) &&
- ns_to_sec(now_ns) < s->counters.last_change + s->slowstart &&
- ns_to_sec(now_ns) >= s->counters.last_change) {
- ratio = MAX(1, 100 * (ns_to_sec(now_ns) - s->counters.last_change) / s->slowstart);
+ ns_to_sec(now_ns) < last_change + s->slowstart &&
+ ns_to_sec(now_ns) >= last_change) {
+ ratio = MAX(1, 100 * (ns_to_sec(now_ns) - last_change) / s->slowstart);
chunk_appendf(buf, "; throttle=%d%%", ratio);
}
goto end;
rewrite_err:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
hdr_rule_err:
node = ebpt_first(&hdr_rules);
while (node) {
if (st->comp_ctx[dir] && st->comp_ctx[dir]->cur_lvl > 0) {
update_freq_ctr(&global.comp_bps_in, consumed);
- _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in[dir], consumed);
- _HA_ATOMIC_ADD(&s->be->be_counters.comp_in[dir], consumed);
+ _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.shared->comp_in[dir], consumed);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->comp_in[dir], consumed);
update_freq_ctr(&global.comp_bps_out, to_forward);
- _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out[dir], to_forward);
- _HA_ATOMIC_ADD(&s->be->be_counters.comp_out[dir], to_forward);
+ _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.shared->comp_out[dir], to_forward);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->comp_out[dir], to_forward);
} else {
- _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp[dir], consumed);
- _HA_ATOMIC_ADD(&s->be->be_counters.comp_byp[dir], consumed);
+ _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.shared->comp_byp[dir], consumed);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->comp_byp[dir], consumed);
}
return to_forward;
goto end;
if (strm_fe(s)->mode == PR_MODE_HTTP)
- _HA_ATOMIC_INC(&strm_fe(s)->fe_counters.p.http.comp_rsp);
+ _HA_ATOMIC_INC(&strm_fe(s)->fe_counters.shared->p.http.comp_rsp);
if ((s->flags & SF_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP))
- _HA_ATOMIC_INC(&s->be->be_counters.p.http.comp_rsp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->p.http.comp_rsp);
end:
return 1;
}
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = read_freq_ctr(&px->fe_counters.req_per_sec);
+ smp->data.u.sint = read_freq_ctr(&px->fe_counters.shared->req_per_sec);
return 1;
}
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = read_freq_ctr(&px->fe_counters.sess_per_sec);
+ smp->data.u.sint = read_freq_ctr(&px->fe_counters.shared->sess_per_sec);
return 1;
}
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
p->id, s->id,
(s->cur_state != SRV_ST_STOPPED) ? "UP" : "DOWN",
- s->cur_sess, s->queueslength, s->counters.cum_sess);
+ s->cur_sess, s->queueslength, HA_ATOMIC_LOAD(&s->counters.shared->cum_sess));
ha_warning("%s\n", trash.area);
send_log(p, LOG_NOTICE, "%s\n", trash.area);
s = s->next;
chunk_printf(&trash,
"SIGHUP: Proxy %s has no servers. Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id,
- p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, HA_ATOMIC_LOAD(&p->fe_counters.shared->cum_conn), HA_ATOMIC_LOAD(&p->be_counters.shared->cum_sess));
} else if (p->srv_act == 0) {
chunk_printf(&trash,
"SIGHUP: Proxy %s %s ! Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id,
(p->srv_bck) ? "is running on backup servers" : "has no server available",
- p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, HA_ATOMIC_LOAD(&p->fe_counters.shared->cum_conn), HA_ATOMIC_LOAD(&p->be_counters.shared->cum_sess));
} else {
chunk_printf(&trash,
"SIGHUP: Proxy %s has %d active servers and %d backup servers available."
" Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
p->id, p->srv_act, p->srv_bck,
- p->feconn, p->beconn, p->totpend, p->queueslength, p->fe_counters.cum_conn, p->be_counters.cum_sess);
+ p->feconn, p->beconn, p->totpend, p->queueslength, HA_ATOMIC_LOAD(&p->fe_counters.shared->cum_conn), HA_ATOMIC_LOAD(&p->be_counters.shared->cum_sess));
}
ha_warning("%s\n", trash.area);
send_log(p, LOG_NOTICE, "%s\n", trash.area);
/* let's log the request time */
s->logs.request_ts = now_ns;
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->intercepted_req);
}
done:
goto leave;
fail_rewrite:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
ret = ACT_RET_ERR;
goto leave;
fail_rewrite:
- _HA_ATOMIC_ADD(&sess->fe->fe_counters.failed_rewrites, 1);
+ _HA_ATOMIC_ADD(&sess->fe->fe_counters.shared->failed_rewrites, 1);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_ADD(&s->be->be_counters.failed_rewrites, 1);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->failed_rewrites, 1);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_ADD(&sess->listener->counters->failed_rewrites, 1);
+ _HA_ATOMIC_ADD(&sess->listener->counters->shared->failed_rewrites, 1);
if (objt_server(s->target))
- _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.failed_rewrites, 1);
+ _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.shared->failed_rewrites, 1);
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
ret = ACT_RET_ERR;
goto leave;
fail_rewrite:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
ret = ACT_RET_ERR;
struct session *sess, struct stream *s, int flags)
{
if (http_res_set_status(rule->arg.http.i, rule->arg.http.str, s) == -1) {
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
if (!(s->flags & SF_ERR_MASK))
s->req.analysers &= AN_REQ_FLT_END;
s->res.analysers &= AN_RES_FLT_END;
- _HA_ATOMIC_INC(&s->be->be_counters.denied_req);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_req);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->denied_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_req);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
req->analysers &= AN_REQ_FLT_END;
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->intercepted_req);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_LOCAL;
goto leave;
fail_rewrite:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
if (!(msg->flags & HTTP_MSGF_SOFT_RW)) {
ret = ACT_RET_ERR;
goto leave;
fail_rewrite:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
if (!(msg->flags & HTTP_MSGF_SOFT_RW)) {
ret = ACT_RET_ERR;
req->analysers &= AN_REQ_FLT_END;
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->intercepted_req);
}
return ACT_RET_ABRT;
struct acl_cond *cond;
s->flags |= SF_MONITOR;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->intercepted_req);
/* Check if we want to fail this monitor request or not */
list_for_each_entry(cond, &sess->fe->mon_fail_cond, list) {
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
stream_report_term_evt(s->scb, strm_tevt_type_internal_err);
goto return_prx_cond;
return_bad_req:
txn->status = 400;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
stream_report_term_evt(s->scb, strm_tevt_type_proto_err);
/* fall through */
/* Proceed with the applets now. */
if (unlikely(objt_applet(s->target))) {
if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->intercepted_req);
if (http_handle_expect_hdr(s, htx, msg) == -1)
goto return_int_err;
if (!req->analyse_exp)
req->analyse_exp = tick_add(now_ms, 0);
stream_inc_http_err_ctr(s);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_req);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.denied_req);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->denied_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_req);
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
goto done_without_exp;
s->logs.request_ts = now_ns;
stream_inc_http_err_ctr(s);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_req);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.denied_req);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->denied_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_req);
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
goto return_prx_err;
return_fail_rewrite:
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
/* fall through */
return_int_err:
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
goto return_prx_err;
return_bad_req:
txn->status = 400;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
/* fall through */
return_fail_rewrite:
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
/* fall through */
return_int_err:
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
http_set_term_flags(s);
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (s->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
goto return_prx_err;
return_bad_req: /* let's centralize all bad requests */
txn->status = 400;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
/* fall through */
return 0;
return_cli_abort:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.cli_aborts);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->cli_aborts);
if (!(s->flags & SF_ERR_MASK))
s->flags |= ((req->flags & CF_READ_TIMEOUT) ? SF_ERR_CLITO : SF_ERR_CLICL);
status = 400;
goto return_prx_cond;
return_srv_abort:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.srv_aborts);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->srv_aborts);
if (!(s->flags & SF_ERR_MASK))
s->flags |= ((req->flags & CF_WRITE_TIMEOUT) ? SF_ERR_SRVTO : SF_ERR_SRVCL);
status = 502;
return_int_err:
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.internal_errors);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->internal_errors);
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
status = 500;
goto return_prx_cond;
return_bad_req:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
status = 400;
/* fall through */
s->flags &= ~SF_CURR_SESS;
_HA_ATOMIC_DEC(&__objt_server(s->target)->cur_sess);
}
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.retries);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->retries);
}
- _HA_ATOMIC_INC(&s->be->be_counters.retries);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->retries);
req = &s->req;
res = &s->res;
if (s->flags & SF_SRV_REUSED)
goto abort_keep_alive;
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
/* if the server refused the early data, just send a 425 */
if (conn && conn->err_code == CO_ER_SSL_EARLY_FAILED)
return 0;
}
}
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
txn->status = 504;
stream_inc_http_fail_ctr(s);
/* 3: client abort with an abortonclose */
else if ((s->scb->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) && (s->scb->flags & SC_FL_SHUT_DONE) &&
(s->scf->flags & (SC_FL_EOS|SC_FL_ABRT_DONE))) {
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.cli_aborts);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->cli_aborts);
txn->status = 400;
if (s->flags & SF_SRV_REUSED)
goto abort_keep_alive;
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
txn->status = 502;
stream_inc_http_fail_ctr(s);
if (s->flags & SF_SRV_REUSED)
goto abort_keep_alive;
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
rep->analysers &= AN_RES_FLT_END;
if (!(s->flags & SF_ERR_MASK))
if (n < 1 || n > 5)
n = 0;
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.p.http.rsp[n]);
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.p.http.cum_req);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->p.http.rsp[n]);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->p.http.cum_req);
}
/*
return 1;
return_int_err:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.internal_errors);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->internal_errors);
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
return 0;
}
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
txn->status = 502;
stream_inc_http_fail_ctr(s);
return 1;
deny:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_resp);
- _HA_ATOMIC_INC(&s->be->be_counters.denied_resp);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->denied_resp);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_resp);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.denied_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->denied_resp);
stream_report_term_evt(s->scb, strm_tevt_type_intercepted);
goto return_prx_err;
return_fail_rewrite:
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_rewrites);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_rewrites);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_rewrites);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_rewrites);
/* fall through */
return_int_err:
txn->status = 500;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.internal_errors);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->internal_errors);
stream_report_term_evt(s->scb, strm_tevt_type_internal_err);
goto return_prx_err;
s->logs.t_data = -1; /* was not a valid response */
txn->status = 502;
stream_inc_http_fail_ctr(s);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target)) {
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP);
}
stream_report_term_evt(s->scb, strm_tevt_type_proto_err);
return 0;
return_srv_abort:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.srv_aborts);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->srv_aborts);
stream_inc_http_fail_ctr(s);
if (!(s->flags & SF_ERR_MASK))
s->flags |= ((res->flags & CF_READ_TIMEOUT) ? SF_ERR_SRVTO : SF_ERR_SRVCL);
goto return_error;
return_cli_abort:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.cli_aborts);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->cli_aborts);
if (!(s->flags & SF_ERR_MASK))
s->flags |= ((res->flags & CF_WRITE_TIMEOUT) ? SF_ERR_CLITO : SF_ERR_CLICL);
goto return_error;
return_int_err:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.internal_errors);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->internal_errors);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
stream_report_term_evt(s->scb, strm_tevt_type_internal_err);
goto return_error;
return_bad_res:
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target)) {
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP);
}
stream_inc_http_fail_ctr(s);
req->analysers &= AN_REQ_FLT_END;
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->intercepted_req);
}
out:
txn->status = 408;
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_CLITO;
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
goto abort;
abort_res:
}
#endif
if (p && p->fe_sps_lim) {
- int max = freq_ctr_remain(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0);
+ int max = freq_ctr_remain(&p->fe_counters.shared->sess_per_sec, p->fe_sps_lim, 0);
if (unlikely(!max)) {
/* frontend accept rate limit was reached */
- expire = tick_add(now_ms, next_event_delay(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0));
+ expire = tick_add(now_ms, next_event_delay(&p->fe_counters.shared->sess_per_sec, p->fe_sps_lim, 0));
goto limit_proxy;
}
dequeue_all_listeners();
if (p && !MT_LIST_ISEMPTY(&p->listener_queue) &&
- (!p->fe_sps_lim || freq_ctr_remain(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0) > 0))
+ (!p->fe_sps_lim || freq_ctr_remain(&p->fe_counters.shared->sess_per_sec, p->fe_sps_lim, 0) > 0))
dequeue_proxy_listeners(p, 0);
}
return;
dequeue_all_listeners();
if (fe && !MT_LIST_ISEMPTY(&fe->listener_queue) &&
- (!fe->fe_sps_lim || freq_ctr_remain(&fe->fe_counters.sess_per_sec, fe->fe_sps_lim, 0) > 0))
+ (!fe->fe_sps_lim || freq_ctr_remain(&fe->fe_counters.shared->sess_per_sec, fe->fe_sps_lim, 0) > 0))
dequeue_proxy_listeners(fe, 0);
else if (fe) {
unsigned int wait;
int expire = TICK_ETERNITY;
if (fe->task && fe->fe_sps_lim &&
- (wait = next_event_delay(&fe->fe_counters.sess_per_sec,fe->fe_sps_lim, 0))) {
+ (wait = next_event_delay(&fe->fe_counters.shared->sess_per_sec,fe->fe_sps_lim, 0))) {
/* we're blocking because a limit was reached on the number of
* requests/s on the frontend. We want to re-check ASAP, which
* means in 1 ms before estimated expiration date, because the
parse_error:
if (l->counters)
- _HA_ATOMIC_INC(&l->counters->failed_req);
- _HA_ATOMIC_INC(&frontend->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&l->counters->shared->failed_req);
+ _HA_ATOMIC_INC(&frontend->fe_counters.shared->failed_req);
goto error;
cli_abort:
if (l->counters)
- _HA_ATOMIC_INC(&l->counters->cli_aborts);
- _HA_ATOMIC_INC(&frontend->fe_counters.cli_aborts);
+ _HA_ATOMIC_INC(&l->counters->shared->cli_aborts);
+ _HA_ATOMIC_INC(&frontend->fe_counters.shared->cli_aborts);
error:
se_fl_set(appctx->sedesc, SE_FL_ERROR);
}
session_inc_http_req_ctr(sess);
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.p.http.rsp[5]);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->p.http.rsp[5]);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
h1c->errcode = 500;
ret = h1_send_error(h1c);
session_inc_http_req_ctr(sess);
session_inc_http_err_ctr(sess);
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.p.http.rsp[4]);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->p.http.rsp[4]);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
if (!h1c->errcode)
h1c->errcode = 400;
session_inc_http_req_ctr(sess);
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.p.http.rsp[4]);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->p.http.rsp[4]);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
h1c->errcode = 501;
ret = h1_send_error(h1c);
session_inc_http_req_ctr(sess);
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.p.http.rsp[4]);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->p.http.rsp[4]);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
h1c->errcode = 408;
ret = h1_send_error(h1c);
ha_free(&px->id);
LIST_DEL_INIT(&px->global_list);
drop_file_name(&px->conf.file);
+ ha_free(&px->fe_counters.shared);
+ ha_free(&px->be_counters.shared);
ha_free(&px->check_command);
ha_free(&px->check_path);
ha_free(&px->cookie_name);
free(l->name);
free(l->label);
free(l->per_thr);
- free(l->counters);
+ if (l->counters) {
+ free(l->counters->shared);
+ free(l->counters);
+ }
task_destroy(l->rx.rhttp.task);
EXTRA_COUNTERS_FREE(l->extra_counters);
init_new_proxy(px);
last_change = ns_to_sec(now_ns);
- if (cap & PR_CAP_FE)
- px->fe_counters.last_change = last_change;
- if (cap & PR_CAP_BE)
- px->be_counters.last_change = last_change;
+ /* allocate private memory for shared counters: used as a fallback
+ * or when sharing is disabled. If sharing is enabled pointers will
+ * be updated to point to the proper shared memory location during
+ * proxy postparsing, see proxy_postparse()
+ */
+ if (cap & PR_CAP_FE) {
+ px->fe_counters.shared = calloc(1, sizeof(*px->fe_counters.shared));
+ if (!px->fe_counters.shared) {
+ memprintf(errmsg, "out of memory");
+ goto fail;
+ }
+ HA_ATOMIC_STORE(&px->fe_counters.shared->last_change, last_change);
+ }
+ if (cap & (PR_CAP_FE|PR_CAP_BE)) {
+ /* by default stream->be points to stream->fe, thus proxy
+ * be_counters may be used even if the proxy lacks the backend
+ * capability
+ */
+ px->be_counters.shared = calloc(1, sizeof(*px->be_counters.shared));
+ if (!px->be_counters.shared) {
+ memprintf(errmsg, "out of memory");
+ goto fail;
+ }
+
+ HA_ATOMIC_STORE(&px->be_counters.shared->last_change, last_change);
+ }
+
if (name) {
px->id = strdup(name);
if (!px->id) {
- memprintf(errmsg, "proxy '%s': out of memory", name);
- return 0;
+ memprintf(errmsg, "out of memory");
+ goto fail;
}
}
LIST_APPEND(&proxies, &px->global_list);
return 1;
+
+ fail:
+ if (name)
+ memprintf(errmsg, "proxy '%s': %s", name, *errmsg);
+
+ ha_free(&px->id);
+ ha_free(&px->fe_counters.shared);
+ ha_free(&px->be_counters.shared);
+
+ return 0;
}
/* Allocates a new proxy <name> of type <cap>.
* the data plane but on the control plane.
*/
if (p->cap & PR_CAP_FE)
- cum_conn = p->fe_counters.cum_conn;
+ cum_conn = HA_ATOMIC_LOAD(&p->fe_counters.shared->cum_conn);
if (p->cap & PR_CAP_BE)
- cum_sess = p->be_counters.cum_sess;
+ cum_sess = HA_ATOMIC_LOAD(&p->be_counters.shared->cum_sess);
if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP || p->mode == PR_MODE_SYSLOG || p->mode == PR_MODE_SPOP) && !(p->cap & PR_CAP_INT))
ha_warning("Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
goto out;
if (p->fe_sps_lim &&
- (wait = next_event_delay(&p->fe_counters.sess_per_sec, p->fe_sps_lim, 0))) {
+ (wait = next_event_delay(&p->fe_counters.shared->sess_per_sec, p->fe_sps_lim, 0))) {
/* we're blocking because a limit was reached on the number of
* requests/s on the frontend. We want to re-check ASAP, which
* means in 1 ms before estimated expiration date, because the
dump_server_addr(&srv->check.addr, srv_check_addr);
dump_server_addr(&srv->agent.addr, srv_agent_addr);
- srv_time_since_last_change = ns_to_sec(now_ns) - srv->counters.last_change;
+ srv_time_since_last_change = ns_to_sec(now_ns) - HA_ATOMIC_LOAD(&srv->counters.shared->last_change);
bk_f_forced_id = px->options & PR_O_FORCED_ID ? 1 : 0;
srv_f_forced_id = srv->flags & SRV_F_FORCED_ID ? 1 : 0;
unsigned int srv_dynamic_maxconn(const struct server *s)
{
unsigned int max;
+ unsigned long last_change;
if (s->proxy->beconn >= s->proxy->fullconn)
/* no fullconn or proxy is full */
else max = MAX(s->minconn,
s->proxy->beconn * s->maxconn / s->proxy->fullconn);
+ last_change = HA_ATOMIC_LOAD(&s->counters.shared->last_change);
+
if ((s->cur_state == SRV_ST_STARTING) &&
- ns_to_sec(now_ns) < s->counters.last_change + s->slowstart &&
- ns_to_sec(now_ns) >= s->counters.last_change) {
+ ns_to_sec(now_ns) < last_change + s->slowstart &&
+ ns_to_sec(now_ns) >= last_change) {
unsigned int ratio;
- ratio = 100 * (ns_to_sec(now_ns) - s->counters.last_change) / s->slowstart;
+ ratio = 100 * (ns_to_sec(now_ns) - last_change) / s->slowstart;
max = MAX(1, max * ratio / 100);
}
return max;
int srv_downtime(const struct server *s)
{
- if ((s->cur_state != SRV_ST_STOPPED) || s->counters.last_change >= ns_to_sec(now_ns)) // ignore negative time
+ unsigned long last_change = HA_ATOMIC_LOAD(&s->counters.shared->last_change);
+
+ if ((s->cur_state != SRV_ST_STOPPED) || last_change >= ns_to_sec(now_ns)) // ignore negative time
return s->down_time;
- return ns_to_sec(now_ns) - s->counters.last_change + s->down_time;
+ return ns_to_sec(now_ns) - last_change + s->down_time;
}
int srv_getinter(const struct check *check)
*/
void server_recalc_eweight(struct server *sv, int must_update)
{
+ unsigned long last_change = HA_ATOMIC_LOAD(&sv->counters.shared->last_change);
struct proxy *px = sv->proxy;
unsigned w;
- if (ns_to_sec(now_ns) < sv->counters.last_change || ns_to_sec(now_ns) >= sv->counters.last_change + sv->slowstart) {
+ if (ns_to_sec(now_ns) < last_change || ns_to_sec(now_ns) >= last_change + sv->slowstart) {
/* go to full throttle if the slowstart interval is reached unless server is currently down */
if ((sv->cur_state != SRV_ST_STOPPED) && (sv->next_state == SRV_ST_STARTING))
sv->next_state = SRV_ST_RUNNING;
if ((sv->cur_state == SRV_ST_STOPPED) && (sv->next_state == SRV_ST_STARTING) && (px->lbprm.algo & BE_LB_PROP_DYN))
w = 1;
else if ((sv->next_state == SRV_ST_STARTING) && (px->lbprm.algo & BE_LB_PROP_DYN))
- w = (px->lbprm.wdiv * (ns_to_sec(now_ns) - sv->counters.last_change) + sv->slowstart) / sv->slowstart;
+ w = (px->lbprm.wdiv * (ns_to_sec(now_ns) - last_change) + sv->slowstart) / sv->slowstart;
else
w = px->lbprm.wdiv;
struct server *new_server(struct proxy *proxy)
{
struct server *srv;
+ struct be_counters_shared *scounters;
srv = calloc(1, sizeof *srv);
if (!srv)
return NULL;
+ scounters = calloc(1, sizeof(*scounters));
+ if (!scounters) {
+ ha_free(&srv);
+ return NULL;
+ }
+
srv_take(srv);
srv->obj_type = OBJ_TYPE_SERVER;
srv->rid = 0; /* rid defaults to 0 */
srv->next_state = SRV_ST_RUNNING; /* early server setup */
- srv->counters.last_change = ns_to_sec(now_ns);
+ srv->counters.shared = scounters;
+ HA_ATOMIC_STORE(&srv->counters.shared->last_change, ns_to_sec(now_ns));
srv->check.obj_type = OBJ_TYPE_CHECK;
srv->check.status = HCHK_STATUS_INI;
free(srv->resolvers_id);
free(srv->addr_node.key);
free(srv->lb_nodes);
+ free(srv->counters.shared);
if (srv->log_target) {
deinit_log_target(srv->log_target);
free(srv->log_target);
if (srv->next_state == SRV_ST_STARTING) {
task_schedule(srv->warmup,
tick_add(now_ms,
- MS_TO_TICKS(MAX(1000, (ns_to_sec(now_ns) - srv->counters.last_change)) / 20)));
+ MS_TO_TICKS(MAX(1000, (ns_to_sec(now_ns) - HA_ATOMIC_LOAD(&srv->counters.shared->last_change))) / 20)));
}
}
/* check if server stats must be updated due the the server state change */
if (srv_prev_state != s->cur_state) {
if (srv_prev_state == SRV_ST_STOPPED) {
+ unsigned long last_change = HA_ATOMIC_LOAD(&s->counters.shared->last_change);
+
/* server was down and no longer is */
- if (s->counters.last_change < ns_to_sec(now_ns)) // ignore negative times
- s->down_time += ns_to_sec(now_ns) - s->counters.last_change;
+ if (last_change < ns_to_sec(now_ns)) // ignore negative times
+ s->down_time += ns_to_sec(now_ns) - last_change;
_srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_UP, cb_data.common, s);
}
else if (s->cur_state == SRV_ST_STOPPED) {
/* server was up and is currently down */
- s->counters.down_trans++;
+ HA_ATOMIC_INC(&s->counters.shared->down_trans);
_srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, cb_data.common, s);
}
if (s->cur_state != SRV_ST_RUNNING && s->proxy->ready_srv == s)
HA_ATOMIC_STORE(&s->proxy->ready_srv, NULL);
- s->counters.last_change = ns_to_sec(now_ns);
+ HA_ATOMIC_STORE(&s->counters.shared->last_change, ns_to_sec(now_ns));
/* publish the state change */
_srv_event_hdl_prepare_state(&cb_data.state,
if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
set_backend_down(s->proxy); /* backend going down */
else if (!prev_srv_count && (s->proxy->srv_bck || s->proxy->srv_act)) {
+ unsigned long last_change = HA_ATOMIC_LOAD(&s->proxy->be_counters.shared->last_change);
+
/* backend was down and is back up again:
* no helper function, updating last_change and backend downtime stats
*/
- if (s->proxy->be_counters.last_change < ns_to_sec(now_ns)) // ignore negative times
- s->proxy->down_time += ns_to_sec(now_ns) - s->proxy->be_counters.last_change;
- s->proxy->be_counters.last_change = ns_to_sec(now_ns);
+ if (last_change < ns_to_sec(now_ns)) // ignore negative times
+ s->proxy->down_time += ns_to_sec(now_ns) - last_change;
+ HA_ATOMIC_STORE(&s->proxy->be_counters.shared->last_change, ns_to_sec(now_ns));
}
}
srv_adm_set_drain(srv);
}
- srv->counters.last_change = ns_to_sec(now_ns) - srv_last_time_change;
+ HA_ATOMIC_STORE(&srv->counters.shared->last_change, ns_to_sec(now_ns) - srv_last_time_change);
srv->check.status = srv_check_status;
srv->check.result = srv_check_result;
struct server *srv;
struct proxy *px;
struct ist token;
- char *base_off;
+ char *base_off, *base_off_shared;
char *guid;
int i, off;
if (domain == STFILE_DOMAIN_PX_FE) {
if (!(px->cap & PR_CAP_FE))
return 0; /* silently ignored fe/be mismatch */
+
+ base_off_shared = (char *)px->fe_counters.shared;
base_off = (char *)&px->fe_counters;
+
off = 0;
}
else if (domain == STFILE_DOMAIN_PX_BE) {
if (!(px->cap & PR_CAP_BE))
return 0; /* silently ignored fe/be mismatch */
+
+ base_off_shared = (char *)px->be_counters.shared;
base_off = (char *)&px->be_counters;
+
off = 1;
}
else {
if (!li->counters)
return 0;
+ base_off_shared = (char *)li->counters->shared;
base_off = (char *)li->counters;
+
off = 0;
break;
goto err;
srv = __objt_server(node->obj_type);
+ base_off_shared = (char *)srv->counters.shared;
base_off = (char *)&srv->counters;
+
off = 1;
break;
if (!col)
continue;
- load_ctr(col, token, base_off + col->metric.offset[off]);
+ if (col->flags & STAT_COL_FL_SHARED)
+ load_ctr(col, token, base_off_shared + col->metric.offset[off]);
+ else
+ load_ctr(col, token, base_off + col->metric.offset[off]);
}
return 0;
.metric.offset[1] = offsetof(struct be_counters, offset_f), \
}
+/* Define a new generic shared metric for both frontend and backend sides. */
+#define ME_NEW_PX_SHARED(name_f, alt_n, nature, format, offset_f, cap_f, desc_f)\
+ { \
+ ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \
+ .flags = STAT_COL_FL_GENERIC | STAT_COL_FL_SHARED, \
+ .metric.offset[0] = offsetof(struct fe_counters_shared, offset_f), \
+ .metric.offset[1] = offsetof(struct be_counters_shared, offset_f), \
+ }
+
/* Define a new generic metric for frontend side only. */
#define ME_NEW_FE(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \
{ \
.metric.offset[0] = offsetof(struct fe_counters, offset_f), \
}
+/* Define a new generic shared metric for frontend side only. */
+#define ME_NEW_FE_SHARED(name_f, alt_n, nature, format, offset_f, cap_f, desc_f)\
+ { \
+ ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \
+ .flags = STAT_COL_FL_GENERIC | STAT_COL_FL_SHARED, \
+ .metric.offset[0] = offsetof(struct fe_counters_shared, offset_f), \
+ }
+
/* Define a new generic metric for backend side only. */
#define ME_NEW_BE(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \
{ \
.metric.offset[1] = offsetof(struct be_counters, offset_f), \
}
+/* Define a new generic shared metric for backend side only. */
+#define ME_NEW_BE_SHARED(name_f, alt_n, nature, format, offset_f, cap_f, desc_f)\
+ { \
+ ME_NEW_COMMON(name_f, alt_n, nature, format, offset_f, cap_f, desc_f) \
+ .flags = STAT_COL_FL_GENERIC | STAT_COL_FL_SHARED, \
+ .metric.offset[1] = offsetof(struct be_counters_shared, offset_f), \
+ }
+
const struct stat_col stat_cols_px[ST_I_PX_MAX] = {
[ST_I_PX_PXNAME] = { .name = "pxname", .alt_name = NULL, .desc = "Proxy name" },
[ST_I_PX_SVNAME] = { .name = "svname", .alt_name = NULL, .desc = "Server name" },
[ST_I_PX_SCUR] = { .name = "scur", .alt_name = "current_sessions", .desc = "Number of current sessions on the frontend, backend or server", .cap = STATS_PX_CAP_LFBS},
[ST_I_PX_SMAX] = { .name = "smax", .alt_name = "max_sessions", .desc = "Highest value of current sessions encountered since process started", .cap = STATS_PX_CAP_LFBS },
[ST_I_PX_SLIM] = { .name = "slim", .alt_name = "limit_sessions", .desc = "Frontend/listener/server's maxconn, backend's fullconn", .cap = STATS_PX_CAP_LFBS },
- [ST_I_PX_STOT] = ME_NEW_PX("stot", "sessions_total", FN_COUNTER, FF_U64, cum_sess, STATS_PX_CAP_LFBS, "Total number of sessions since process started"),
- [ST_I_PX_BIN] = ME_NEW_PX("bin", "bytes_in_total", FN_COUNTER, FF_U64, bytes_in, STATS_PX_CAP_LFBS, "Total number of request bytes since process started"),
- [ST_I_PX_BOUT] = ME_NEW_PX("bout", "bytes_out_total", FN_COUNTER, FF_U64, bytes_out, STATS_PX_CAP_LFBS, "Total number of response bytes since process started"),
- [ST_I_PX_DREQ] = ME_NEW_PX("dreq", "requests_denied_total", FN_COUNTER, FF_U64, denied_req, STATS_PX_CAP_LFB_, "Total number of denied requests since process started"),
- [ST_I_PX_DRESP] = ME_NEW_PX("dresp", "responses_denied_total", FN_COUNTER, FF_U64, denied_resp, STATS_PX_CAP_LFBS, "Total number of denied responses since process started"),
- [ST_I_PX_EREQ] = ME_NEW_FE("ereq", "request_errors_total", FN_COUNTER, FF_U64, failed_req, STATS_PX_CAP_LF__, "Total number of invalid requests since process started"),
- [ST_I_PX_ECON] = ME_NEW_BE("econ", "connection_errors_total", FN_COUNTER, FF_U64, failed_conns, STATS_PX_CAP___BS, "Total number of failed connections to server since the worker process started"),
- [ST_I_PX_ERESP] = ME_NEW_BE("eresp", "response_errors_total", FN_COUNTER, FF_U64, failed_resp, STATS_PX_CAP___BS, "Total number of invalid responses since the worker process started"),
- [ST_I_PX_WRETR] = ME_NEW_BE("wretr", "retry_warnings_total", FN_COUNTER, FF_U64, retries, STATS_PX_CAP___BS, "Total number of server connection retries since the worker process started"),
- [ST_I_PX_WREDIS] = ME_NEW_BE("wredis", "redispatch_warnings_total", FN_COUNTER, FF_U64, redispatches, STATS_PX_CAP___BS, "Total number of server redispatches due to connection failures since the worker process started"),
+ [ST_I_PX_STOT] = ME_NEW_PX_SHARED("stot", "sessions_total", FN_COUNTER, FF_U64, cum_sess, STATS_PX_CAP_LFBS, "Total number of sessions since process started"),
+ [ST_I_PX_BIN] = ME_NEW_PX_SHARED("bin", "bytes_in_total", FN_COUNTER, FF_U64, bytes_in, STATS_PX_CAP_LFBS, "Total number of request bytes since process started"),
+ [ST_I_PX_BOUT] = ME_NEW_PX_SHARED("bout", "bytes_out_total", FN_COUNTER, FF_U64, bytes_out, STATS_PX_CAP_LFBS, "Total number of response bytes since process started"),
+ [ST_I_PX_DREQ] = ME_NEW_PX_SHARED("dreq", "requests_denied_total", FN_COUNTER, FF_U64, denied_req, STATS_PX_CAP_LFB_, "Total number of denied requests since process started"),
+ [ST_I_PX_DRESP] = ME_NEW_PX_SHARED("dresp", "responses_denied_total", FN_COUNTER, FF_U64, denied_resp, STATS_PX_CAP_LFBS, "Total number of denied responses since process started"),
+ [ST_I_PX_EREQ] = ME_NEW_FE_SHARED("ereq", "request_errors_total", FN_COUNTER, FF_U64, failed_req, STATS_PX_CAP_LF__, "Total number of invalid requests since process started"),
+ [ST_I_PX_ECON] = ME_NEW_BE_SHARED("econ", "connection_errors_total", FN_COUNTER, FF_U64, failed_conns, STATS_PX_CAP___BS, "Total number of failed connections to server since the worker process started"),
+ [ST_I_PX_ERESP] = ME_NEW_BE_SHARED("eresp", "response_errors_total", FN_COUNTER, FF_U64, failed_resp, STATS_PX_CAP___BS, "Total number of invalid responses since the worker process started"),
+ [ST_I_PX_WRETR] = ME_NEW_BE_SHARED("wretr", "retry_warnings_total", FN_COUNTER, FF_U64, retries, STATS_PX_CAP___BS, "Total number of server connection retries since the worker process started"),
+ [ST_I_PX_WREDIS] = ME_NEW_BE_SHARED("wredis", "redispatch_warnings_total", FN_COUNTER, FF_U64, redispatches, STATS_PX_CAP___BS, "Total number of server redispatches due to connection failures since the worker process started"),
[ST_I_PX_STATUS] = { .name = "status", .alt_name = "status", .desc = "Frontend/listen status: OPEN/WAITING/FULL/STOP; backend: UP/DOWN; server: last check status", .cap = STATS_PX_CAP_LFBS },
[ST_I_PX_WEIGHT] = { .name = "weight", .alt_name = "weight", .desc = "Server's effective weight, or sum of active servers' effective weights for a backend", .cap = STATS_PX_CAP___BS },
[ST_I_PX_ACT] = { .name = "act", .alt_name = "active_servers", .desc = "Total number of active UP servers with a non-zero weight", .cap = STATS_PX_CAP___BS },
[ST_I_PX_BCK] = { .name = "bck", .alt_name = "backup_servers", .desc = "Total number of backup UP servers with a non-zero weight", .cap = STATS_PX_CAP___BS },
- [ST_I_PX_CHKFAIL] = ME_NEW_BE("chkfail", "check_failures_total", FN_COUNTER, FF_U64, failed_checks, STATS_PX_CAP____S, "Total number of failed individual health checks per server/backend, since the worker process started"),
- [ST_I_PX_CHKDOWN] = ME_NEW_BE("chkdown", "check_up_down_total", FN_COUNTER, FF_U64, down_trans, STATS_PX_CAP___BS, "Total number of failed checks causing UP to DOWN server transitions, per server/backend, since the worker process started"),
- [ST_I_PX_LASTCHG] = ME_NEW_BE("lastchg", "check_last_change_seconds", FN_AGE, FF_U32, last_change, STATS_PX_CAP___BS, "How long ago the last server state changed, in seconds"),
+ [ST_I_PX_CHKFAIL] = ME_NEW_BE_SHARED("chkfail", "check_failures_total", FN_COUNTER, FF_U64, failed_checks, STATS_PX_CAP____S, "Total number of failed individual health checks per server/backend, since the worker process started"),
+ [ST_I_PX_CHKDOWN] = ME_NEW_BE_SHARED("chkdown", "check_up_down_total", FN_COUNTER, FF_U64, down_trans, STATS_PX_CAP___BS, "Total number of failed checks causing UP to DOWN server transitions, per server/backend, since the worker process started"),
+ [ST_I_PX_LASTCHG] = ME_NEW_BE_SHARED("lastchg", "check_last_change_seconds", FN_AGE, FF_U32, last_change, STATS_PX_CAP___BS, "How long ago the last server state changed, in seconds"),
[ST_I_PX_DOWNTIME] = { .name = "downtime", .alt_name = "downtime_seconds_total", .desc = "Total time spent in DOWN state, for server or backend", .cap = STATS_PX_CAP___BS },
[ST_I_PX_QLIMIT] = { .name = "qlimit", .alt_name = "queue_limit", .desc = "Limit on the number of connections in queue, for servers only (maxqueue argument)", .cap = STATS_PX_CAP____S },
[ST_I_PX_PID] = { .name = "pid", .alt_name = NULL, .desc = "Relative worker process number (1)" },
[ST_I_PX_IID] = { .name = "iid", .alt_name = NULL, .desc = "Frontend or Backend numeric identifier ('id' setting)" },
[ST_I_PX_SID] = { .name = "sid", .alt_name = NULL, .desc = "Server numeric identifier ('id' setting)" },
[ST_I_PX_THROTTLE] = { .name = "throttle", .alt_name = "current_throttle", .desc = "Throttling ratio applied to a server's maxconn and weight during the slowstart period (0 to 100%)", .cap = STATS_PX_CAP____S },
- [ST_I_PX_LBTOT] = ME_NEW_BE("lbtot", "loadbalanced_total", FN_COUNTER, FF_U64, cum_lbconn, STATS_PX_CAP___BS, "Total number of requests routed by load balancing since the worker process started (ignores queue pop and stickiness)"),
+ [ST_I_PX_LBTOT] = ME_NEW_BE_SHARED("lbtot", "loadbalanced_total", FN_COUNTER, FF_U64, cum_lbconn, STATS_PX_CAP___BS, "Total number of requests routed by load balancing since the worker process started (ignores queue pop and stickiness)"),
[ST_I_PX_TRACKED] = { .name = "tracked", .alt_name = NULL, .desc = "Name of the other server this server tracks for its state" },
[ST_I_PX_TYPE] = { .name = "type", .alt_name = NULL, .desc = "Type of the object (Listener, Frontend, Backend, Server)" },
- [ST_I_PX_RATE] = ME_NEW_PX("rate", "current_session_rate", FN_RATE, FF_U32, sess_per_sec, STATS_PX_CAP__FBS, "Total number of sessions processed by this object over the last second (sessions for listeners/frontends, requests for backends/servers)"),
+ [ST_I_PX_RATE] = ME_NEW_PX_SHARED("rate", "current_session_rate", FN_RATE, FF_U32, sess_per_sec, STATS_PX_CAP__FBS, "Total number of sessions processed by this object over the last second (sessions for listeners/frontends, requests for backends/servers)"),
[ST_I_PX_RATE_LIM] = { .name = "rate_lim", .alt_name = "limit_session_rate", .desc = "Limit on the number of sessions accepted in a second (frontend only, 'rate-limit sessions' setting)", .cap = STATS_PX_CAP__F__ },
[ST_I_PX_RATE_MAX] = { .name = "rate_max", .alt_name = "max_session_rate", .desc = "Highest value of sessions per second observed since the worker process started", .cap = STATS_PX_CAP__FBS },
[ST_I_PX_CHECK_STATUS] = { .name = "check_status", .alt_name = "check_status", .desc = "Status report of the server's latest health check, prefixed with '*' if a check is currently in progress", .cap = STATS_PX_CAP____S },
[ST_I_PX_CHECK_CODE] = { .name = "check_code", .alt_name = "check_code", .desc = "HTTP/SMTP/LDAP status code reported by the latest server health check", .cap = STATS_PX_CAP____S },
[ST_I_PX_CHECK_DURATION] = { .name = "check_duration", .alt_name = "check_duration_seconds", .desc = "Total duration of the latest server health check, in milliseconds", .cap = STATS_PX_CAP____S },
- [ST_I_PX_HRSP_1XX] = ME_NEW_PX("hrsp_1xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[1], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 100-199 returned by this object since the worker process started"),
- [ST_I_PX_HRSP_2XX] = ME_NEW_PX("hrsp_2xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[2], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 200-299 returned by this object since the worker process started"),
- [ST_I_PX_HRSP_3XX] = ME_NEW_PX("hrsp_3xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[3], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 300-399 returned by this object since the worker process started"),
- [ST_I_PX_HRSP_4XX] = ME_NEW_PX("hrsp_4xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[4], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 400-499 returned by this object since the worker process started"),
- [ST_I_PX_HRSP_5XX] = ME_NEW_PX("hrsp_5xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[5], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 500-599 returned by this object since the worker process started"),
- [ST_I_PX_HRSP_OTHER] = ME_NEW_PX("hrsp_other", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[0], STATS_PX_CAP__FBS, "Total number of HTTP responses with status <100, >599 returned by this object since the worker process started (error -1 included)"),
- [ST_I_PX_HANAFAIL] = ME_NEW_BE("hanafail", NULL, FN_COUNTER, FF_U64, failed_hana, STATS_PX_CAP____S, "Total number of failed checks caused by an 'on-error' directive after an 'observe' condition matched"),
- [ST_I_PX_REQ_RATE] = ME_NEW_FE("req_rate", NULL, FN_RATE, FF_U32, req_per_sec, STATS_PX_CAP__F__, "Number of HTTP requests processed over the last second on this object"),
+ [ST_I_PX_HRSP_1XX] = ME_NEW_PX_SHARED("hrsp_1xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[1], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 100-199 returned by this object since the worker process started"),
+ [ST_I_PX_HRSP_2XX] = ME_NEW_PX_SHARED("hrsp_2xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[2], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 200-299 returned by this object since the worker process started"),
+ [ST_I_PX_HRSP_3XX] = ME_NEW_PX_SHARED("hrsp_3xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[3], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 300-399 returned by this object since the worker process started"),
+ [ST_I_PX_HRSP_4XX] = ME_NEW_PX_SHARED("hrsp_4xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[4], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 400-499 returned by this object since the worker process started"),
+ [ST_I_PX_HRSP_5XX] = ME_NEW_PX_SHARED("hrsp_5xx", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[5], STATS_PX_CAP__FBS, "Total number of HTTP responses with status 500-599 returned by this object since the worker process started"),
+ [ST_I_PX_HRSP_OTHER] = ME_NEW_PX_SHARED("hrsp_other", "http_responses_total", FN_COUNTER, FF_U64, p.http.rsp[0], STATS_PX_CAP__FBS, "Total number of HTTP responses with status <100, >599 returned by this object since the worker process started (error -1 included)"),
+ [ST_I_PX_HANAFAIL] = ME_NEW_BE_SHARED("hanafail", NULL, FN_COUNTER, FF_U64, failed_hana, STATS_PX_CAP____S, "Total number of failed checks caused by an 'on-error' directive after an 'observe' condition matched"),
+ [ST_I_PX_REQ_RATE] = ME_NEW_FE_SHARED("req_rate", NULL, FN_RATE, FF_U32, req_per_sec, STATS_PX_CAP__F__, "Number of HTTP requests processed over the last second on this object"),
[ST_I_PX_REQ_RATE_MAX] = { .name = "req_rate_max", .alt_name = "http_requests_rate_max", .desc = "Highest value of http requests observed since the worker process started", .cap = STATS_PX_CAP__F__ },
/* Note: ST_I_PX_REQ_TOT is also displayed on frontend but does not uses a raw counter value, see me_generate_field() for details. */
- [ST_I_PX_REQ_TOT] = ME_NEW_BE("req_tot", "http_requests_total", FN_COUNTER, FF_U64, p.http.cum_req, STATS_PX_CAP__FBS, "Total number of HTTP requests processed by this object since the worker process started"),
- [ST_I_PX_CLI_ABRT] = ME_NEW_BE("cli_abrt", "client_aborts_total", FN_COUNTER, FF_U64, cli_aborts, STATS_PX_CAP___BS, "Total number of requests or connections aborted by the client since the worker process started"),
- [ST_I_PX_SRV_ABRT] = ME_NEW_BE("srv_abrt", "server_aborts_total", FN_COUNTER, FF_U64, srv_aborts, STATS_PX_CAP___BS, "Total number of requests or connections aborted by the server since the worker process started"),
- [ST_I_PX_COMP_IN] = ME_NEW_PX("comp_in", "http_comp_bytes_in_total", FN_COUNTER, FF_U64, comp_in[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes submitted to the HTTP compressor for this object since the worker process started"),
- [ST_I_PX_COMP_OUT] = ME_NEW_PX("comp_out", "http_comp_bytes_out_total", FN_COUNTER, FF_U64, comp_out[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes emitted by the HTTP compressor for this object since the worker process started"),
- [ST_I_PX_COMP_BYP] = ME_NEW_PX("comp_byp", "http_comp_bytes_bypassed_total", FN_COUNTER, FF_U64, comp_byp[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes that bypassed HTTP compression for this object since the worker process started (CPU/memory/bandwidth limitation)"),
- [ST_I_PX_COMP_RSP] = ME_NEW_PX("comp_rsp", "http_comp_responses_total", FN_COUNTER, FF_U64, p.http.comp_rsp, STATS_PX_CAP__FB_, "Total number of HTTP responses that were compressed for this object since the worker process started"),
- [ST_I_PX_LASTSESS] = ME_NEW_BE("lastsess", "last_session_seconds", FN_AGE, FF_S32, last_sess, STATS_PX_CAP___BS, "How long ago some traffic was seen on this object on this worker process, in seconds"),
+ [ST_I_PX_REQ_TOT] = ME_NEW_BE_SHARED("req_tot", "http_requests_total", FN_COUNTER, FF_U64, p.http.cum_req, STATS_PX_CAP__FBS, "Total number of HTTP requests processed by this object since the worker process started"),
+ [ST_I_PX_CLI_ABRT] = ME_NEW_BE_SHARED("cli_abrt", "client_aborts_total", FN_COUNTER, FF_U64, cli_aborts, STATS_PX_CAP___BS, "Total number of requests or connections aborted by the client since the worker process started"),
+ [ST_I_PX_SRV_ABRT] = ME_NEW_BE_SHARED("srv_abrt", "server_aborts_total", FN_COUNTER, FF_U64, srv_aborts, STATS_PX_CAP___BS, "Total number of requests or connections aborted by the server since the worker process started"),
+ [ST_I_PX_COMP_IN] = ME_NEW_PX_SHARED("comp_in", "http_comp_bytes_in_total", FN_COUNTER, FF_U64, comp_in[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes submitted to the HTTP compressor for this object since the worker process started"),
+ [ST_I_PX_COMP_OUT] = ME_NEW_PX_SHARED("comp_out", "http_comp_bytes_out_total", FN_COUNTER, FF_U64, comp_out[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes emitted by the HTTP compressor for this object since the worker process started"),
+ [ST_I_PX_COMP_BYP] = ME_NEW_PX_SHARED("comp_byp", "http_comp_bytes_bypassed_total", FN_COUNTER, FF_U64, comp_byp[COMP_DIR_RES], STATS_PX_CAP__FB_, "Total number of bytes that bypassed HTTP compression for this object since the worker process started (CPU/memory/bandwidth limitation)"),
+ [ST_I_PX_COMP_RSP] = ME_NEW_PX_SHARED("comp_rsp", "http_comp_responses_total", FN_COUNTER, FF_U64, p.http.comp_rsp, STATS_PX_CAP__FB_, "Total number of HTTP responses that were compressed for this object since the worker process started"),
+ [ST_I_PX_LASTSESS] = ME_NEW_BE_SHARED("lastsess", "last_session_seconds", FN_AGE, FF_S32, last_sess, STATS_PX_CAP___BS, "How long ago some traffic was seen on this object on this worker process, in seconds"),
[ST_I_PX_LAST_CHK] = { .name = "last_chk", .alt_name = NULL, .desc = "Short description of the latest health check report for this server (see also check_desc)" },
[ST_I_PX_LAST_AGT] = { .name = "last_agt", .alt_name = NULL, .desc = "Short description of the latest agent check report for this server (see also agent_desc)" },
[ST_I_PX_QTIME] = { .name = "qtime", .alt_name = "queue_time_average_seconds", .desc = "Time spent in the queue, in milliseconds, averaged over the 1024 last requests (backend/server)", .cap = STATS_PX_CAP___BS },
[ST_I_PX_COOKIE] = { .name = "cookie", .alt_name = NULL, .desc = "Backend's cookie name or Server's cookie value, shown only if show-legends is set, or at levels oper/admin for the CLI" },
[ST_I_PX_MODE] = { .name = "mode", .alt_name = NULL, .desc = "'mode' setting (tcp/http/health/cli/spop)" },
[ST_I_PX_ALGO] = { .name = "algo", .alt_name = NULL, .desc = "Backend's load balancing algorithm, shown only if show-legends is set, or at levels oper/admin for the CLI" },
- [ST_I_PX_CONN_RATE] = ME_NEW_FE("conn_rate", NULL, FN_RATE, FF_U32, conn_per_sec, STATS_PX_CAP__F__, "Number of new connections accepted over the last second on the frontend for this worker process"),
+ [ST_I_PX_CONN_RATE] = ME_NEW_FE_SHARED("conn_rate", NULL, FN_RATE, FF_U32, conn_per_sec, STATS_PX_CAP__F__, "Number of new connections accepted over the last second on the frontend for this worker process"),
[ST_I_PX_CONN_RATE_MAX] = { .name = "conn_rate_max", .alt_name = "connections_rate_max", .desc = "Highest value of connections per second observed since the worker process started", .cap = STATS_PX_CAP__F__ },
- [ST_I_PX_CONN_TOT] = ME_NEW_FE("conn_tot", "connections_total", FN_COUNTER, FF_U64, cum_conn, STATS_PX_CAP_LF__, "Total number of new connections accepted on this frontend since the worker process started"),
- [ST_I_PX_INTERCEPTED] = ME_NEW_FE("intercepted", "intercepted_requests_total", FN_COUNTER, FF_U64, intercepted_req, STATS_PX_CAP__F__, "Total number of HTTP requests intercepted on the frontend (redirects/stats/services) since the worker process started"),
- [ST_I_PX_DCON] = ME_NEW_FE("dcon", "denied_connections_total", FN_COUNTER, FF_U64, denied_conn, STATS_PX_CAP_LF__, "Total number of incoming connections blocked on a listener/frontend by a tcp-request connection rule since the worker process started"),
- [ST_I_PX_DSES] = ME_NEW_FE("dses", "denied_sessions_total", FN_COUNTER, FF_U64, denied_sess, STATS_PX_CAP_LF__, "Total number of incoming sessions blocked on a listener/frontend by a tcp-request connection rule since the worker process started"),
- [ST_I_PX_WREW] = ME_NEW_PX("wrew", "failed_header_rewriting_total", FN_COUNTER, FF_U64, failed_rewrites, STATS_PX_CAP_LFBS, "Total number of failed HTTP header rewrites since the worker process started"),
- [ST_I_PX_CONNECT] = ME_NEW_BE("connect", "connection_attempts_total", FN_COUNTER, FF_U64, connect, STATS_PX_CAP___BS, "Total number of outgoing connection attempts on this backend/server since the worker process started"),
- [ST_I_PX_REUSE] = ME_NEW_BE("reuse", "connection_reuses_total", FN_COUNTER, FF_U64, reuse, STATS_PX_CAP___BS, "Total number of reused connection on this backend/server since the worker process started"),
- [ST_I_PX_CACHE_LOOKUPS] = ME_NEW_PX("cache_lookups", "http_cache_lookups_total", FN_COUNTER, FF_U64, p.http.cache_lookups, STATS_PX_CAP__FB_, "Total number of HTTP requests looked up in the cache on this frontend/backend since the worker process started"),
- [ST_I_PX_CACHE_HITS] = ME_NEW_PX("cache_hits", "http_cache_hits_total", FN_COUNTER, FF_U64, p.http.cache_hits, STATS_PX_CAP__FB_, "Total number of HTTP requests not found in the cache on this frontend/backend since the worker process started"),
+ [ST_I_PX_CONN_TOT] = ME_NEW_FE_SHARED("conn_tot", "connections_total", FN_COUNTER, FF_U64, cum_conn, STATS_PX_CAP_LF__, "Total number of new connections accepted on this frontend since the worker process started"),
+ [ST_I_PX_INTERCEPTED] = ME_NEW_FE_SHARED("intercepted", "intercepted_requests_total", FN_COUNTER, FF_U64, intercepted_req, STATS_PX_CAP__F__, "Total number of HTTP requests intercepted on the frontend (redirects/stats/services) since the worker process started"),
+ [ST_I_PX_DCON] = ME_NEW_FE_SHARED("dcon", "denied_connections_total", FN_COUNTER, FF_U64, denied_conn, STATS_PX_CAP_LF__, "Total number of incoming connections blocked on a listener/frontend by a tcp-request connection rule since the worker process started"),
+ [ST_I_PX_DSES] = ME_NEW_FE_SHARED("dses", "denied_sessions_total", FN_COUNTER, FF_U64, denied_sess, STATS_PX_CAP_LF__, "Total number of incoming sessions blocked on a listener/frontend by a tcp-request connection rule since the worker process started"),
+ [ST_I_PX_WREW] = ME_NEW_PX_SHARED("wrew", "failed_header_rewriting_total", FN_COUNTER, FF_U64, failed_rewrites, STATS_PX_CAP_LFBS, "Total number of failed HTTP header rewrites since the worker process started"),
+ [ST_I_PX_CONNECT] = ME_NEW_BE_SHARED("connect", "connection_attempts_total", FN_COUNTER, FF_U64, connect, STATS_PX_CAP___BS, "Total number of outgoing connection attempts on this backend/server since the worker process started"),
+ [ST_I_PX_REUSE] = ME_NEW_BE_SHARED("reuse", "connection_reuses_total", FN_COUNTER, FF_U64, reuse, STATS_PX_CAP___BS, "Total number of reused connection on this backend/server since the worker process started"),
+ [ST_I_PX_CACHE_LOOKUPS] = ME_NEW_PX_SHARED("cache_lookups", "http_cache_lookups_total", FN_COUNTER, FF_U64, p.http.cache_lookups, STATS_PX_CAP__FB_, "Total number of HTTP requests looked up in the cache on this frontend/backend since the worker process started"),
+ [ST_I_PX_CACHE_HITS] = ME_NEW_PX_SHARED("cache_hits", "http_cache_hits_total", FN_COUNTER, FF_U64, p.http.cache_hits, STATS_PX_CAP__FB_, "Total number of HTTP requests not found in the cache on this frontend/backend since the worker process started"),
[ST_I_PX_SRV_ICUR] = { .name = "srv_icur", .alt_name = "idle_connections_current", .desc = "Current number of idle connections available for reuse on this server", .cap = STATS_PX_CAP____S },
[ST_I_PX_SRV_ILIM] = { .name = "src_ilim", .alt_name = "idle_connections_limit", .desc = "Limit on the number of available idle connections on this server (server 'pool_max_conn' directive)", .cap = STATS_PX_CAP____S },
[ST_I_PX_QT_MAX] = { .name = "qtime_max", .alt_name = "max_queue_time_seconds", .desc = "Maximum observed time spent in the queue, in milliseconds (backend/server)", .cap = STATS_PX_CAP___BS },
[ST_I_PX_CT_MAX] = { .name = "ctime_max", .alt_name = "max_connect_time_seconds", .desc = "Maximum observed time spent waiting for a connection to complete, in milliseconds (backend/server)", .cap = STATS_PX_CAP___BS },
[ST_I_PX_RT_MAX] = { .name = "rtime_max", .alt_name = "max_response_time_seconds", .desc = "Maximum observed time spent waiting for a server response, in milliseconds (backend/server)", .cap = STATS_PX_CAP___BS },
[ST_I_PX_TT_MAX] = { .name = "ttime_max", .alt_name = "max_total_time_seconds", .desc = "Maximum observed total request+response time (request+queue+connect+response+processing), in milliseconds (backend/server)", .cap = STATS_PX_CAP___BS },
- [ST_I_PX_EINT] = ME_NEW_PX("eint", "internal_errors_total", FN_COUNTER, FF_U64, internal_errors, STATS_PX_CAP_LFBS, "Total number of internal errors since process started"),
+ [ST_I_PX_EINT] = ME_NEW_PX_SHARED("eint", "internal_errors_total", FN_COUNTER, FF_U64, internal_errors, STATS_PX_CAP_LFBS, "Total number of internal errors since process started"),
[ST_I_PX_IDLE_CONN_CUR] = { .name = "idle_conn_cur", .alt_name = "unsafe_idle_connections_current", .desc = "Current number of unsafe idle connections", .cap = STATS_PX_CAP____S},
[ST_I_PX_SAFE_CONN_CUR] = { .name = "safe_conn_cur", .alt_name = "safe_idle_connections_current", .desc = "Current number of safe idle connections", .cap = STATS_PX_CAP____S},
[ST_I_PX_USED_CONN_CUR] = { .name = "used_conn_cur", .alt_name = "used_connections_current", .desc = "Current number of connections in use", .cap = STATS_PX_CAP____S},
[ST_I_PX_AGG_CHECK_STATUS] = { .name = "agg_check_status", .alt_name = "agg_check_status", .desc = "Backend's aggregated gauge of servers' state check status", .cap = STATS_PX_CAP___B_ },
[ST_I_PX_SRID] = { .name = "srid", .alt_name = NULL, .desc = "Server id revision, to prevent server id reuse mixups" },
[ST_I_PX_SESS_OTHER] = { .name = "sess_other", .alt_name = NULL, .desc = "Total number of sessions other than HTTP since process started" },
- [ST_I_PX_H1SESS] = ME_NEW_FE("h1sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[0], STATS_PX_CAP__F__, "Total number of HTTP/1 sessions since process started"),
- [ST_I_PX_H2SESS] = ME_NEW_FE("h2sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[1], STATS_PX_CAP__F__, "Total number of HTTP/2 sessions since process started"),
- [ST_I_PX_H3SESS] = ME_NEW_FE("h3sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[2], STATS_PX_CAP__F__, "Total number of HTTP/3 sessions since process started"),
- [ST_I_PX_REQ_OTHER] = ME_NEW_FE("req_other", NULL, FN_COUNTER, FF_U64, p.http.cum_req[0], STATS_PX_CAP__F__, "Total number of sessions other than HTTP processed by this object since the worker process started"),
- [ST_I_PX_H1REQ] = ME_NEW_FE("h1req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[1], STATS_PX_CAP__F__, "Total number of HTTP/1 sessions processed by this object since the worker process started"),
- [ST_I_PX_H2REQ] = ME_NEW_FE("h2req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[2], STATS_PX_CAP__F__, "Total number of hTTP/2 sessions processed by this object since the worker process started"),
- [ST_I_PX_H3REQ] = ME_NEW_FE("h3req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[3], STATS_PX_CAP__F__, "Total number of HTTP/3 sessions processed by this object since the worker process started"),
+ [ST_I_PX_H1SESS] = ME_NEW_FE_SHARED("h1sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[0], STATS_PX_CAP__F__, "Total number of HTTP/1 sessions since process started"),
+ [ST_I_PX_H2SESS] = ME_NEW_FE_SHARED("h2sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[1], STATS_PX_CAP__F__, "Total number of HTTP/2 sessions since process started"),
+ [ST_I_PX_H3SESS] = ME_NEW_FE_SHARED("h3sess", NULL, FN_COUNTER, FF_U64, cum_sess_ver[2], STATS_PX_CAP__F__, "Total number of HTTP/3 sessions since process started"),
+ [ST_I_PX_REQ_OTHER] = ME_NEW_FE_SHARED("req_other", NULL, FN_COUNTER, FF_U64, p.http.cum_req[0], STATS_PX_CAP__F__, "Total number of sessions other than HTTP processed by this object since the worker process started"),
+ [ST_I_PX_H1REQ] = ME_NEW_FE_SHARED("h1req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[1], STATS_PX_CAP__F__, "Total number of HTTP/1 sessions processed by this object since the worker process started"),
+ [ST_I_PX_H2REQ] = ME_NEW_FE_SHARED("h2req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[2], STATS_PX_CAP__F__, "Total number of hTTP/2 sessions processed by this object since the worker process started"),
+ [ST_I_PX_H3REQ] = ME_NEW_FE_SHARED("h3req", NULL, FN_COUNTER, FF_U64, p.http.cum_req[3], STATS_PX_CAP__F__, "Total number of HTTP/3 sessions processed by this object since the worker process started"),
[ST_I_PX_PROTO] = { .name = "proto", .alt_name = NULL, .desc = "Protocol" },
};
case ST_I_PX_LASTSESS:
if (srv)
- return !srv->counters.last_sess;
+ return !HA_ATOMIC_LOAD(&srv->counters.shared->last_sess);
else if (px)
- return !px->be_counters.last_sess;
+ return !HA_ATOMIC_LOAD(&px->be_counters.shared->last_sess);
else
return 0;
switch (cap) {
case STATS_PX_CAP_FE:
case STATS_PX_CAP_LI:
- counter = (char *)counters + col->metric.offset[0];
+ if (col->flags & STAT_COL_FL_SHARED)
+ counter = (char *)((struct fe_counters *)counters)->shared + col->metric.offset[0];
+ else
+ counter = (char *)counters + col->metric.offset[0];
wrong_side = !(col->cap & (STATS_PX_CAP_FE|STATS_PX_CAP_LI));
break;
case STATS_PX_CAP_BE:
case STATS_PX_CAP_SRV:
- counter = (char *)counters + col->metric.offset[1];
+ if (col->flags & STAT_COL_FL_SHARED)
+ counter = (char *)((struct be_counters *)counters)->shared + col->metric.offset[1];
+ else
+ counter = (char *)counters + col->metric.offset[1];
wrong_side = !(col->cap & (STATS_PX_CAP_BE|STATS_PX_CAP_SRV));
break;
if (idx == ST_I_PX_REQ_TOT && cap == STATS_PX_CAP_FE && !stat_file) {
struct proxy *px = __objt_proxy(objt);
const size_t nb_reqs =
- sizeof(px->fe_counters.p.http.cum_req) /
- sizeof(*px->fe_counters.p.http.cum_req);
+ sizeof(px->fe_counters.shared->p.http.cum_req) /
+ sizeof(*px->fe_counters.shared->p.http.cum_req);
uint64_t total_req = 0;
int i;
for (i = 0; i < nb_reqs; i++)
- total_req += px->fe_counters.p.http.cum_req[i];
+ total_req += HA_ATOMIC_LOAD(&px->fe_counters.shared->p.http.cum_req[i]);
return mkf_u64(FN_COUNTER, total_req);
}
if (fn == FN_COUNTER) {
switch (stcol_format(col)) {
case FF_U64:
- value = mkf_u64(FN_COUNTER, *(uint64_t *)counter);
+ if (col->flags & STAT_COL_FL_SHARED)
+ value = mkf_u64(FN_COUNTER, HA_ATOMIC_LOAD((uint64_t *)counter));
+
+ else
+ value = mkf_u64(FN_COUNTER, *(uint64_t *)counter);
break;
default:
/* only FF_U64 counters currently use generic metric calculation */
value = mkf_u32(FN_RATE, read_freq_ctr(counter));
}
else if (fn == FN_AGE) {
- unsigned long age = *(unsigned long *)counter;
+ unsigned long age;
+
+ if (col->flags & STAT_COL_FL_SHARED)
+ age = HA_ATOMIC_LOAD((unsigned long *)counter);
+ else
+ age = *(unsigned long *)counter;
+
if (age)
age = ns_to_sec(now_ns) - age;
int i;
uint64_t total_sess;
size_t nb_sess =
- sizeof(px->fe_counters.cum_sess_ver) / sizeof(*px->fe_counters.cum_sess_ver);
+ sizeof(px->fe_counters.shared->cum_sess_ver) / sizeof(*px->fe_counters.shared->cum_sess_ver);
- total_sess = px->fe_counters.cum_sess;
+ total_sess = HA_ATOMIC_LOAD(&px->fe_counters.shared->cum_sess);
for (i = 0; i < nb_sess; i++)
- total_sess -= px->fe_counters.cum_sess_ver[i];
+ total_sess -= HA_ATOMIC_LOAD(&px->fe_counters.shared->cum_sess_ver[i]);
total_sess = (int64_t)total_sess < 0 ? 0 : total_sess;
field = mkf_u64(FN_COUNTER, total_sess);
break;
if (index == NULL || *index == ST_I_PX_QTIME ||
*index == ST_I_PX_CTIME || *index == ST_I_PX_RTIME ||
*index == ST_I_PX_TTIME) {
- srv_samples_counter = (px->mode == PR_MODE_HTTP) ? sv->counters.p.http.cum_req : sv->counters.cum_lbconn;
+ srv_samples_counter = (px->mode == PR_MODE_HTTP) ? HA_ATOMIC_LOAD(&sv->counters.shared->p.http.cum_req) : HA_ATOMIC_LOAD(&sv->counters.shared->cum_lbconn);
if (srv_samples_counter < TIME_STATS_SAMPLES && srv_samples_counter > 0)
srv_samples_window = srv_samples_counter;
}
if (!index || *index == ST_I_PX_QTIME ||
*index == ST_I_PX_CTIME || *index == ST_I_PX_RTIME ||
*index == ST_I_PX_TTIME) {
- be_samples_counter = (px->mode == PR_MODE_HTTP) ? px->be_counters.p.http.cum_req : px->be_counters.cum_lbconn;
+ be_samples_counter = (px->mode == PR_MODE_HTTP) ? HA_ATOMIC_LOAD(&px->be_counters.shared->p.http.cum_req) : HA_ATOMIC_LOAD(&px->be_counters.shared->cum_lbconn);
if (be_samples_counter < TIME_STATS_SAMPLES && be_samples_counter > 0)
be_samples_window = be_samples_counter;
}
bytes = s->req.total - s->logs.bytes_in;
s->logs.bytes_in = s->req.total;
if (bytes) {
- _HA_ATOMIC_ADD(&sess->fe->fe_counters.bytes_in, bytes);
- _HA_ATOMIC_ADD(&s->be->be_counters.bytes_in, bytes);
+ _HA_ATOMIC_ADD(&sess->fe->fe_counters.shared->bytes_in, bytes);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->bytes_in, bytes);
if (objt_server(s->target))
- _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.bytes_in, bytes);
+ _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.shared->bytes_in, bytes);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_ADD(&sess->listener->counters->bytes_in, bytes);
+ _HA_ATOMIC_ADD(&sess->listener->counters->shared->bytes_in, bytes);
for (i = 0; i < global.tune.nb_stk_ctr; i++) {
if (!stkctr_inc_bytes_in_ctr(&s->stkctr[i], bytes))
bytes = s->res.total - s->logs.bytes_out;
s->logs.bytes_out = s->res.total;
if (bytes) {
- _HA_ATOMIC_ADD(&sess->fe->fe_counters.bytes_out, bytes);
- _HA_ATOMIC_ADD(&s->be->be_counters.bytes_out, bytes);
+ _HA_ATOMIC_ADD(&sess->fe->fe_counters.shared->bytes_out, bytes);
+ _HA_ATOMIC_ADD(&s->be->be_counters.shared->bytes_out, bytes);
if (objt_server(s->target))
- _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.bytes_out, bytes);
+ _HA_ATOMIC_ADD(&__objt_server(s->target)->counters.shared->bytes_out, bytes);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_ADD(&sess->listener->counters->bytes_out, bytes);
+ _HA_ATOMIC_ADD(&sess->listener->counters->shared->bytes_out, bytes);
for (i = 0; i < global.tune.nb_stk_ctr; i++) {
if (!stkctr_inc_bytes_out_ctr(&s->stkctr[i], bytes))
if (!(s->flags & SF_FINST_MASK)) {
if (s->scb->state == SC_ST_INI) {
/* anything before REQ in fact */
- _HA_ATOMIC_INC(&strm_fe(s)->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&strm_fe(s)->fe_counters.shared->failed_req);
if (strm_li(s) && strm_li(s)->counters)
- _HA_ATOMIC_INC(&strm_li(s)->counters->failed_req);
+ _HA_ATOMIC_INC(&strm_li(s)->counters->shared->failed_req);
s->flags |= SF_FINST_R;
}
if (rule->from != ACT_F_HTTP_REQ) {
if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
- _HA_ATOMIC_INC(&sess->fe->fe_counters.intercepted_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->intercepted_req);
/* The flag SF_ASSIGNED prevent from server assignment. */
s->flags |= SF_ASSIGNED;
sc_shutdown(scf);
if (!(req->analysers) && !(res->analysers)) {
COUNT_IF(1, "Report a client abort (no analysers)");
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.cli_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->cli_aborts);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_CLICL;
if (!(s->flags & SF_FINST_MASK))
if (sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) {
sc_abort(scb);
sc_shutdown(scb);
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.failed_resp);
+ _HA_ATOMIC_INC(&srv->counters.shared->failed_resp);
if (!(req->analysers) && !(res->analysers)) {
COUNT_IF(1, "Report a client abort (no analysers)");
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.srv_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->srv_aborts);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_SRVCL;
if (!(s->flags & SF_FINST_MASK))
req->analysers &= AN_REQ_FLT_END;
channel_auto_close(req);
if (scf->flags & SC_FL_ERROR) {
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.cli_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->cli_aborts);
s->flags |= SF_ERR_CLICL;
COUNT_IF(1, "Report unhandled client error");
}
else if (req->flags & CF_READ_TIMEOUT) {
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.cli_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->cli_aborts);
s->flags |= SF_ERR_CLITO;
COUNT_IF(1, "Report unhandled client timeout (RD)");
}
else {
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.srv_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->srv_aborts);
s->flags |= SF_ERR_SRVTO;
COUNT_IF(1, "Report unhandled server timeout (WR)");
}
res->analysers &= AN_RES_FLT_END;
channel_auto_close(res);
if (scb->flags & SC_FL_ERROR) {
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.srv_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->srv_aborts);
s->flags |= SF_ERR_SRVCL;
COUNT_IF(1, "Report unhandled server error");
}
else if (res->flags & CF_READ_TIMEOUT) {
- _HA_ATOMIC_INC(&s->be->be_counters.srv_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.srv_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->srv_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->srv_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->srv_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->srv_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.srv_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->srv_aborts);
s->flags |= SF_ERR_SRVTO;
COUNT_IF(1, "Report unhandled server timeout (RD)");
}
else {
- _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
- _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->cli_aborts);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->cli_aborts);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->cli_aborts);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->cli_aborts);
if (srv)
- _HA_ATOMIC_INC(&srv->counters.cli_aborts);
+ _HA_ATOMIC_INC(&srv->counters.shared->cli_aborts);
s->flags |= SF_ERR_CLITO;
COUNT_IF(1, "Report unhandled client timeout (WR)");
}
n = 0;
if (sess->fe->mode == PR_MODE_HTTP) {
- _HA_ATOMIC_INC(&sess->fe->fe_counters.p.http.rsp[n]);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->p.http.rsp[n]);
}
if ((s->flags & SF_BE_ASSIGNED) &&
(s->be->mode == PR_MODE_HTTP)) {
- _HA_ATOMIC_INC(&s->be->be_counters.p.http.rsp[n]);
- _HA_ATOMIC_INC(&s->be->be_counters.p.http.cum_req);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->p.http.rsp[n]);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->p.http.cum_req);
}
}
srv = objt_server(s->target);
if (srv) {
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
- srv->counters.p.http.cum_req : srv->counters.cum_lbconn) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
+ HA_ATOMIC_LOAD(&srv->counters.shared->p.http.cum_req) : HA_ATOMIC_LOAD(&srv->counters.shared->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
swrate_add_dynamic(&srv->counters.q_time, samples_window, t_queue);
swrate_add_dynamic(&srv->counters.c_time, samples_window, t_connect);
swrate_add_dynamic(&srv->counters.d_time, samples_window, t_data);
HA_ATOMIC_UPDATE_MAX(&srv->counters.ttime_max, t_close);
}
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
- s->be->be_counters.p.http.cum_req : s->be->be_counters.cum_lbconn) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
+ HA_ATOMIC_LOAD(&s->be->be_counters.shared->p.http.cum_req) : HA_ATOMIC_LOAD(&s->be->be_counters.shared->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
swrate_add_dynamic(&s->be->be_counters.q_time, samples_window, t_queue);
swrate_add_dynamic(&s->be->be_counters.c_time, samples_window, t_connect);
swrate_add_dynamic(&s->be->be_counters.d_time, samples_window, t_data);
strm->req.analysers &= AN_REQ_FLT_END;
strm->res.analysers &= AN_RES_FLT_END;
if (strm->flags & SF_BE_ASSIGNED)
- _HA_ATOMIC_INC(&strm->be->be_counters.denied_req);
+ _HA_ATOMIC_INC(&strm->be->be_counters.shared->denied_req);
if (!(strm->flags & SF_ERR_MASK))
strm->flags |= SF_ERR_PRXCOND;
if (!(strm->flags & SF_FINST_MASK))
strm->flags |= SF_FINST_R;
}
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_req);
return ACT_RET_ABRT;
}
return 0;
deny:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_req);
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
goto reject;
internal:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.internal_errors);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->internal_errors);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->internal_errors);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
goto reject;
invalid:
- _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_req);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->failed_req);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->failed_req);
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
reject:
return 0;
deny:
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.denied_resp);
- _HA_ATOMIC_INC(&s->be->be_counters.denied_resp);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->denied_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->denied_resp);
if (s->sess->listener && s->sess->listener->counters)
- _HA_ATOMIC_INC(&s->sess->listener->counters->denied_resp);
+ _HA_ATOMIC_INC(&s->sess->listener->counters->shared->denied_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.denied_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->denied_resp);
stream_report_term_evt(s->scb, strm_tevt_type_intercepted);
goto reject;
internal:
- _HA_ATOMIC_INC(&s->sess->fe->fe_counters.internal_errors);
- _HA_ATOMIC_INC(&s->be->be_counters.internal_errors);
+ _HA_ATOMIC_INC(&s->sess->fe->fe_counters.shared->internal_errors);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->internal_errors);
if (s->sess->listener && s->sess->listener->counters)
- _HA_ATOMIC_INC(&s->sess->listener->counters->internal_errors);
+ _HA_ATOMIC_INC(&s->sess->listener->counters->shared->internal_errors);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.internal_errors);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->internal_errors);
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_INTERNAL;
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
goto reject;
invalid:
- _HA_ATOMIC_INC(&s->be->be_counters.failed_resp);
+ _HA_ATOMIC_INC(&s->be->be_counters.shared->failed_resp);
if (objt_server(s->target))
- _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_resp);
+ _HA_ATOMIC_INC(&__objt_server(s->target)->counters.shared->failed_resp);
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
reject:
goto end;
}
else if (rule->action == ACT_ACTION_DENY) {
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_conn);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_conn);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_conn);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_conn);
result = 0;
goto end;
goto end;
}
else if (rule->action == ACT_ACTION_DENY) {
- _HA_ATOMIC_INC(&sess->fe->fe_counters.denied_sess);
+ _HA_ATOMIC_INC(&sess->fe->fe_counters.shared->denied_sess);
if (sess->listener && sess->listener->counters)
- _HA_ATOMIC_INC(&sess->listener->counters->denied_sess);
+ _HA_ATOMIC_INC(&sess->listener->counters->shared->denied_sess);
result = 0;
goto end;