From 2406db4b3905d8d1971c788e8871db569d841ed4 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 9 Dec 2012 12:16:43 +0100 Subject: [PATCH] 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. --- doc/configuration.txt | 9 +++++++++ src/session.c | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index bfd9729951..8128c53f0c 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -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 Applies to the socket's id. Useful in frontends with many bind keywords. diff --git a/src/session.c b/src/session.c index 0bee9576ee..a4c53a1609 100644 --- a/src/session.c +++ b/src/session.c @@ -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) }, -- 2.39.5