From: Willy Tarreau Date: Fri, 13 Oct 2017 09:46:26 +0000 (+0200) Subject: MINOR: server: add the srv_queue() sample fetch method X-Git-Tag: v1.8-dev3~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff2b7afe0b72874e158400aaa58f413dda030489;p=thirdparty%2Fhaproxy.git MINOR: server: add the srv_queue() sample fetch method srv_queue([/]) : integer Returns an integer value corresponding to the number of connections currently pending in the designated server's queue. If 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. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index c3aa6fa843..c7359a85ff 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -13373,6 +13373,14 @@ srv_is_up([/]) : 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([/]) : integer + Returns an integer value corresponding to the number of connections currently + pending in the designated server's queue. If 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([/]) : integer Returns an integer corresponding to the sessions creation rate on the designated server, in number of new sessions per second. If is diff --git a/src/backend.c b/src/backend.c index 52adab0095..06f15a1ca0 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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 */ }, }};