From 2a46bfe2398b278611827cba76570d3463186e03 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Wed, 12 Jul 2023 18:05:25 +0200 Subject: [PATCH] MINOR: sample: implement act_conn sample fetch Implement the act_conn sample fetch which is the same as %ac (actconn) in the log-format. --- doc/configuration.txt | 3 +++ src/sample.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index 8fcb8c2b4..b1947b24d 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -19289,6 +19289,9 @@ not even relate to any client information. These ones are sometimes used with "monitor-fail" directives to report an internal status to external watchers. The sample fetch methods described in this section are usable anywhere. +act_conn : integer + Returns the total number of active concurrent connections on the process. + always_false : boolean Always returns the boolean "false" value. It may be used with ACLs as a temporary replacement for another one when adjusting configurations. diff --git a/src/sample.c b/src/sample.c index daaa2cba3..7bd7b9b0c 100644 --- a/src/sample.c +++ b/src/sample.c @@ -4075,6 +4075,17 @@ static int sample_conv_jwt_payload_query(const struct arg *args, struct sample * /* All supported sample fetch functions must be declared here */ /************************************************************************/ + +/* returns the actconn */ +static int +smp_fetch_actconn(const struct arg *args, struct sample *smp, const char *kw, void *private) +{ + smp->data.type = SMP_T_SINT; + smp->data.u.sint = actconn; + return 1; +} + + /* force TRUE to be returned at the fetch level */ static int smp_fetch_true(const struct arg *args, struct sample *smp, const char *kw, void *private) @@ -4500,6 +4511,7 @@ static int smp_fetch_quic_enabled(const struct arg *args, struct sample *smp, co * common denominator, the type that can be casted into all other ones. */ static struct sample_fetch_kw_list smp_kws = {ILH, { + { "act_conn", smp_fetch_actconn, 0, NULL, SMP_T_SINT, SMP_USE_CONST }, { "always_false", smp_fetch_false, 0, NULL, SMP_T_BOOL, SMP_USE_CONST }, { "always_true", smp_fetch_true, 0, NULL, SMP_T_BOOL, SMP_USE_CONST }, { "env", smp_fetch_env, ARG1(1,STR), NULL, SMP_T_STR, SMP_USE_CONST },