mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 00:27:08 +02:00
MEDIUM: counters: factor out smp_fetch_sc*_conn_cur
smp_fetch_sc0_conn_cur, smp_fetch_sc1_conn_cur, smp_fetch_sc2_conn_cur, smp_fetch_src_conn_cur and smp_fetch_conn_cur were merged into a single function which relies on the fetch name to decide what to return.
This commit is contained in:
parent
c8c65700de
commit
f44a553476
@ -2819,16 +2819,24 @@ smp_fetch_src_updt_conn_cnt(struct proxy *px, struct session *l4, void *l7, unsi
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set temp integer to the number of concurrent connections in the stksess entry <ts> */
|
/* set <smp> to the number of concurrent connections from the session's tracked
|
||||||
|
* frontend counters. Supports being called as "sc[0-9]_conn_cur" or
|
||||||
|
* "src_conn_cur" only.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
smp_fetch_conn_cur(struct stktable *table, struct sample *smp, struct stksess *ts)
|
smp_fetch_sc_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
||||||
|
const struct arg *args, struct sample *smp, const char *kw)
|
||||||
{
|
{
|
||||||
|
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
|
||||||
|
|
||||||
|
if (!stkctr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
smp->flags = SMP_F_VOL_TEST;
|
smp->flags = SMP_F_VOL_TEST;
|
||||||
smp->type = SMP_T_UINT;
|
smp->type = SMP_T_UINT;
|
||||||
smp->data.uint = 0;
|
smp->data.uint = 0;
|
||||||
|
if (stkctr->entry != NULL) {
|
||||||
if (ts != NULL) {
|
void *ptr = stktable_data_ptr(stkctr->table, stkctr->entry, STKTABLE_DT_CONN_CUR);
|
||||||
void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_CONN_CUR);
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return 0; /* parameter not stored */
|
return 0; /* parameter not stored */
|
||||||
smp->data.uint = stktable_data_cast(ptr, conn_cur);
|
smp->data.uint = stktable_data_cast(ptr, conn_cur);
|
||||||
@ -2836,57 +2844,6 @@ smp_fetch_conn_cur(struct stktable *table, struct sample *smp, struct stksess *t
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set temp integer to the number of concurrent connections from the session's tracked FE counters */
|
|
||||||
static int
|
|
||||||
smp_fetch_sc0_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
|
||||||
const struct arg *args, struct sample *smp, const char *kw)
|
|
||||||
{
|
|
||||||
if (!l4->stkctr[0].entry)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return smp_fetch_conn_cur(l4->stkctr[0].table, smp, l4->stkctr[0].entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set temp integer to the number of concurrent connections from the session's tracked BE counters */
|
|
||||||
static int
|
|
||||||
smp_fetch_sc1_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
|
||||||
const struct arg *args, struct sample *smp, const char *kw)
|
|
||||||
{
|
|
||||||
if (!l4->stkctr[1].entry)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return smp_fetch_conn_cur(l4->stkctr[1].table, smp, l4->stkctr[1].entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set temp integer to the number of concurrent connections from the session's tracked BE counters */
|
|
||||||
static int
|
|
||||||
smp_fetch_sc2_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
|
||||||
const struct arg *args, struct sample *smp, const char *kw)
|
|
||||||
{
|
|
||||||
if (!l4->stkctr[2].entry)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return smp_fetch_conn_cur(l4->stkctr[2].table, smp, l4->stkctr[2].entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set temp integer to the number of concurrent connections from the session's source
|
|
||||||
* address in the table pointed to by expr.
|
|
||||||
* Accepts exactly 1 argument of type table.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
smp_fetch_src_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
|
||||||
const struct arg *args, struct sample *smp, const char *kw)
|
|
||||||
{
|
|
||||||
struct stktable_key *key;
|
|
||||||
|
|
||||||
key = addr_to_stktable_key(&l4->si[0].conn->addr.from);
|
|
||||||
if (!key)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
px = args->data.prx;
|
|
||||||
return smp_fetch_conn_cur(&px->table, smp, stktable_lookup_key(&px->table, key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set temp integer to the cumulated number of sessions in the stksess entry <ts> */
|
/* set temp integer to the cumulated number of sessions in the stksess entry <ts> */
|
||||||
static int
|
static int
|
||||||
smp_fetch_sess_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
|
smp_fetch_sess_cnt(struct stktable *table, struct sample *smp, struct stksess *ts)
|
||||||
@ -3685,7 +3642,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
|||||||
{ "sc0_bytes_out_rate", smp_fetch_sc0_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_bytes_out_rate", smp_fetch_sc0_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_conn_cur", smp_fetch_sc0_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_conn_cur", smp_fetch_sc_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc0_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc0_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
@ -3704,7 +3661,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
|||||||
{ "sc1_bytes_out_rate", smp_fetch_sc1_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_bytes_out_rate", smp_fetch_sc1_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_conn_cur", smp_fetch_sc1_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_conn_cur", smp_fetch_sc_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc1_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc1_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
@ -3723,7 +3680,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
|||||||
{ "sc2_bytes_out_rate", smp_fetch_sc2_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_bytes_out_rate", smp_fetch_sc2_bytes_out_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_clr_gpc0", smp_fetch_sc_clr_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_conn_cnt", smp_fetch_sc_conn_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_conn_cur", smp_fetch_sc2_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_conn_cur", smp_fetch_sc_conn_cur, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_conn_rate", smp_fetch_sc_conn_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_get_gpc0", smp_fetch_sc_get_gpc0, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
{ "sc2_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
{ "sc2_gpc0_rate", smp_fetch_sc_gpc0_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||||
@ -3742,7 +3699,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
|||||||
{ "src_bytes_out_rate", smp_fetch_src_bytes_out_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_bytes_out_rate", smp_fetch_src_bytes_out_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_clr_gpc0", smp_fetch_sc_clr_gpc0, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_clr_gpc0", smp_fetch_sc_clr_gpc0, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_conn_cnt", smp_fetch_sc_conn_cnt, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_conn_cnt", smp_fetch_sc_conn_cnt, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_conn_cur", smp_fetch_src_conn_cur, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_conn_cur", smp_fetch_sc_conn_cur, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_conn_rate", smp_fetch_sc_conn_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_conn_rate", smp_fetch_sc_conn_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_get_gpc0", smp_fetch_sc_get_gpc0, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_get_gpc0", smp_fetch_sc_get_gpc0, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
{ "src_gpc0_rate", smp_fetch_sc_gpc0_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
{ "src_gpc0_rate", smp_fetch_sc_gpc0_rate, ARG1(1,TAB), NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||||
|
Loading…
Reference in New Issue
Block a user