set-var(var[,cond...]) any same
sha1 binary binary
sha2([bits]) binary binary
+srv_is_up string boolean
srv_queue string integer
strcmp(var) string boolean
sub(value) integer integer
Please note that this converter is only available when HAProxy has been
compiled with USE_OPENSSL.
+srv_is_up
+ Takes an input value of type string, either a server name or <backend>/<server>
+ format and returns true when the designated server is currently UP. Can be used
+ in places where we want to look up a server status from a dynamic name, like a
+ cookie value (e.g. req.cook(SRVID),srv_is_up) and then make a decision to
+ direct a request elsewhere. Before using this, please keep in mind that using
+ this converter on uncontrolled data might allow an external observer to query
+ the state of any server in the whole configuration, which might possibly not
+ be acceptable in some environments.
+
srv_queue
Takes an input value of type string, either a server name or <backend>/<server>
format and returns the number of queued streams on that server. Can be used
return server_find(px, smp->data.u.str.area);
}
+static int
+sample_conv_srv_is_up(const struct arg *args, struct sample *smp, void *private)
+{
+ struct server *srv = sample_conv_srv(smp);
+
+ if (!srv)
+ return 0;
+
+ smp->data.type = SMP_T_BOOL;
+ if (!(srv->cur_admin & SRV_ADMF_MAINT) &&
+ (!(srv->check.state & CHK_ST_CONFIGURED) || (srv->cur_state != SRV_ST_STOPPED)))
+ smp->data.u.sint = 1;
+ else
+ smp->data.u.sint = 0;
+ return 1;
+}
+
static int
sample_conv_srv_queue(const struct arg *args, struct sample *smp, void *private)
{
/* Note: must not be declared <const> as its list will be overwritten */
static struct sample_conv_kw_list sample_conv_kws = {ILH, {
{ "nbsrv", sample_conv_nbsrv, 0, NULL, SMP_T_STR, SMP_T_SINT },
+ { "srv_is_up", sample_conv_srv_is_up, 0, NULL, SMP_T_STR, SMP_T_BOOL },
{ "srv_queue", sample_conv_srv_queue, 0, NULL, SMP_T_STR, SMP_T_SINT },
{ /* END */ },
}};