mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
MINOR: counters: rename last_change counter to last_state_change
Since proxy and server struct already have an internal last_change variable and we cannot merge it with the shared counter one, let's rename the last_change counter to be more specific and prevent the mixup between the two. last_change counter is renamed to last_state_change, and unlike the internal last_change, this one is a shared counter so it is expected to be updated by other processes in our back. However, when updating last_state_change counter, we use the value of the server/proxy last_change as reference value.
This commit is contained in:
parent
5b1480c9d4
commit
4fcc9b5572
@ -35,7 +35,7 @@
|
||||
};
|
||||
#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 */\
|
||||
|
@ -2895,7 +2895,7 @@ void back_handle_st_rdy(struct stream *s)
|
||||
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)) {
|
||||
|
@ -61,7 +61,6 @@ void counters_be_shared_drop(struct be_counters_shared *counters)
|
||||
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
|
||||
@ -80,10 +79,11 @@ static void*_counters_shared_get(const struct guid_node *guid, size_t size)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -7051,8 +7051,8 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
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,
|
||||
@ -7072,7 +7072,7 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,8 +321,8 @@ static void srv_state_srv_update(struct server *srv, int version, char **params)
|
||||
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;
|
||||
|
||||
|
@ -100,7 +100,7 @@ const struct stat_col stat_cols_px[ST_I_PX_MAX] = {
|
||||
[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)" },
|
||||
|
Loading…
Reference in New Issue
Block a user