From: wessels <> Date: Wed, 1 Apr 1998 12:38:55 +0000 (+0000) Subject: - Add median service times to cachemgr 'info' page. X-Git-Tag: SQUID_3_0_PRE1~3663 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b87b92fb2696af955748ba29d3a4f0815febdc22;p=thirdparty%2Fsquid.git - Add median service times to cachemgr 'info' page. - 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! --- diff --git a/src/enums.h b/src/enums.h index 33c4fc9400..e7bf5c27a1 100644 --- a/src/enums.h +++ b/src/enums.h @@ -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 +}; diff --git a/src/ipcache.cc b/src/ipcache.cc index 1e042c479f..eb556e7ed2 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -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); diff --git a/src/peer_select.cc b/src/peer_select.cc index ffdf7a2247..67009ccc42 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -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, diff --git a/src/protos.h b/src/protos.h index 659cdfa719..bf6b821fc6 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index 80e3fc6ec3..f637e3391d 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -11,15 +11,10 @@ #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 *); diff --git a/src/stat.cc b/src/stat.cc index 3d46afdb3c..a8c7e8c232 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -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 * diff --git a/src/structs.h b/src/structs.h index 8d0cb61648..c6340b1ece 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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;