};
#define COUNTERS_SHARED_TG \
struct { \
- unsigned long last_change; /* last time, when the state was changed */\
+ unsigned long last_state_change; /* last time, when the state was changed */\
long long srv_aborts; /* aborted responses during DATA phase caused by the server */\
long long cli_aborts; /* aborted responses during DATA phase caused by the client */\
long long internal_errors; /* internal processing errors */\
void set_backend_down(struct proxy *be)
{
be->last_change = ns_to_sec(now_ns);
- HA_ATOMIC_STORE(&be->be_counters.shared->tg[tgid - 1]->last_change, ns_to_sec(now_ns));
+ HA_ATOMIC_STORE(&be->be_counters.shared->tg[tgid - 1]->last_state_change, be->last_change);
_HA_ATOMIC_INC(&be->be_counters.shared->tg[tgid - 1]->down_trans);
if (!(global.mode & MODE_STARTING)) {
static void*_counters_shared_get(const struct guid_node *guid, size_t size)
{
struct counters_shared *shared;
- uint last_change;
int it = 0;
/* no shared memory for now, simply allocate a memory block
}
it += 1;
}
- last_change = ns_to_sec(now_ns);
- /* only set one group, only latest value is considered */
- HA_ATOMIC_STORE(&shared->tg[0]->last_change, last_change);
+ /* initial values:
+ * only set one group, only latest value is considered
+ */
+ HA_ATOMIC_STORE(&shared->tg[0]->last_state_change, ns_to_sec(now_ns));
return shared;
}
if (s->cur_state != SRV_ST_RUNNING && s->proxy->ready_srv == s)
HA_ATOMIC_STORE(&s->proxy->ready_srv, NULL);
- HA_ATOMIC_STORE(&s->counters.shared->tg[tgid - 1]->last_change, ns_to_sec(now_ns));
s->last_change = ns_to_sec(now_ns);
+ HA_ATOMIC_STORE(&s->counters.shared->tg[tgid - 1]->last_state_change, s->last_change);
/* publish the state change */
_srv_event_hdl_prepare_state(&cb_data.state,
if (last_change < ns_to_sec(now_ns)) // ignore negative times
s->proxy->down_time += ns_to_sec(now_ns) - last_change;
s->proxy->last_change = ns_to_sec(now_ns);
- HA_ATOMIC_STORE(&s->proxy->be_counters.shared->tg[tgid - 1]->last_change, ns_to_sec(now_ns));
+ HA_ATOMIC_STORE(&s->proxy->be_counters.shared->tg[tgid - 1]->last_state_change, s->proxy->last_change);
}
}
srv_adm_set_drain(srv);
}
- HA_ATOMIC_STORE(&srv->counters.shared->tg[0]->last_change, ns_to_sec(now_ns) - srv_last_time_change);
srv->last_change = ns_to_sec(now_ns) - srv_last_time_change;
+ HA_ATOMIC_STORE(&srv->counters.shared->tg[0]->last_state_change, srv->last_change);
srv->check.status = srv_check_status;
srv->check.result = srv_check_result;
[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_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_LASTCHG] = ME_NEW_BE_SHARED("lastchg", "check_last_change_seconds", FN_AGE, FF_U32, last_state_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)" },