MINOR: server: add the srv_queue() sample fetch method

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.
This commit is contained in:
Willy Tarreau 2017-10-13 11:46:26 +02:00
parent dce734e10f
commit ff2b7afe0b
2 changed files with 22 additions and 0 deletions

View File

@ -13373,6 +13373,14 @@ srv_is_up([<backend>/]<server>) : boolean
using dummy servers as boolean variables that can be enabled or disabled from 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. 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 srv_sess_rate([<backend>/]<server>) : integer
Returns an integer corresponding to the sessions creation rate on the Returns an integer corresponding to the sessions creation rate on the
designated server, in number of new sessions per second. If <backend> is designated server, in number of new sessions per second. If <backend> is

View File

@ -1798,6 +1798,19 @@ smp_fetch_srv_conn(const struct arg *args, struct sample *smp, const char *kw, v
return 1; 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. /* 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 * Accepts exactly 1 argument. Argument is a server, other types will lead to
* undefined behaviour. * 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_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_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_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, }, { "srv_sess_rate", smp_fetch_srv_sess_rate, ARG1(1,SRV), NULL, SMP_T_SINT, SMP_USE_INTRN, },
{ /* END */ }, { /* END */ },
}}; }};