]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
next big step on 5 minute averages
authorwessels <>
Sat, 15 Nov 1997 13:36:33 +0000 (13:36 +0000)
committerwessels <>
Sat, 15 Nov 1997 13:36:33 +0000 (13:36 +0000)
src/enums.h
src/protos.h
src/stat.cc

index 732f8fbc540c39037854764efb86045e4ff92513..8f199515f4c4673a2286641a26e52167e7e0cf86 100644 (file)
@@ -148,6 +148,7 @@ typedef enum {
     MGR_STOREDIR,
     MGR_CBDATA,
     MGR_PCONN,
+    MGR_5MIN,
     MGR_MAX
 } objcache_op;
 
index 6759784b67a004e1cf3fa22f4f72d15fe6a68ca4..6ea2b80f07a76cab9a9f685327a6a5c166076b8d 100644 (file)
@@ -551,6 +551,7 @@ extern OBJH dump_config;
 extern OBJH storeDirStats;
 extern OBJH pconnHistDump;
 extern void dump_peers(StoreEntry *, peer *);
+extern OBJH statAvgDump;
 
 extern void pconnPush(int, const char *host, u_short port);
 extern int pconnPop(const char *host, u_short port);
index 5dca38e2f5f68b505d2d5718471001490ba5a293..dca48ba85b47e95888c6f8afe985312dd8e373c3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.172 1997/11/15 00:14:51 wessels Exp $
+ * $Id: stat.cc,v 1.173 1997/11/15 06:36:36 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -128,6 +128,7 @@ int server_pconn_hist[PCONN_HIST_SZ];
 
 #define N_DELTAS 5
 static StatCounters Deltas[N_DELTAS];
+static int NDeltas = 0;
 
 /* process utilization information */
 static void
@@ -916,6 +917,9 @@ statAvgTick(void *notused)
     struct rusage rusage;
     eventAdd("statAvgTick", statAvgTick, NULL, 60);
     memmove(p, t, (N_DELTAS - 1) * sizeof(StatCounters));
+    squid_getrusage(&rusage);
+    c->page_faults = rusage_pagefaults(&rusage);
+    c->cputime = rusage_cputime(&rusage);
     t->client_http.requests = c->client_http.requests - p->client_http.requests;
     t->client_http.hits = c->client_http.hits - p->client_http.hits;
     t->client_http.errors = c->client_http.errors - p->client_http.errors;
@@ -929,7 +933,61 @@ statAvgTick(void *notused)
     t->page_faults = c->page_faults - p->page_faults;
     t->select_loops = c->select_loops - p->select_loops;
     t->cputime = c->cputime - p->cputime;
-    squid_getrusage(&rusage);
-    c->page_faults = rusage_pagefaults(&rusage);
-    c->cputime = rusage_cputime(&rusage);
+    NDeltas++;
+}
+
+void
+statAvgDump(StoreEntry * sentry)
+{
+    int i;
+    int N = NDeltas > N_DELTAS ? N_DELTAS : NDeltas;
+    StatCounters A;
+    StatCounters *c;
+    memset(&A, '\0', sizeof(StatCounters));
+    for (i = 0; i < N; i++) {
+       c = &Deltas[i];
+       A.client_http.requests += c->client_http.requests;
+       A.client_http.hits += c->client_http.hits;
+       A.client_http.errors += c->client_http.errors;
+       A.client_http.bytes_in += c->client_http.bytes_in;
+       A.client_http.bytes_out += c->client_http.bytes_out;
+       A.icp.pkts_sent += c->icp.pkts_sent;
+       A.icp.pkts_recv += c->icp.pkts_recv;
+       A.icp.bytes_sent += c->icp.bytes_sent;
+       A.icp.bytes_recv += c->icp.bytes_recv;
+       A.unlink.requests += c->unlink.requests;
+       A.page_faults += c->page_faults;
+       A.select_loops += c->select_loops;
+       A.cputime += c->cputime;
+    }
+    if (N) {
+       A.client_http.requests /= N;
+       A.client_http.hits /= N;
+       A.client_http.errors /= N;
+       A.client_http.bytes_in /= N;
+       A.client_http.bytes_out /= N;
+       A.icp.pkts_sent /= N;
+       A.icp.pkts_recv /= N;
+       A.icp.bytes_sent /= N;
+       A.icp.bytes_recv /= N;
+       A.unlink.requests /= N;
+       A.page_faults /= N;
+       A.select_loops /= N;
+       A.cputime /= N;
+    }
+    EBIT_SET(sentry->flag, DELAY_SENDING);
+    storeAppendPrintf(sentry, "client_http.requests = %d\n", A.client_http.requests);
+    storeAppendPrintf(sentry, "client_http.hits = %d\n", A.client_http.hits);
+    storeAppendPrintf(sentry, "client_http.errors = %d\n", A.client_http.errors);
+    storeAppendPrintf(sentry, "client_http.bytes_in = %d\n", A.client_http.bytes_in);
+    storeAppendPrintf(sentry, "client_http.bytes_out = %d\n", A.client_http.bytes_out);
+    storeAppendPrintf(sentry, "icp.pkts_sent = %d\n", A.icp.pkts_sent);
+    storeAppendPrintf(sentry, "icp.pkts_recv = %d\n", A.icp.pkts_recv);
+    storeAppendPrintf(sentry, "icp.bytes_sent = %d\n", A.icp.bytes_sent);
+    storeAppendPrintf(sentry, "icp.bytes_recv = %d\n", A.icp.bytes_recv);
+    storeAppendPrintf(sentry, "unlink.requests = %d\n", A.unlink.requests);
+    storeAppendPrintf(sentry, "page_faults = %d\n", A.page_faults);
+    storeAppendPrintf(sentry, "select_loops = %d\n", A.select_loops);
+    EBIT_CLR(sentry->flag, DELAY_SENDING);
+    storeAppendPrintf(sentry, "cputime = %f seconds\n", A.cputime);
 }