mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-02-14 22:01:08 +01:00
MINOR: counters: factor out smp_fetch_sc*_tracked
The new function makes use of the sc# in the keyword to get the counter ID.
This commit is contained in:
parent
cadd8c9ec3
commit
88821241d4
@ -2578,36 +2578,17 @@ void session_shutdown(struct session *session, int why)
|
||||
/* All supported ACL keywords must be declared here. */
|
||||
/************************************************************************/
|
||||
|
||||
/* set return a boolean indicating if sc0 is currently being tracked or not */
|
||||
/* set return a boolean indicating if the requested session counter is
|
||||
* currently being tracked or not.
|
||||
* Supports being called as "sc[0-9]_tracked" only.
|
||||
*/
|
||||
static int
|
||||
smp_fetch_sc0_tracked(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
||||
smp_fetch_sc_tracked(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
||||
const struct arg *args, struct sample *smp, const char *kw)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.uint = !!l4->stkctr[0].entry;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* set return a boolean indicating if sc1 is currently being tracked or not */
|
||||
static int
|
||||
smp_fetch_sc1_tracked(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
||||
const struct arg *args, struct sample *smp, const char *kw)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.uint = !!l4->stkctr[1].entry;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* set return a boolean indicating if sc2 is currently being tracked or not */
|
||||
static int
|
||||
smp_fetch_sc2_tracked(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
|
||||
const struct arg *args, struct sample *smp, const char *kw)
|
||||
{
|
||||
smp->flags = SMP_F_VOL_TEST;
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->data.uint = !!l4->stkctr[2].entry;
|
||||
smp->data.uint = !!l4->stkctr[kw[2] - '0'].entry;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -3961,7 +3942,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
||||
{ "sc0_kbytes_out", smp_fetch_sc0_kbytes_out, 0, NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||
{ "sc0_sess_cnt", smp_fetch_sc0_sess_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc0_sess_rate", smp_fetch_sc0_sess_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc0_tracked", smp_fetch_sc0_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc0_tracked", smp_fetch_sc_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc0_trackers", smp_fetch_sc0_trackers, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc1_bytes_in_rate", smp_fetch_sc1_bytes_in_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, },
|
||||
@ -3980,7 +3961,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
||||
{ "sc1_kbytes_out", smp_fetch_sc1_kbytes_out, 0, NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||
{ "sc1_sess_cnt", smp_fetch_sc1_sess_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc1_sess_rate", smp_fetch_sc1_sess_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc1_tracked", smp_fetch_sc1_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc1_tracked", smp_fetch_sc_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc1_trackers", smp_fetch_sc1_trackers, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc2_bytes_in_rate", smp_fetch_sc2_bytes_in_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, },
|
||||
@ -3999,7 +3980,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
|
||||
{ "sc2_kbytes_out", smp_fetch_sc2_kbytes_out, 0, NULL, SMP_T_UINT, SMP_USE_L4CLI, },
|
||||
{ "sc2_sess_cnt", smp_fetch_sc2_sess_cnt, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc2_sess_rate", smp_fetch_sc2_sess_rate, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "sc2_tracked", smp_fetch_sc2_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc2_tracked", smp_fetch_sc_tracked, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN, },
|
||||
{ "sc2_trackers", smp_fetch_sc2_trackers, 0, NULL, SMP_T_UINT, SMP_USE_INTRN, },
|
||||
{ "src_bytes_in_rate", smp_fetch_src_bytes_in_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, },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user