diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-03-10 10:07:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-03-10 10:07:41 -0400 |
commit | d29a8ad564757866dee8d2cbd940c5028a03f2e3 (patch) | |
tree | 23ed85f8b159baee2037d43f0e2571da70f66fd2 /src/or/rephist.c | |
parent | 99b59dee7046b04854ac263a1cf810dceb80df12 (diff) | |
download | tor-d29a8ad564757866dee8d2cbd940c5028a03f2e3.tar.gz tor-d29a8ad564757866dee8d2cbd940c5028a03f2e3.zip |
Add link protocol version counts to the heartbeat message
Closes ticket 15212
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 34908828a5..fe0997c891 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -3121,6 +3121,50 @@ rep_hist_hs_stats_write(time_t now) return start_of_hs_stats_interval + WRITE_STATS_INTERVAL; } +#define MAX_LINK_PROTO_TO_LOG 4 +static uint64_t link_proto_count[MAX_LINK_PROTO_TO_LOG+1][2]; + +/** Note that we negotiated link protocol version <b>link_proto</b>, on + * a connection that started here iff <b>started_here</b> is true. + */ +void +rep_hist_note_negotiated_link_proto(unsigned link_proto, int started_here) +{ + started_here = !!started_here; /* force to 0 or 1 */ + if (link_proto > MAX_LINK_PROTO_TO_LOG) { + log_warn(LD_BUG, "Can't log link protocol %u", link_proto); + return; + } + + link_proto_count[link_proto][started_here]++; +} + +/** Log a heartbeat message explaining how many connections of each link + * protocol version we have used. + */ +void +rep_hist_log_link_protocol_counts(void) +{ + log_notice(LD_HEARTBEAT, + "Since startup, we have initiated " + U64_FORMAT" v1 connections, " + U64_FORMAT" v2 connections, " + U64_FORMAT" v3 connections, and " + U64_FORMAT" v4 connections; and received " + U64_FORMAT" v1 connections, " + U64_FORMAT" v2 connections, " + U64_FORMAT" v3 connections, and " + U64_FORMAT" v4 connections.", + U64_PRINTF_ARG(link_proto_count[1][1]), + U64_PRINTF_ARG(link_proto_count[2][1]), + U64_PRINTF_ARG(link_proto_count[3][1]), + U64_PRINTF_ARG(link_proto_count[4][1]), + U64_PRINTF_ARG(link_proto_count[1][0]), + U64_PRINTF_ARG(link_proto_count[2][0]), + U64_PRINTF_ARG(link_proto_count[3][0]), + U64_PRINTF_ARG(link_proto_count[4][0])); +} + /** Free all storage held by the OR/link history caches, by the * bandwidth history arrays, by the port history, or by statistics . */ void |