MINOR: sample: implement the uptime sample fetch
'uptime' returns the uptime of the current HAProxy worker in seconds.
This commit is contained in:
parent
f76e73511a
commit
0a00302fab
|
@ -21435,6 +21435,9 @@ txn.sess_term_state : string
|
|||
# Return a 429-Too-Many-Requests if stream timed out in queue
|
||||
http-after-response set-status 429 if { txn.sess_term_state "sQ" }
|
||||
|
||||
uptime : integer
|
||||
Returns the uptime of the current HAProxy worker in seconds.
|
||||
|
||||
uuid([<version>]) : string
|
||||
Returns a UUID following the RFC 9562 standard. If the version is not
|
||||
specified, a UUID version 4 (fully random) is returned.
|
||||
|
|
11
src/sample.c
11
src/sample.c
|
@ -4823,6 +4823,16 @@ static int smp_fetch_uuid(const struct arg *args, struct sample *smp, const char
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* returns the uptime in seconds */
|
||||
static int
|
||||
smp_fetch_uptime(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.u.sint = ns_to_sec(now_ns - start_time_ns);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Check if QUIC support was compiled and was not disabled by "no-quic" global option */
|
||||
static int smp_fetch_quic_enabled(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
|
@ -5123,6 +5133,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
|
|||
{ "thread", smp_fetch_thread, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "rand", smp_fetch_rand, ARG1(0,SINT), NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "stopping", smp_fetch_stopping, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
|
||||
{ "uptime", smp_fetch_uptime, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "uuid", smp_fetch_uuid, ARG1(0, SINT), smp_check_uuid, SMP_T_STR, SMP_USE_CONST },
|
||||
|
||||
{ "cpu_calls", smp_fetch_cpu_calls, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
|
|
Loading…
Reference in New Issue