Re: [PATCH] spelling fixes

2022-12-07 Thread Willy Tarreau
On Wed, Dec 07, 2022 at 09:48:17AM +0500,  ??? wrote:
> Hello,
> 
> yet another spelling fix.

Applied and pushed, thank you Ilya!
Willy



Re: [PATCH] MINOR : converter: add param converter

2022-12-07 Thread Willy Tarreau
On Tue, Dec 06, 2022 at 03:44:00PM -0700, Thayne wrote:
> Any update on this?

Hmm indeed it left forgotten in the dust, we must get back to it to verify
that it's OK then merge it.

Thanks for the reminder, Thayne!
Willy



Re: [PATCH 0/2] BUG/MINOR: promex: fix haproxy_backend_agg_server_check_status

2022-12-07 Thread Christopher Faulet

Le 12/6/22 à 15:13, Cedric Paillet a écrit :



Sorry, indeed I mentioned the enum ID and not the promex name.
I proposed to keep "haproxy_bakcned_agg_server_check_status"
altering its description to announce it is deprecated
. And then to add "haproxy_backend_agg_check_status"
aggregate  haproxy_server_check_status) and "haproxy_backend_agg_server_status"
or "haproxy_backend_agg_srv_status" (to aggregate haproxy_server_status).


To resume, is it ok for you ?

- Deprecated haproxy_backend_agg_server_check_status. ( Modify the metric 
description )
- create new haproxy_backend_agg_server_status metric, aggregation of 
haproxy_backend_server_status. ( to replace misnamed 
haproxy_backend_agg_server_check_status )
- create new haproxy_backend_agg_check_status metric, aggregation of 
haproxy_backend_server_check_status.

this will be merged/backported in 2.5/2.6/2.7/2.8-dev and 
haproxy_backend_agg_server_check_status will be removed in 2.9 ( or 2.10 )


Exactly.

--
Christopher Faulet




Re: [PATCH] MINOR : converter: add param converter

2022-12-07 Thread Willy Tarreau
On Wed, Jun 08, 2022 at 01:56:20AM -0600, astrotha...@gmail.com wrote:
> +param(,[])
> +  This extracts the first occurrence of the parameter  in the input 
> string
> +  where parameters are delimited by , which defaults to "&", and the 
> name
> +  and value of the parameter are separated by a "=". If there is no "=" and 
> value
> +  before the end of the parameter segment, it is treated as equivalent to a 
> value
> +  of an empty string.
> +
> +  This can be useful for extracting parameters from a query string, or 
> possibly a
> +  x-www-form-urlencoded body. In particular, `query,param()` can be 
> used as
> +  an alternative to `urlp()` which only uses "&" as a delimiter, 
> whereas "urlp"
> +  also uses "?" and ";".
> +
> +  Note that this converter doesn't do anything special with url encoded 
> characters. If
> +  you want to decode the value, you can use the url_dec converter on the 
> output. If
> +  the name of the parameter in the input might contain encoded characters, 
> you'll probably

Be careful to trim your long lines in the doc so that they don't overflow 80
characters.

> +static int sample_conv_param(const struct arg *arg_p, struct sample *smp, 
> void *private)
> +{
> + char *pos, *end, *pend, *equal;
> + char delim = '&';
> + const char *name = arg_p[0].data.str.area;
> + size_t name_l = arg_p[0].data.str.data;
> +
> + if (arg_p[1].type == ARGT_STR)
> + delim = *arg_p[1].data.str.area;
> +
> + pos = smp->data.u.str.area;
> + end = pos + smp->data.u.str.data;
> + while (pos < end) {
> + equal = pos + name_l;
> + /* Parameter not found */
> + if (equal > end)
> + break;
> +
> + if (equal == end || *equal == '&') {
  ^^^
here it should be "delim", I guess it's a leftover from a previous version

> + if (memcmp(pos, name, name_l) == 0) {
> + /* input contains parameter, but no value is 
> suplied */
 
^^^
supplied :-)

> + smp->data.u.str.data = 0;
> + return 1;
> + }
> + pos = equal + 1;
> + continue;
> + }
> +
> + if (*equal == '=' && memcmp(pos, name, name_l) == 0) {
> + pos = equal + 1;
> + pend = memchr(pos, delim, end - pos);
> + if (pend == NULL)
> + pend = end;
> + b_set_area_sub(&(smp->data.u.str), pos, pend - pos);

Ah, I didn't notice that b_set_area_sub() comes in a previous patch.
I'm not fond of this function, because it standardizes something that
should never work except in this exceptional case, and will inevitably
result in someone using it for the wrong thing. The point is that the
 part of a buffer is allocated from pools normally and must not
be changed at all, since for regular use, there are start offset and
length that do the job. However here in samples we're still using buffers
to store strings because they're easy to allocate and are convenient
enough to use, but I would say it's just a convenience that's almost an
abuse. Most likely that the string part of samples could be turned to IST
instead. Thus I'd rather see both the ->area and ->data parts here being
manually assigned, it's more readable and doesn't standardize an exception.
I suspect it would simply become:

smp->data.u.str.area = pos;
smp->data.u.str.data = pend - pos;

And that's way more readable for those trying to rule out the possibility of
a bug here.

>  /* Note: must not be declared  as its list will be overwritten */
>  static struct sample_conv_kw_list sample_conv_kws = {ILH, {
> - { "add_item",sample_conv_add_item, ARG3(2,STR,STR,STR),   
> smp_check_add_item,   SMP_T_STR,  SMP_T_STR  },
> - { "debug",   sample_conv_debug,ARG2(0,STR,STR),   
> smp_check_debug,  SMP_T_ANY,  SMP_T_ANY  },
> - { "b64dec",  sample_conv_base642bin,   0, NULL, 
> SMP_T_STR,  SMP_T_BIN  },
> + { "add_item",sample_conv_add_item, ARG3(2,STR,STR,STR),   
> smp_check_add_item,   SMP_T_STR,  SMP_T_STR  }, { "debug",   
> sample_conv_debug,ARG2(0,STR,STR),   smp_check_debug,  
> SMP_T_ANY,  SMP_T_ANY  }, { "b64dec",  sample_conv_base642bin,   0,   
>   NULL, SMP_T_STR,  SMP_T_BIN  },

There's a mistake here, you accidently folded 3 lines. Probably "J" being
pressed there by accident in vim :-)

Otherwise it looks good. Please recheck, but I'm overall fine with merging
this.

Thank you!
Willy



Agent for HAProxy agent health checks

2022-12-07 Thread William Edwards

Hi,

I open sourced our agent for HAProxy agent health checks, Sway. It's on 
GitHub[1]. Hopefully it's useful to someone!


Sway differs from alternatives that I found (such as Herald[2]). Instead 
of using a plugin system, Sway uses commands. This allows me to re-use 
general-purpose Nagios scripts. Also, the code has nearly 100% test 
coverage.


If Sway is useful to someone, for easy installation, I included the 
Debian package source in the repository.


With kind regards,

William Edwards

[1]: https://github.com/CyberfusionNL/Sway
[2]: https://github.com/helpshift/herald