From: Miroslav Lichvar Date: Mon, 18 Jan 2016 16:08:23 +0000 (+0100) Subject: clientlog: count total number of hits and drops X-Git-Tag: 2.3-pre1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f52a7386607880f623d1573be529c852d841d954;p=thirdparty%2Fchrony.git clientlog: count total number of hits and drops Count total number of NTP and command hits. Count also number of log records that were replaced when the hash table couldn't be resized due to the memory limit. --- diff --git a/clientlog.c b/clientlog.c index bb77e64b..942d85ef 100644 --- a/clientlog.c +++ b/clientlog.c @@ -123,6 +123,13 @@ static int cmd_leak_rate; /* Flag indicating whether facility is turned on or not */ static int active; +/* Global statistics */ +static uint32_t total_ntp_hits; +static uint32_t total_cmd_hits; +static uint32_t total_ntp_drops; +static uint32_t total_cmd_drops; +static uint32_t total_record_drops; + /* ================================================== */ static int expand_hashtable(void); @@ -186,6 +193,7 @@ get_record(IPAddr *ip) /* There is no other option, replace the oldest record */ record = oldest_record; + total_record_drops++; break; } @@ -398,6 +406,8 @@ CLG_LogNTPAccess(IPAddr *client, struct timeval *now) { Record *record; + total_ntp_hits++; + if (!active) return -1; @@ -426,6 +436,8 @@ CLG_LogCommandAccess(IPAddr *client, struct timeval *now) { Record *record; + total_cmd_hits++; + if (!active) return -1; @@ -502,6 +514,7 @@ CLG_LimitNTPResponseRate(int index) record->flags |= FLAG_NTP_DROPPED; record->ntp_drops++; + total_ntp_drops++; return 1; } @@ -529,6 +542,7 @@ CLG_LimitCommandResponseRate(int index) } record->cmd_drops++; + total_cmd_drops++; return 1; }