mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 09:24:31 +00:00
MINOR: samples: implement bytes_in and bytes_out samples
%[bytes_in] and %[bytes_out] are equivalent to %U and %B tags in log-format.
This commit is contained in:
parent
5abbae2d3d
commit
c7424a1bac
@ -22063,6 +22063,13 @@ baseq : string
|
||||
instead of "base" allows one to properly identify the target resource, for
|
||||
statistics or caching use cases. See also "path", "pathq" and "base".
|
||||
|
||||
|
||||
bytes_in : integer
|
||||
This returns the number of bytes uploaded from the client to the server.
|
||||
|
||||
bytes_out integer
|
||||
This is the number of bytes transmitted from the server to the client.
|
||||
|
||||
capture.req.hdr(<idx>) : string
|
||||
This extracts the content of the header captured by the "capture request
|
||||
header", idx is the position of the capture keyword in the configuration.
|
||||
@ -23745,6 +23752,7 @@ Please refer to the table below for currently defined variables :
|
||||
| Others |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| | %B | bytes_read (from server to client) | numeric |
|
||||
| | | %[bytes_out] | |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| H | %CC | captured_request_cookie | string |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
@ -23769,6 +23777,7 @@ Please refer to the table below for currently defined variables :
|
||||
| | %ST | status_code | numeric |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| | %U | bytes_uploaded (from client to server) | numeric |
|
||||
| | | %[bytes_in] | |
|
||||
+---+------+------------------------------------------------------+---------+
|
||||
| | %ac | actconn | |
|
||||
| | | %[act_conn] | numeric |
|
||||
|
26
src/sample.c
26
src/sample.c
@ -4905,9 +4905,35 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* bytes_{in,out} */
|
||||
static int smp_fetch_bytes(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
struct strm_logs *logs;
|
||||
|
||||
if (!smp->strm)
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->flags = 0;
|
||||
|
||||
logs = &smp->strm->logs;
|
||||
if (!logs)
|
||||
return 0;
|
||||
|
||||
if (kw[6] == 'i') { /* bytes_in */
|
||||
smp->data.u.sint = logs->bytes_in;
|
||||
} else { /* bytes_out */
|
||||
smp->data.u.sint = logs->bytes_out;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static struct sample_fetch_kw_list smp_logs_kws = {ILH, {
|
||||
{ "bytes_in", smp_fetch_bytes, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
{ "bytes_out", smp_fetch_bytes, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
|
||||
|
||||
{ "txn.timer.total", smp_fetch_txn_timers, 0, NULL, SMP_T_SINT, SMP_USE_TXFIN }, /* "Ta" */
|
||||
{ "txn.timer.user", smp_fetch_txn_timers, 0, NULL, SMP_T_SINT, SMP_USE_TXFIN }, /* "Tu" */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user