MINOR: tevt: Add a sample to get termination events for all locations

"term_events" is a sample fetche function that can be used to get
termination events for all locations in one call. The format equivalent to:

  {fc_term_events,fc_mux_term_events,fs.term_events,txn.term_events,bs.term_events,bc_mux_term_events,bc_term_events}

If no event was reported for a location, the field is empty. If the feature
is not supported yet, a dash ('-') is printed.
This commit is contained in:
Christopher Faulet 2025-01-21 07:46:17 +01:00
parent eb2f1a4ba4
commit b161155498
2 changed files with 52 additions and 0 deletions

View File

@ -22087,6 +22087,7 @@ stopping boolean
str(<string>) string
table_avl([<table>]) integer
table_cnt([<table>]) integer
term_events string
thread integer
txn.id32 integer
txn.sess_term_state string
@ -22565,6 +22566,27 @@ table_cnt([<table>]) : integer
stick-table or in the designated stick-table. See also "table_conn_cnt" and
table_avl for other entry counting methods.
term_events: string
Returns all known termination events for all entities attached a stream, on
client and server sides. A tuple of seven elements is returned with following info:
- the termination events of the frontend connection
- the termination events of the frontend mux connection
- the termination events of the frontend stream endpoint descriptor
(the mux stream or the applet)
- the termination events of the stream
- the termination events of the backend stream endpoint descriptor
(the mux stream or the applet)
- the termination events of the backend mux connection
- the termination events of the backend connection
At each level, the first four events are reported. An empty string is
returned if no event was reported yet for a specific level. If termination
events are not supported, a "-" is returned.
It must only be used for debugging purpose. The exact format is not
documented because it may evolve depending on developers requirements.
thread : integer
Returns an integer value corresponding to the position of the thread calling
the function, between 0 and (global.nbthread-1). This is useful for logging

View File

@ -4271,6 +4271,35 @@ static int smp_fetch_conn_retries(const struct arg *args, struct sample *smp, co
return 1;
}
static int smp_fetch_tevts(const struct arg *args, struct sample *smp, const char *km, void *private)
{
struct buffer *trash = get_trash_chunk();
struct connection *fconn, *bconn;
int fc_mux_ret, bc_mux_ret;
fconn = smp->sess ? objt_conn(smp->sess->origin) : NULL;
bconn = smp->strm ? sc_conn(smp->strm->scb) : NULL;
fc_mux_ret = bc_mux_ret = -1;
if (fconn && fconn->mux && fconn->mux->ctl)
fc_mux_ret = fconn->mux->ctl(fconn, MUX_CTL_TEVTS, NULL);
if (bconn && bconn->mux && bconn->mux->ctl)
bc_mux_ret = bconn->mux->ctl(bconn, MUX_CTL_TEVTS, NULL);
chunk_printf(trash, "{%s,", fconn ? tevt_evts2str(fconn->term_evts_log) : "-");
chunk_appendf(trash, "%s,", (fc_mux_ret != -1) ? tevt_evts2str(fc_mux_ret) : "-");
chunk_appendf(trash, "%s,", smp->strm ? tevt_evts2str(smp->strm->scf->sedesc->term_evts_log) : "-");
chunk_appendf(trash, "%s,", smp->strm ? tevt_evts2str(smp->strm->term_evts_log) : "-");
chunk_appendf(trash, "%s,", smp->strm ? tevt_evts2str(smp->strm->scb->sedesc->term_evts_log) : "-");
chunk_appendf(trash, "%s,", (bc_mux_ret != -1) ? tevt_evts2str(bc_mux_ret) : "-");
chunk_appendf(trash, "%s}", bconn ? tevt_evts2str(bconn->term_evts_log) : "-");
smp->data.u.str = *trash;
smp->data.type = SMP_T_STR;
smp->flags = SMP_F_VOL_TEST | SMP_F_MAY_CHANGE;
return 1;
}
static int smp_fetch_id32(const struct arg *args, struct sample *smp, const char *km, void *private)
{
smp->flags = SMP_F_VOL_TXN;
@ -4304,6 +4333,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
{ "last_entity", smp_fetch_last_entity, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
{ "last_rule_file", smp_fetch_last_rule_file, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
{ "last_rule_line", smp_fetch_last_rule_line, 0, NULL, SMP_T_SINT, SMP_USE_INTRN, },
{ "term_events", smp_fetch_tevts, 0, NULL, SMP_T_STR, SMP_USE_INTRN, },
{ "txn.conn_retries", smp_fetch_conn_retries, 0, NULL, SMP_T_SINT, SMP_USE_L4SRV, },
{ "txn.id32", smp_fetch_id32, 0, NULL, SMP_T_SINT, SMP_USE_INTRN, },
{ "txn.redispatched", smp_fetch_redispatched, 0, NULL, SMP_T_BOOL, SMP_USE_L4SRV, },