]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Add median service times to cachemgr 'info' page.
authorwessels <>
Wed, 1 Apr 1998 12:38:55 +0000 (12:38 +0000)
committerwessels <>
Wed, 1 Apr 1998 12:38:55 +0000 (12:38 +0000)
- Fixed DNS service time calculation -- the start time was set as
  the *dispatch* time, not the *request* time, so it only measured
  how long the dnsserver took to process, and did not account for
  queueing delays.
- Fixed ICP svc time calculation -- start time was set way too
  early, before DNS lookups!

src/enums.h
src/ipcache.cc
src/peer_select.cc
src/protos.h
src/snmp_agent.cc
src/stat.cc
src/structs.h

index 33c4fc9400eb0b60c7df9c1dc1d4a4ad9d0ec074..e7bf5c27a18f12a95e96a36cfb60e38290a9b470 100644 (file)
@@ -572,3 +572,14 @@ typedef enum {
     psParsed,
     psError
 } HttpMsgParseState;
+
+
+enum {
+    MEDIAN_HTTP,
+    MEDIAN_ICP_QUERY,
+    MEDIAN_DNS,
+    MEDIAN_HIT,
+    MEDIAN_MISS,
+    MEDIAN_NM,
+    MEDIAN_ICP_REPLY
+};
index 1e042c479f3cd9934cc6e40bea4962eb31e32dd7..eb556e7ed273b4a88252a5b46fb46e0790655ef7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.174 1998/03/31 04:08:32 wessels Exp $
+ * $Id: ipcache.cc,v 1.175 1998/04/01 05:38:57 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -511,7 +511,7 @@ ipcache_dnsHandleRead(int fd, void *data)
     if (strstr(dnsData->ip_inbuf, "$end\n")) {
        /* end of record found */
        statHistCount(&Counter.dns.svc_time,
-           tvSubMsec(dnsData->dispatch_time, current_time));
+           tvSubMsec(i->request_time, current_time));
        if ((x = ipcache_parsebuffer(dnsData->ip_inbuf, dnsData)) == NULL) {
            debug(14, 0) ("ipcache_dnsHandleRead: ipcache_parsebuffer failed?!\n");
        } else {
@@ -588,6 +588,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
        IpcacheStats.misses++;
        i = ipcacheAddNew(name, NULL, IP_PENDING);
        ipcacheAddPending(i, handler, handlerData);
+       i->request_time = current_time;
     } else if (i->status == IP_CACHED || i->status == IP_NEGATIVE_CACHED) {
        /* HIT */
        debug(14, 4) ("ipcache_nbgethostbyname: HIT for '%s'\n", name);
index ffdf7a22471b64d7cb6c65d6c5c9af6ee562f507..67009ccc4294011023e4bffbdfb9492d1f652608 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.42 1998/03/16 23:21:33 wessels Exp $
+ * $Id: peer_select.cc,v 1.43 1998/04/01 05:38:59 wessels Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -143,7 +143,6 @@ peerSelect(request_t * request,
     psstate->fail_callback = fail_callback;
     psstate->callback_data = callback_data;
     cbdataLock(callback_data);
-    psstate->icp.start = current_time;
     peerSelectCheckAS(psstate);
 }
 
@@ -302,6 +301,7 @@ peerSelectFoo(ps_state * psstate)
     } else if (peerSelectIcpPing(request, direct, entry)) {
        assert(entry->ping_status == PING_NONE);
        debug(44, 3) ("peerSelect: Doing ICP pings\n");
+        psstate->icp.start = current_time;
        psstate->icp.n_sent = neighborsUdpPing(request,
            entry,
            peerHandleIcpReply,
index 659cdfa7197ae3ea368ac4f8eb04c6c034f170ae..bf6b821fc6dc00514361df47a79733bd5033dada 100644 (file)
@@ -546,6 +546,7 @@ extern void passStart(int, const char *, request_t *, size_t *);
 extern void identStart(int, ConnStateData *, IDCB * callback, void *);
 
 extern void statInit(void);
+extern double median_svc_get(int, int);
 extern void pconnHistCount(int, int);
 
 void statHistClean(StatHist * H);
index 80e3fc6ec38181d6d0ea5b9be549d7011377de5b..f637e3391da3d121d946a433013595b9de2b5c3c 100644 (file)
 
 #include "mib.h"
 
-enum {
-    HTTP_SVC, ICP_SVC, DNS_SVC
-};
-
 void snmpAclCheckDone(int answer, void *);
 static struct snmp_pdu *snmp_agent_response(struct snmp_pdu *PDU);
 static int community_check(char *b, oid * name, int namelen);
 struct snmp_session *Session;
-extern int get_median_svc(int, int);
 extern StatCounters *snmpStatGet(int);
 extern void snmp_agent_parse_done(int, snmp_request_t *);
 void addr2oid(struct in_addr addr, oid *);
index 3d46afdb3c87dbd957e6e712e0cf4162b4789303..a8c7e8c232c97651f26e31d6d2258873ec039c7d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.221 1998/03/31 05:37:50 wessels Exp $
+ * $Id: stat.cc,v 1.222 1998/04/01 05:39:04 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -121,6 +121,7 @@ static void statCountersInitSpecial(StatCounters *);
 static void statCountersClean(StatCounters *);
 static void statCountersCopy(StatCounters * dest, const StatCounters * orig);
 static void statCountersDump(StoreEntry * sentry);
+static double statMedianSvc(int, int);
 static OBJH stat_io_get;
 static OBJH stat_objects_get;
 static OBJH stat_vmobjects_get;
@@ -476,6 +477,26 @@ info_get(StoreEntry * sentry)
     storeAppendPrintf(sentry, "\tRequests given to unlinkd:\t%d\n",
        Counter.unlink.requests);
 
+    storeAppendPrintf(sentry, "Median Service Times (seconds)  5 min    60 min:\n");
+    storeAppendPrintf(sentry, "\tHTTP Requests (All):  %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_HTTP) / 1000.0,
+       statMedianSvc(60, MEDIAN_HTTP) / 1000.0);
+    storeAppendPrintf(sentry, "\tCache Misses:         %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_MISS) / 1000.0,
+       statMedianSvc(60, MEDIAN_MISS) / 1000.0);
+    storeAppendPrintf(sentry, "\tCache Hits:           %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_HIT) / 1000.0,
+       statMedianSvc(60, MEDIAN_HIT) / 1000.0);
+    storeAppendPrintf(sentry, "\tNot-Modified Replies: %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_NM) / 1000.0,
+       statMedianSvc(60, MEDIAN_NM) / 1000.0);
+    storeAppendPrintf(sentry, "\tDNS Lookups:          %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_DNS) / 1000.0,
+       statMedianSvc(60, MEDIAN_DNS) / 1000.0);
+    storeAppendPrintf(sentry, "\tICP Queries:          %8.5f %8.5f\n",
+       statMedianSvc(5, MEDIAN_ICP_QUERY) / 1000000.0,
+       statMedianSvc(60, MEDIAN_ICP_QUERY) / 1000000.0);
+
     squid_getrusage(&rusage);
     cputime = rusage_cputime(&rusage);
     storeAppendPrintf(sentry, "Resource usage for %s:\n", appname);
@@ -954,12 +975,8 @@ statAvg60min(StoreEntry * e)
     statAvgDump(e, 60, 0);
 }
 
-enum {
-    HTTP_SVC, ICP_SVC, DNS_SVC
-};
-
-int
-get_median_svc(int interval, int which)
+static double
+statMedianSvc(int interval, int which)
 {
     StatCounters *f;
     StatCounters *l;
@@ -972,20 +989,38 @@ get_median_svc(int interval, int which)
     assert(f);
     assert(l);
     switch (which) {
-    case HTTP_SVC:
+    case MEDIAN_HTTP:
        x = statHistDeltaMedian(&l->client_http.all_svc_time, &f->client_http.all_svc_time);
        break;
-    case ICP_SVC:
+    case MEDIAN_HIT:
+       x = statHistDeltaMedian(&l->client_http.hit_svc_time, &f->client_http.hit_svc_time);
+       break;
+    case MEDIAN_MISS:
+       x = statHistDeltaMedian(&l->client_http.miss_svc_time, &f->client_http.miss_svc_time);
+       break;
+    case MEDIAN_NM:
+       x = statHistDeltaMedian(&l->client_http.nm_svc_time, &f->client_http.nm_svc_time);
+       break;
+    case MEDIAN_ICP_QUERY:
        x = statHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time);
        break;
-    case DNS_SVC:
+    case MEDIAN_DNS:
        x = statHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);
        break;
     default:
        debug(49, 5) ("get_median_val: unknown type.\n");
        x = 0;
     }
-    return (int) x;
+    return x;
+}
+
+/*
+ * SNMP wants ints, ick
+ */
+int
+get_median_svc(int interval, int which)
+{
+       return(int) statMedianSvc(interval, which);
 }
 
 StatCounters *
index 8d0cb6164839dff618c1aad8240ea221b6c36a17..c6340b1ece6cd6de495f064b12251f9485bf9ba9 100644 (file)
@@ -726,6 +726,7 @@ struct _ipcache_entry {
     ipcache_addrs addrs;
     ip_pending *pending_head;
     char *error_message;
+    struct timeval request_time;
     dlink_node lru;
     u_char locks;
     ipcache_status_t status:3;