From 22861c2f4083e7e29a732a4907c2dcadd6a6a4db Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 6 May 2021 11:17:26 -0400 Subject: relay: Add TCP port exhaustion metrics Signed-off-by: David Goulet --- src/feature/stats/rephist.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/feature/stats/rephist.c') diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 7481b2f0a8..01fa644b9e 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -214,6 +214,9 @@ static overload_stats_t overload_stats; static uint64_t stats_n_read_limit_reached = 0; static uint64_t stats_n_write_limit_reached = 0; +/** Total number of times we've reached TCP port exhaustion. */ +static uint64_t stats_n_tcp_exhaustion = 0; + /***** DNS statistics *****/ /** Represents the statistics of DNS queries seen if it is an Exit. */ @@ -512,6 +515,22 @@ rep_hist_note_overload(overload_type_t overload) } } +/** Note down that we've reached a TCP port exhaustion. This triggers an + * overload general event. */ +void +rep_hist_note_tcp_exhaustion(void) +{ + stats_n_tcp_exhaustion++; + rep_hist_note_overload(OVERLOAD_GENERAL); +} + +/** Return the total number of TCP exhaustion times we've reached. */ +uint64_t +rep_hist_get_n_tcp_exhaustion(void) +{ + return stats_n_tcp_exhaustion; +} + /** Return the or_history_t for the OR with identity digest id, * creating it if necessary. */ static or_history_t * -- cgit v1.2.3-54-g00ecf