MEDIUM: counters: add sc1_trackers/sc2_trackers

Returns the current amount of concurrent connections tracking the same
tracked counters. This number is automatically incremented when tracking
begins and decremented when tracking stops. It differs from sc1_conn_cur in
that it does not rely on any stored information but on the table's reference
count (the "use" value which is returned by "show table" on the CLI). This
may sometimes be more suited for layer7 tracking.
This commit is contained in:
Willy Tarreau 2012-12-09 12:16:43 +01:00
parent 5d5b5d8eaf
commit 2406db4b39
2 changed files with 33 additions and 0 deletions

View file

@ -8276,6 +8276,15 @@ sc2_sess_rate
connection could result in many backend sessions if some HTTP keep-alive is
performed over the connection with the client. See also src_sess_rate.
sc1_trackers
sc2_trackers
Returns the current amount of concurrent connections tracking the same
tracked counters. This number is automatically incremented when tracking
begins and decremented when tracking stops. It differs from sc1_conn_cur in
that it does not rely on any stored information but on the table's reference
count (the "use" value which is returned by "show table" on the CLI). This
may sometimes be more suited for layer7 tracking.
so_id <integer>
Applies to the socket's id. Useful in frontends with many bind keywords.

View file

@ -3597,6 +3597,28 @@ acl_fetch_src_bytes_out_rate(struct proxy *px, struct session *l4, void *l7, uns
return acl_fetch_bytes_out_rate(&px->table, smp, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the number of active trackers on the SC1 entry */
static int
acl_fetch_sc1_trackers(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
if (!l4->stkctr1_entry)
return 0;
return l4->stkctr1_entry->ref_cnt;
}
/* set temp integer to the number of active trackers on the SC1 entry */
static int
acl_fetch_sc2_trackers(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
if (!l4->stkctr2_entry)
return 0;
return l4->stkctr2_entry->ref_cnt;
}
/* set temp integer to the number of used entries in the table pointed to by expr.
* Accepts exactly 1 argument of type table.
*/
@ -3644,6 +3666,7 @@ static struct acl_kw_list acl_kws = {{ },{
{ "sc1_kbytes_out", acl_parse_int, acl_fetch_sc1_kbytes_out, acl_match_int, ACL_USE_TCP4_VOLATILE, 0 },
{ "sc1_sess_cnt", acl_parse_int, acl_fetch_sc1_sess_cnt, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc1_sess_rate", acl_parse_int, acl_fetch_sc1_sess_rate, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc1_trackers", acl_parse_int, acl_fetch_sc1_trackers, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc2_bytes_in_rate", acl_parse_int, acl_fetch_sc2_bytes_in_rate, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc2_bytes_out_rate", acl_parse_int, acl_fetch_sc2_bytes_out_rate, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc2_clr_gpc0", acl_parse_int, acl_fetch_sc2_clr_gpc0, acl_match_int, ACL_USE_NOTHING, 0 },
@ -3660,6 +3683,7 @@ static struct acl_kw_list acl_kws = {{ },{
{ "sc2_kbytes_out", acl_parse_int, acl_fetch_sc2_kbytes_out, acl_match_int, ACL_USE_TCP4_VOLATILE, 0 },
{ "sc2_sess_cnt", acl_parse_int, acl_fetch_sc2_sess_cnt, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc2_sess_rate", acl_parse_int, acl_fetch_sc2_sess_rate, acl_match_int, ACL_USE_NOTHING, 0 },
{ "sc2_trackers", acl_parse_int, acl_fetch_sc2_trackers, acl_match_int, ACL_USE_NOTHING, 0 },
{ "src_bytes_in_rate", acl_parse_int, acl_fetch_src_bytes_in_rate, acl_match_int, ACL_USE_TCP4_VOLATILE, ARG1(1,TAB) },
{ "src_bytes_out_rate", acl_parse_int, acl_fetch_src_bytes_out_rate, acl_match_int, ACL_USE_TCP4_VOLATILE, ARG1(1,TAB) },
{ "src_clr_gpc0", acl_parse_int, acl_fetch_src_clr_gpc0, acl_match_int, ACL_USE_TCP4_VOLATILE, ARG1(1,TAB) },