]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: implement act_conn sample fetch
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 12 Jul 2023 16:05:25 +0000 (18:05 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Mon, 24 Jul 2023 15:12:29 +0000 (17:12 +0200)
Implement the act_conn sample fetch which is the same as %ac (actconn)
in the log-format.

doc/configuration.txt
src/sample.c

index 8fcb8c2b40a3f9c987418b8e08189a8ad981f55e..b1947b24d51aa64ea154f6562b04c4b4e9273099 100644 (file)
@@ -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.
index daaa2cba3c68b1c2ea970b853cd7a66191f85f23..7bd7b9b0ce8e56f3eca3a26f641f811748c3c224 100644 (file)
@@ -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 },