diff --git a/doc/configuration.txt b/doc/configuration.txt index 6478bc852..36be7e8e6 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -22748,6 +22748,10 @@ sc_kbytes_out([,]) integer sc0_kbytes_out([
]) integer sc1_kbytes_out([
]) integer sc2_kbytes_out([
]) integer +sc_key() any +sc0_key any +sc1_key any +sc2_key any sc_sess_cnt([,
]) integer sc0_sess_cnt([
]) integer sc1_sess_cnt([
]) integer @@ -23560,6 +23564,12 @@ sc2_kbytes_out([
]) : integer counters, measured in kilobytes. The test is currently performed on 32-bit integers, which limits values to 4 terabytes. See also src_kbytes_out. +sc_key() : any +sc0_key : any +sc1_key : any +sc2_key : any + Returns the key used to match the currently tracked counter. + sc_sess_cnt([,
]) : integer sc0_sess_cnt([
]) : integer sc1_sess_cnt([
]) : integer diff --git a/src/stick_table.c b/src/stick_table.c index 7f788f8f7..eebf3354d 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -5115,6 +5115,32 @@ smp_fetch_sc_kbytes_out(const struct arg *args, struct sample *smp, const char * return 1; } +/* set to the key associated to the stream's tracked entry. + * Supports being called as "sc[0-9]_key" or "sc_key" only. + */ +static int +smp_fetch_sc_key(const struct arg *args, struct sample *smp, const char *kw, void *private) +{ + struct stkctr tmpstkctr; + struct stkctr *stkctr; + struct stksess *entry; + + stkctr = smp_fetch_sc_stkctr(smp->sess, smp->strm, args, kw, &tmpstkctr); + if (!stkctr) + return 0; + + entry = stkctr_entry(stkctr); + if (entry != NULL) { + int ret = stkey_to_smp(smp, stksess_getkey(stkctr->table, entry), stkctr->table->type); + + if (stkctr == &tmpstkctr) + stktable_release(stkctr->table, entry); + + return !!ret; + } + return 0; /* nothing currently tracked */ +} + /* set to the data rate sent to clients in bytes/s, as found in the * stream's tracked frontend counters. Supports being called as * "sc[0-9]_bytes_out_rate" or "src_bytes_out_rate" only. @@ -6049,6 +6075,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, { { "sc_inc_gpc1", smp_fetch_sc_inc_gpc1, ARG2(1,SINT,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc_kbytes_in", smp_fetch_sc_kbytes_in, ARG2(1,SINT,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, { "sc_kbytes_out", smp_fetch_sc_kbytes_out, ARG2(1,SINT,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, + { "sc_key", smp_fetch_sc_key, ARG1(1,SINT), NULL, SMP_T_ANY, SMP_USE_INTRN, }, { "sc_sess_cnt", smp_fetch_sc_sess_cnt, ARG2(1,SINT,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc_sess_rate", smp_fetch_sc_sess_rate, ARG2(1,SINT,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc_tracked", smp_fetch_sc_tracked, ARG2(1,SINT,TAB), NULL, SMP_T_BOOL, SMP_USE_INTRN, }, @@ -6077,6 +6104,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, { { "sc0_inc_gpc1", smp_fetch_sc_inc_gpc1, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc0_kbytes_in", smp_fetch_sc_kbytes_in, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, { "sc0_kbytes_out", smp_fetch_sc_kbytes_out, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, + { "sc0_key", smp_fetch_sc_key, 0, NULL, SMP_T_ANY, SMP_USE_INTRN, }, { "sc0_sess_cnt", smp_fetch_sc_sess_cnt, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc0_sess_rate", smp_fetch_sc_sess_rate, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc0_tracked", smp_fetch_sc_tracked, ARG1(0,TAB), NULL, SMP_T_BOOL, SMP_USE_INTRN, }, @@ -6106,6 +6134,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, { { "sc1_inc_gpc1", smp_fetch_sc_inc_gpc1, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc1_kbytes_in", smp_fetch_sc_kbytes_in, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, { "sc1_kbytes_out", smp_fetch_sc_kbytes_out, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, + { "sc1_key", smp_fetch_sc_key, 0, NULL, SMP_T_ANY, SMP_USE_INTRN, }, { "sc1_sess_cnt", smp_fetch_sc_sess_cnt, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc1_sess_rate", smp_fetch_sc_sess_rate, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc1_tracked", smp_fetch_sc_tracked, ARG1(0,TAB), NULL, SMP_T_BOOL, SMP_USE_INTRN, }, @@ -6134,6 +6163,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, { { "sc2_inc_gpc1", smp_fetch_sc_inc_gpc1, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc2_kbytes_in", smp_fetch_sc_kbytes_in, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, { "sc2_kbytes_out", smp_fetch_sc_kbytes_out, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_L4CLI, }, + { "sc2_key", smp_fetch_sc_key, 0, NULL, SMP_T_ANY, SMP_USE_INTRN, }, { "sc2_sess_cnt", smp_fetch_sc_sess_cnt, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc2_sess_rate", smp_fetch_sc_sess_rate, ARG1(0,TAB), NULL, SMP_T_SINT, SMP_USE_INTRN, }, { "sc2_tracked", smp_fetch_sc_tracked, ARG1(0,TAB), NULL, SMP_T_BOOL, SMP_USE_INTRN, },