]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: add the srv_queue() sample fetch method
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Oct 2017 09:46:26 +0000 (11:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 Oct 2017 09:47:18 +0000 (11:47 +0200)
srv_queue([<backend>/]<server>) : integer
  Returns an integer value corresponding to the number of connections currently
  pending in the designated server's queue. If <backend> is omitted, then the
  server is looked up in the current backend. It can sometimes be used together
  with the "use-server" directive to force to use a known faster server when it
  is not much loaded. See also the "srv_conn", "avg_queue" and "queue" sample
  fetch methods.

doc/configuration.txt
src/backend.c

index c3aa6fa8439d62558fa439f191f9c3630a0bcb35..c7359a85ffed23fb1c56cc37d683679e7772ad7c 100644 (file)
@@ -13373,6 +13373,14 @@ srv_is_up([<backend>/]<server>) : boolean
   using dummy servers as boolean variables that can be enabled or disabled from
   the CLI, so that rules depending on those ACLs can be tweaked in realtime.
 
+srv_queue([<backend>/]<server>) : integer
+  Returns an integer value corresponding to the number of connections currently
+  pending in the designated server's queue. If <backend> is omitted, then the
+  server is looked up in the current backend. It can sometimes be used together
+  with the "use-server" directive to force to use a known faster server when it
+  is not much loaded. See also the "srv_conn", "avg_queue" and "queue" sample
+  fetch methods.
+
 srv_sess_rate([<backend>/]<server>) : integer
   Returns an integer corresponding to the sessions creation rate on the
   designated server, in number of new sessions per second. If <backend> is
index 52adab0095993135a5e037634a7aab96e373f52b..06f15a1ca0297fd96136c852a608157f637ab5f9 100644 (file)
@@ -1798,6 +1798,19 @@ smp_fetch_srv_conn(const struct arg *args, struct sample *smp, const char *kw, v
        return 1;
 }
 
+/* set temp integer to the number of connections pending in the server's queue.
+ * Accepts exactly 1 argument. Argument is a server, other types will lead to
+ * undefined behaviour.
+ */
+static int
+smp_fetch_srv_queue(const struct arg *args, struct sample *smp, const char *kw, void *private)
+{
+       smp->flags = SMP_F_VOL_TEST;
+       smp->data.type = SMP_T_SINT;
+       smp->data.u.sint = args->data.srv->nbpend;
+       return 1;
+}
+
 /* set temp integer to the number of enabled servers on the proxy.
  * Accepts exactly 1 argument. Argument is a server, other types will lead to
  * undefined behaviour.
@@ -1845,6 +1858,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { "srv_conn",      smp_fetch_srv_conn,       ARG1(1,SRV), NULL, SMP_T_SINT, SMP_USE_INTRN, },
        { "srv_id",        smp_fetch_srv_id,         0,           NULL, SMP_T_SINT, SMP_USE_SERVR, },
        { "srv_is_up",     smp_fetch_srv_is_up,      ARG1(1,SRV), NULL, SMP_T_BOOL, SMP_USE_INTRN, },
+       { "srv_queue",     smp_fetch_srv_queue,      ARG1(1,SRV), NULL, SMP_T_SINT, SMP_USE_INTRN, },
        { "srv_sess_rate", smp_fetch_srv_sess_rate,  ARG1(1,SRV), NULL, SMP_T_SINT, SMP_USE_INTRN, },
        { /* END */ },
 }};