]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
clientlog: count total number of hits and drops
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Jan 2016 16:08:23 +0000 (17:08 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 22 Jan 2016 12:26:04 +0000 (13:26 +0100)
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.

clientlog.c

index bb77e64b3c38a2c9f032ca9339ce38fb9ee76ba8..942d85ef1b7a234b3a427bdbbd90f88966ede89e 100644 (file)
@@ -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;
 }