mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-15 07:54:33 +00:00
MINOR: Add hostname sample fetch
It adds "hostname" as a new sample fetch. It does exactly the same as "%H" in a log format except that it can be used outside of log formats. Signed-off-by: Nenad Merdanovic <nmerdan@haproxy.com>
This commit is contained in:
parent
2754fbcfd6
commit
807a6e7856
@ -13025,6 +13025,9 @@ fe_sess_rate([<frontend>]) : integer
|
||||
tcp-request content accept if ! too_fast
|
||||
tcp-request content accept if WAIT_END
|
||||
|
||||
hostname : string
|
||||
Returns the system hostname.
|
||||
|
||||
int(<integer>) : signed integer
|
||||
Returns a signed integer.
|
||||
|
||||
|
12
src/sample.c
12
src/sample.c
@ -2511,6 +2511,17 @@ smp_fetch_date(const struct arg *args, struct sample *smp, const char *kw, void
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* returns the hostname */
|
||||
static int
|
||||
smp_fetch_hostname(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->data.type = SMP_T_STR;
|
||||
smp->flags = SMP_F_CONST;
|
||||
smp->data.u.str.str = hostname;
|
||||
smp->data.u.str.len = strlen(hostname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* returns the number of processes */
|
||||
static int
|
||||
smp_fetch_nbproc(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
@ -2684,6 +2695,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
|
||||
{ "always_true", smp_fetch_true, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
|
||||
{ "env", smp_fetch_env, ARG1(1,STR), NULL, SMP_T_STR, SMP_USE_INTRN },
|
||||
{ "date", smp_fetch_date, ARG1(0,SINT), NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
{ "hostname", smp_fetch_hostname, 0, NULL, SMP_T_STR, SMP_USE_INTRN },
|
||||
{ "nbproc", smp_fetch_nbproc,0, NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
{ "proc", smp_fetch_proc, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
{ "rand", smp_fetch_rand, ARG1(0,SINT), NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
|
Loading…
Reference in New Issue
Block a user