]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
add 5/60 minute byte/request hit ratios to info page
authorwessels <>
Wed, 7 Oct 1998 00:32:41 +0000 (00:32 +0000)
committerwessels <>
Wed, 7 Oct 1998 00:32:41 +0000 (00:32 +0000)
src/stat.cc

index 56a06540cf7f257b093b5a7d5af76ee01c16a3b1..67b9c555755a323cb59be094f9ebd3811e613345 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.294 1998/09/23 20:13:54 wessels Exp $
+ * $Id: stat.cc,v 1.295 1998/10/06 18:32:41 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -76,6 +76,8 @@ static OBJH statAvg5min;
 static OBJH statAvg60min;
 static OBJH statUtilization;
 static OBJH statCountersHistograms;
+static double statRequestHitRatio(int minutes);
+static double statByteHitRatio(int minutes);
 
 #ifdef XMALLOC_STATISTICS
 static void info_get_mallstat(int, int, StoreEntry *);
@@ -464,6 +466,12 @@ info_get(StoreEntry * sentry)
 
     storeAppendPrintf(sentry, "Cache information for %s:\n",
        appname);
+    storeAppendPrintf(sentry, "\tRequest Hit Ratios:\t5min: %3.1f%%, 60min: %3.1f%%\n",
+       statRequestHitRatio(5),
+       statRequestHitRatio(60));
+    storeAppendPrintf(sentry, "\tByte Hit Ratios:\t5min: %3.1f%%, 60min: %3.1f%%\n",
+       statByteHitRatio(5),
+       statByteHitRatio(60));
     storeAppendPrintf(sentry, "\tStorage Swap size:\t%d KB\n",
        store_swap_size);
     storeAppendPrintf(sentry, "\tStorage Mem size:\t%d KB\n",
@@ -1260,6 +1268,27 @@ statCPUUsage(int minutes)
        tvSubDsec(CountHist[minutes].timestamp, CountHist[0].timestamp));
 }
 
+static double
+statRequestHitRatio(int minutes)
+{
+    assert(minutes < N_COUNT_HIST);
+    return dpercent(CountHist[0].client_http.hits -
+       CountHist[minutes].client_http.hits,
+       CountHist[0].client_http.requests -
+       CountHist[minutes].client_http.requests);
+}
+
+static double
+statByteHitRatio(int minutes)
+{
+    size_t s;
+    size_t c;
+    assert(minutes < N_COUNT_HIST);
+    c = CountHist[0].client_http.kbytes_out.kb - CountHist[minutes].client_http.kbytes_out.kb;
+    s = CountHist[0].server.all.kbytes_in.kb - CountHist[minutes].server.all.kbytes_in.kb;
+    return dpercent(c - s, c);
+}
+
 #if STAT_GRAPHS
 /*
  * urgh, i don't like these, but they do cut the amount of code down immensely