]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Added more bytes in/out and service time tracking. There is one pair
authorwessels <>
Wed, 25 Feb 1998 04:17:01 +0000 (04:17 +0000)
committerwessels <>
Wed, 25 Feb 1998 04:17:01 +0000 (04:17 +0000)
  of byte counters for the server-side (http,ftp,gopher,wais,ssl,pass).
- Also separately track cache hits, misses, and not-modified replies.
- Try to track ICP query service time, but this may not be implemented
  right.
- Removed '60min' average, now we have 5 minutes max

13 files changed:
src/access_log.cc
src/client_side.cc
src/enums.h
src/ftp.cc
src/gopher.cc
src/http.cc
src/icp_v2.cc
src/peer_select.cc
src/ssl.cc
src/stat.cc
src/structs.h
src/tunnel.cc
src/wais.cc

index 5628fdf8e22f594a754d1f7f0e433c93ee65d38e..1379ee536868f9e74d1c19636b05c2dc9515fe20 100644 (file)
@@ -1,7 +1,7 @@
 
 
 /*
- * $Id: access_log.cc,v 1.22 1998/02/20 18:47:49 wessels Exp $
+ * $Id: access_log.cc,v 1.23 1998/02/24 21:17:01 wessels Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -46,7 +46,7 @@ const char *log_tags[] =
     "TCP_REFRESH_HIT",
     "TCP_REF_FAIL_HIT",
     "TCP_REFRESH_MISS",
-    "TCP_CLIENT_REFRESH",
+    "TCP_CLIENT_REFRESH_MISS",
     "TCP_IMS_HIT",
     "TCP_IMS_MISS",
     "TCP_SWAPFAIL_MISS",
index acc0f1ba3490b0eb293fcbc605472aa8bd4a4c9c..36b7c4ccb762918ee7932b88aab206d969b41509 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.213 1998/02/23 23:47:21 rousskov Exp $
+ * $Id: client_side.cc,v 1.214 1998/02/24 21:17:02 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -33,7 +33,7 @@
 
 static const char *const crlf = "\r\n";
 static const char *const proxy_auth_challenge =
-    "Basic realm=\"Squid proxy-caching web server\"";
+"Basic realm=\"Squid proxy-caching web server\"";
 
 #define REQUEST_BUF_SIZE 4096
 #define FAILURE_MODE_TIME 300
@@ -114,7 +114,7 @@ clientAccessCheck(void *data)
     aclNBCheck(http->acl_checklist, clientAccessCheckDone, http);
 }
 
-#if 0 /* reimplemented using new interfaces */
+#if 0                          /* reimplemented using new interfaces */
 static char *
 clientConstructProxyAuthReply(clientHttpRequest * http)
 {
@@ -166,7 +166,7 @@ clientConstructProxyAuthReply(clientHttpRequest * http)
 #endif
 
 static HttpReply *
-clientConstructProxyAuthReply(clientHttpRequest *http)
+clientConstructProxyAuthReply(clientHttpRequest * http)
 {
     ErrorState *err = errorCon(ERR_CACHE_ACCESS_DENIED, HTTP_PROXY_AUTHENTICATION_REQUIRED);
     HttpReply *rep;
@@ -532,7 +532,7 @@ clientPurgeRequest(clientHttpRequest * http)
        storeRelease(entry);
        http->http_code = HTTP_OK;
     }
-#if 0 /* new interface */
+#if 0                          /* new interface */
     msg = httpReplyHeader(1.0, http->http_code, NULL, 0, 0, -1);
     if ((int) strlen(msg) < 8190)
        strcat(msg, "\r\n");
@@ -558,6 +558,8 @@ checkNegativeHit(StoreEntry * e)
 void
 clientUpdateCounters(clientHttpRequest * http)
 {
+    int svc_time = tvSubMsec(http->start, current_time);
+    icp_ping_data *i;
     Counter.client_http.requests++;
     kb_incr(&Counter.client_http.kbytes_in, http->req_sz);
     kb_incr(&Counter.client_http.kbytes_out, http->out.size);
@@ -567,8 +569,32 @@ clientUpdateCounters(clientHttpRequest * http)
     }
     if (http->request->err_type != ERR_NONE)
        Counter.client_http.errors++;
-    statLogHistCount(&Counter.client_http.svc_time,
-       tvSubMsec(http->start, current_time));
+    statLogHistCount(&Counter.client_http.all_svc_time, svc_time);
+    /*
+     * The idea here is not to be complete, but to get service times
+     * for only well-defined types.  For example, we don't include
+     * LOG_TCP_REFRESH_FAIL_HIT because its not really a cache hit
+     * (we *tried* to validate it, but failed).
+     */
+    switch (http->log_type) {
+    case LOG_TCP_IMS_HIT:
+       statLogHistCount(&Counter.client_http.nm_svc_time, svc_time);
+       break;
+    case LOG_TCP_HIT:
+    case LOG_TCP_MEM_HIT:
+       statLogHistCount(&Counter.client_http.hit_svc_time, svc_time);
+       break;
+    case LOG_TCP_MISS:
+    case LOG_TCP_CLIENT_REFRESH_MISS:
+       statLogHistCount(&Counter.client_http.miss_svc_time, svc_time);
+       break;
+    default:
+       /* make compiler warnings go away */
+       break;
+    }
+    i = &http->request->hier.icp;
+    if (0 != i->stop.tv_sec)
+       statLogHistCount(&Counter.icp.query_svc_time, tvSubUsec(i->start, i->stop));
 }
 
 static void
@@ -1210,7 +1236,7 @@ clientGetHeadersForIMS(void *data, char *buf, ssize_t size)
        return;
     }
     debug(33, 4) ("clientGetHeadersForIMS: Not modified '%s'\n", storeUrl(entry));
-#if 0 /* use new interfaces */
+#if 0                          /* use new interfaces */
     reply = clientConstruct304reply(mem->reply);
     comm_write(http->conn->fd,
        xstrdup(reply),
@@ -1272,7 +1298,7 @@ clientProcessRequest2(clientHttpRequest * http)
            storeRelease(e);
        ipcacheReleaseInvalid(r->host);
        http->entry = NULL;
-       return LOG_TCP_CLIENT_REFRESH;
+       return LOG_TCP_CLIENT_REFRESH_MISS;
     } else if (checkNegativeHit(e)) {
        return LOG_TCP_NEGATIVE_HIT;
     } else if (refreshCheck(e, r, 0)) {
@@ -1318,7 +1344,7 @@ clientProcessRequest(clientHttpRequest * http)
            http->entry = clientCreateStoreEntry(http, r->method, 0);
            storeReleaseRequest(http->entry);
            storeBuffer(http->entry);
-#if 0 /* use new interface */
+#if 0                          /* use new interface */
            hdr = httpReplyHeader(1.0,
                HTTP_OK,
                "text/plain",
@@ -2051,9 +2077,9 @@ clientCheckTransferDone(clientHttpRequest * http)
        return 1;
 }
 
-#if 0 /* moved to HttpReply */
+#if 0                          /* moved to HttpReply */
 static char *
-clientConstruct304reply(http_reply *source)
+clientConstruct304reply(http_reply * source)
 {
     LOCAL_ARRAY(char, line, 256);
     LOCAL_ARRAY(char, reply, 8192);
index ccac5f7ff68f11d3712a0d567681749d95687662..aec7b69adf01ccee2d0fd6fbe1aaa39c6d4cfe3f 100644 (file)
@@ -7,7 +7,7 @@ typedef enum {
     LOG_TCP_REFRESH_HIT,
     LOG_TCP_REFRESH_FAIL_HIT,
     LOG_TCP_REFRESH_MISS,
-    LOG_TCP_CLIENT_REFRESH,
+    LOG_TCP_CLIENT_REFRESH_MISS,
     LOG_TCP_IMS_HIT,
     LOG_TCP_IMS_MISS,
     LOG_TCP_SWAPFAIL_MISS,
@@ -301,7 +301,7 @@ typedef enum {
     HTTP_SERVICE_UNAVAILABLE = 503,
     HTTP_GATEWAY_TIMEOUT = 504,
     HTTP_HTTP_VERSION_NOT_SUPPORTED = 505,
-    HTTP_INVALID_HEADER = 600 /* Squid header parsing error */
+    HTTP_INVALID_HEADER = 600  /* Squid header parsing error */
 } http_status;
 
 /* These are for StoreEntry->flag, which is defined as a SHORT */
@@ -415,7 +415,7 @@ typedef enum {
     MEM_FQDNCACHE_ENTRY,
     MEM_HASH_LINK,
     MEM_HASH_TABLE,
-#if 0 /* renamed to detect all old uses */
+#if 0                          /* renamed to detect all old uses */
     MEM_HTTP_REPLY,
 #else
     MEM_HTTPREPLY,
index 56b63ffaa0aea1f785b27ffc6bde74aacc86487b..4084caaf5057d01d011be4df3eb6ec90775825f9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.196 1998/02/22 07:45:19 rousskov Exp $
+ * $Id: ftp.cc,v 1.197 1998/02/24 21:17:03 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -144,7 +144,7 @@ static void ftpAppendSuccessHeader(FtpStateData * ftpState);
 #if 0
 static char *ftpAuthRequired(const request_t *, const char *);
 #else
-static void ftpAuthRequired(HttpReply *reply, request_t *request, const char *realm);
+static void ftpAuthRequired(HttpReply * reply, request_t * request, const char *realm);
 #endif
 static STABH ftpAbort;
 static void ftpHackShortcut(FtpStateData * ftpState, FTPSM * nextState);
@@ -773,7 +773,10 @@ ftpDataRead(int fd, void *data)
     len = read(fd,
        ftpState->data.buf + ftpState->data.offset,
        ftpState->data.size - ftpState->data.offset);
-    fd_bytes(fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(9, 5) ("ftpDataRead: FD %d, Read %d bytes\n", fd, len);
     if (len > 0) {
        IOStats.Ftp.reads++;
@@ -816,7 +819,7 @@ ftpDataRead(int fd, void *data)
     }
 }
 
-#if 0 /* moved to mime.c because cachemgr needs it too */
+#if 0                          /* moved to mime.c because cachemgr needs it too */
 static char *
 ftpGetBasicAuth(const char *req_hdr)
 {
@@ -1060,6 +1063,10 @@ ftpWriteCommandCallback(int fd, char *bufnotused, size_t size, int errflag, void
     StoreEntry *entry = ftpState->entry;
     ErrorState *err;
     debug(9, 7) ("ftpWriteCommandCallback: wrote %d bytes\n", size);
+    if (size > 0) {
+       fd_bytes(fd, size, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, size);
+    }
     if (errflag == COMM_ERR_CLOSING)
        return;
     if (errflag) {
@@ -1128,7 +1135,10 @@ ftpReadControlReply(int fd, void *data)
     len = read(fd,
        ftpState->ctrl.buf + ftpState->ctrl.offset,
        ftpState->ctrl.size - ftpState->ctrl.offset);
-    fd_bytes(fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, len);
     if (len < 0) {
        debug(50, 1) ("ftpReadControlReply: read error: %s\n", xstrerror());
@@ -1965,7 +1975,7 @@ ftpAppendSuccessHeader(FtpStateData * ftpState)
        }
     }
     storeBuffer(e);
-#if 0 /* old code */
+#if 0                          /* old code */
     storeAppendPrintf(e, "HTTP/1.0 200 Gatewaying\r\n");
     reply->code = 200;
     reply->version = 1.0;
@@ -2016,7 +2026,7 @@ ftpAbort(void *data)
     comm_close(ftpState->ctrl.fd);
 }
 
-#if 0 /* use new interfaces instead */
+#if 0                          /* use new interfaces instead */
 static char *
 ftpAuthRequired(const request_t * request, const char *realm)
 {
@@ -2068,7 +2078,7 @@ ftpAuthRequired(const request_t * request, const char *realm)
 #endif
 
 static void
-ftpAuthRequired(HttpReply *old_reply, request_t *request, const char *realm)
+ftpAuthRequired(HttpReply * old_reply, request_t * request, const char *realm)
 {
     ErrorState *err = errorCon(ERR_ACCESS_DENIED, HTTP_UNAUTHORIZED);
     HttpReply *rep;
index 7da1e6ca9a23dd71d937e56085ba2abb947b3b40..a688955c4e9caf13917e68838310d85ace534c5a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.118 1998/01/12 04:30:02 wessels Exp $
+ * $Id: gopher.cc,v 1.119 1998/02/24 21:17:04 wessels Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -684,7 +684,10 @@ gopherReadReply(int fd, void *data)
     errno = 0;
     /* leave one space for \0 in gopherToHTML */
     len = read(fd, buf, TEMP_BUF_SIZE - 1);
-    fd_bytes(fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(10, 5) ("gopherReadReply: FD %d read len=%d\n", fd, len);
     if (len > 0) {
        commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
@@ -748,6 +751,10 @@ gopherSendComplete(int fd, char *buf, size_t size, int errflag, void *data)
     StoreEntry *entry = gopherState->entry;
     debug(10, 5) ("gopherSendComplete: FD %d size: %d errflag: %d\n",
        fd, size, errflag);
+    if (size > 0) {
+       fd_bytes(fd, size, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, size);
+    }
     if (errflag) {
        ErrorState *err;
        err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
index 5e483d222b8b6653798f7db17de3f9cac3a7a3ba..fe098cb73664a3d7448f9f220b2983a5e731b0db 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.240 1998/02/21 18:46:36 rousskov Exp $
+ * $Id: http.cc,v 1.241 1998/02/24 21:17:05 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
 
 static const char *const crlf = "\r\n";
 
-#if 0 /* moved to HttpHeader */
+#if 0                          /* moved to HttpHeader */
 typedef enum {
     SCC_PUBLIC,
     SCC_PRIVATE,
@@ -125,6 +125,7 @@ typedef enum {
     SCC_MAXAGE,
     SCC_ENUM_END
 } http_server_cc_t;
+
 #endif
 
 enum {
@@ -137,7 +138,7 @@ enum {
     CCC_ENUM_END
 };
 
-#if 0 /* moved to HttpHeader.h */
+#if 0                          /* moved to HttpHeader.h */
 typedef enum {
     HDR_ACCEPT,
     HDR_AGE,
@@ -200,6 +201,7 @@ static struct {
     int misc[HDR_MISC_END];
     int cc[SCC_ENUM_END];
 } ReplyHeaderStats;
+
 #endif /* if 0 */
 
 static CNCB httpConnectDone;
@@ -212,7 +214,7 @@ static void httpAppendRequestHeader(char *hdr, const char *line, size_t * sz, si
 static void httpCacheNegatively(StoreEntry *);
 static void httpMakePrivate(StoreEntry *);
 static void httpMakePublic(StoreEntry *);
-#if 0 /* moved to HttpResponse */
+#if 0                          /* moved to HttpResponse */
 static char *httpStatusString(int status);
 #endif
 static STABH httpAbort;
@@ -552,7 +554,7 @@ httpProcessReplyHeader(HttpStateData * httpState, const char *buf, int size)
        /* Parse headers into reply structure */
        /* Old code never parsed headers if mime_headers_end failed, was it intentional ? @?@ @?@ */
        /* what happens if we fail to parse here? @?@ @?@ */
-       httpReplyParse(reply, httpState->reply_hdr); /* httpState->eof); */
+       httpReplyParse(reply, httpState->reply_hdr);    /* httpState->eof); */
        storeTimestampsSet(entry);
        /* Check if object is cacheable or not based on reply code */
        debug(11, 3) ("httpProcessReplyHeader: HTTP CODE: %d\n", reply->sline.status);
@@ -656,9 +658,10 @@ httpReadReply(int fd, void *data)
     clen = entry->mem_obj->inmem_hi;
     errno = 0;
     len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
-    fd_bytes(fd, len, FD_READ);
     debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, len);
     if (len > 0) {
+       fd_bytes(fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
        commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
        IOStats.Http.reads++;
        for (clen = len - 1, bin = 0; clen; bin++)
@@ -735,6 +738,10 @@ httpSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data)
     ErrorState *err;
     debug(11, 5) ("httpSendComplete: FD %d: size %d: errflag %d.\n",
        fd, size, errflag);
+    if (size > 0) {
+       fd_bytes(fd, size, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, size);
+    }
     if (errflag == COMM_ERR_CLOSING)
        return;
     if (errflag) {
@@ -1135,7 +1142,7 @@ httpConnectDone(int fd, int status, void *data)
     }
 }
 
-#if 0 /* moved to httpHeader */
+#if 0                          /* moved to httpHeader */
 void
 httpReplyHeaderStats(StoreEntry * entry)
 {
@@ -1171,7 +1178,7 @@ httpAbort(void *data)
     comm_close(httpState->fd);
 }
 
-#if 0 /* moved to httpResponse.c */
+#if 0                          /* moved to httpResponse.c */
 static char *
 httpStatusString(int status)
 {
@@ -1297,7 +1304,7 @@ httpStatusString(int status)
 }
 #endif
 
-#if 0 /* moved to HttpResponse.c */
+#if 0                          /* moved to HttpResponse.c */
 char *
 httpReplyHeader(double ver,
     http_status status,
index 09a05565d9edf3296edfaf51fb5c0d8fe8b49149..2296676578c96fbb54f75157ad3549e41865fdb6 100644 (file)
@@ -52,7 +52,7 @@ icpUdpReply(int fd, void *data)
        UdpQueueHead = queue->next;
        if (queue->logcode) {
            icpLogIcp(queue);
-           statLogHistCount(&Counter.icp.svc_time,
+           statLogHistCount(&Counter.icp.reply_svc_time,
                tvSubUsec(queue->start, current_time));
        }
        safe_free(queue->msg);
index 77f6473c2f10a9c7fa7e510cb92332731eeb5415..294bd1715f9f544c5f6d1ff63c36c17f0902be15 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.37 1998/02/03 04:21:19 wessels Exp $
+ * $Id: peer_select.cc,v 1.38 1998/02/24 21:17:07 wessels Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -210,6 +210,7 @@ peerSelectCallback(ps_state * psstate, peer * p)
            eventDelete(peerPingTimeout, psstate);
        entry->ping_status = PING_DONE;
     }
+    psstate->icp.stop = current_time;
     if (cbdataValid(data))
        psstate->callback(p, data);
     cbdataUnlock(data);
index 323d22ea5f0c186fca0685b46c80825fd3f06368..638f63b27f4250627d15aa7c8ea9bc288cc01426 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.73 1998/01/12 04:30:11 wessels Exp $
+ * $Id: ssl.cc,v 1.74 1998/02/24 21:17:07 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -115,7 +115,10 @@ sslReadServer(int fd, void *data)
     SslStateData *sslState = data;
     int len;
     len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
-    fd_bytes(sslState->server.fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(sslState->server.fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(26, 5) ("sslReadServer FD %d, read %d bytes\n", fd, len);
     if (len < 0) {
        debug(50, 1) ("sslReadServer: FD %d: read failure: %s\n",
@@ -156,7 +159,10 @@ sslReadClient(int fd, void *data)
     SslStateData *sslState = data;
     int len;
     len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
-    fd_bytes(sslState->client.fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(sslState->client.fd, len, FD_READ);
+       kb_incr(&Counter.client_http.kbytes_in, len);
+    }
     debug(26, 5) ("sslReadClient FD %d, read %d bytes\n",
        sslState->client.fd, len);
     if (len < 0) {
@@ -194,7 +200,10 @@ sslWriteServer(int fd, void *data)
     len = write(sslState->server.fd,
        sslState->client.buf + sslState->client.offset,
        sslState->client.len - sslState->client.offset);
-    fd_bytes(fd, len, FD_WRITE);
+    if (len > 0) {
+       fd_bytes(sslState->server.fd, len, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, len);
+    }
     debug(26, 5) ("sslWriteServer FD %d, wrote %d bytes\n", fd, len);
     if (len < 0) {
        if (ignoreErrno(errno)) {
@@ -241,7 +250,10 @@ sslWriteClient(int fd, void *data)
     len = write(sslState->client.fd,
        sslState->server.buf + sslState->server.offset,
        sslState->server.len - sslState->server.offset);
-    fd_bytes(fd, len, FD_WRITE);
+    if (len > 0) {
+       fd_bytes(sslState->client.fd, len, FD_WRITE);
+       kb_incr(&Counter.client_http.kbytes_out, len);
+    }
     debug(26, 5) ("sslWriteClient FD %d, wrote %d bytes\n", fd, len);
     if (len < 0) {
        if (ignoreErrno(errno)) {
index 6b8548f4bae67c405724e827d8923f9663bc6e1e..2b763b00320cb38d186d0d323429d68b66cba32b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.203 1998/02/22 12:05:24 kostas Exp $
+ * $Id: stat.cc,v 1.204 1998/02/24 21:17:08 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -127,7 +127,6 @@ static OBJH info_get;
 static OBJH statFiledescriptors;
 static OBJH statCounters;
 static OBJH statAvg5min;
-static OBJH statAvg60min;
 
 #ifdef XMALLOC_STATISTICS
 static void info_get_mallstat(int, int, StoreEntry *);
@@ -136,7 +135,7 @@ static void info_get_mallstat(int, int, StoreEntry *);
 /*
  * An hour's worth, plus the 'current' counter
  */
-#define N_COUNT_HIST 61
+#define N_COUNT_HIST 6
 StatCounters CountHist[N_COUNT_HIST];
 static int NCountHist = 0;
 
@@ -576,6 +575,7 @@ statCountersDump(StoreEntry * sentry)
     squid_getrusage(&rusage);
     f->page_faults = rusage_pagefaults(&rusage);
     f->cputime = rusage_cputime(&rusage);
+
     storeAppendPrintf(sentry, "client_http.requests = %d\n",
        f->client_http.requests);
     storeAppendPrintf(sentry, "client_http.hits = %d\n",
@@ -586,8 +586,24 @@ statCountersDump(StoreEntry * sentry)
        (int) f->client_http.kbytes_in.kb);
     storeAppendPrintf(sentry, "client_http.kbytes_out = %d\n",
        (int) f->client_http.kbytes_out.kb);
-    storeAppendPrintf(sentry, "client_http.svc_time histogram:\n");
-    statLogHistDump(sentry, &f->client_http.svc_time);
+    storeAppendPrintf(sentry, "client_http.all_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->client_http.all_svc_time);
+    storeAppendPrintf(sentry, "client_http.miss_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->client_http.miss_svc_time);
+    storeAppendPrintf(sentry, "client_http.nm_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->client_http.nm_svc_time);
+    storeAppendPrintf(sentry, "client_http.hit_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->client_http.hit_svc_time);
+
+    storeAppendPrintf(sentry, "server.requests = %d\n",
+       (int) f->server.requests);
+    storeAppendPrintf(sentry, "server.errors = %d\n",
+       (int) f->server.errors);
+    storeAppendPrintf(sentry, "server.kbytes_in = %d\n",
+       (int) f->server.kbytes_in.kb);
+    storeAppendPrintf(sentry, "server.kbytes_out = %d\n",
+       (int) f->server.kbytes_out.kb);
+
     storeAppendPrintf(sentry, "icp.pkts_sent = %d\n",
        f->icp.pkts_sent);
     storeAppendPrintf(sentry, "icp.pkts_recv = %d\n",
@@ -596,8 +612,11 @@ statCountersDump(StoreEntry * sentry)
        (int) f->icp.kbytes_sent.kb);
     storeAppendPrintf(sentry, "icp.kbytes_recv = %d\n",
        (int) f->icp.kbytes_recv.kb);
-    storeAppendPrintf(sentry, "icp.svc_time histogram:\n");
-    statLogHistDump(sentry, &f->icp.svc_time);
+    storeAppendPrintf(sentry, "icp.query_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->icp.query_svc_time);
+    storeAppendPrintf(sentry, "icp.reply_svc_time histogram:\n");
+    statLogHistDump(sentry, &f->icp.reply_svc_time);
+
     storeAppendPrintf(sentry, "dns.svc_time histogram:\n");
     statLogHistDump(sentry, &f->dns.svc_time);
     storeAppendPrintf(sentry, "unlink.requests = %d\n",
@@ -629,6 +648,7 @@ statAvgDump(StoreEntry * sentry, int minutes)
     l = &CountHist[minutes];
     dt = tvSubDsec(l->timestamp, f->timestamp);
     ct = f->cputime - l->cputime;
+
     storeAppendPrintf(sentry, "client_http.requests = %f/sec\n",
        XAVG(client_http.requests));
     storeAppendPrintf(sentry, "client_http.hits = %f/sec\n",
@@ -639,9 +659,33 @@ statAvgDump(StoreEntry * sentry, int minutes)
        XAVG(client_http.kbytes_in.kb));
     storeAppendPrintf(sentry, "client_http.kbytes_out = %f/sec\n",
        XAVG(client_http.kbytes_out.kb));
-    x = statLogHistDeltaMedian(&l->client_http.svc_time, &f->client_http.svc_time);
-    storeAppendPrintf(sentry, "client_http.median_svc_time = %f seconds\n",
+
+    x = statLogHistDeltaMedian(&l->client_http.all_svc_time,
+       &f->client_http.all_svc_time);
+    storeAppendPrintf(sentry, "client_http.all_median_svc_time = %f seconds\n",
+       x / 1000.0);
+    x = statLogHistDeltaMedian(&l->client_http.miss_svc_time,
+       &f->client_http.miss_svc_time);
+    storeAppendPrintf(sentry, "client_http.miss_median_svc_time = %f seconds\n",
+       x / 1000.0);
+    x = statLogHistDeltaMedian(&l->client_http.nm_svc_time,
+       &f->client_http.nm_svc_time);
+    storeAppendPrintf(sentry, "client_http.nm_median_svc_time = %f seconds\n",
+       x / 1000.0);
+    x = statLogHistDeltaMedian(&l->client_http.hit_svc_time,
+       &f->client_http.hit_svc_time);
+    storeAppendPrintf(sentry, "client_http.hit_median_svc_time = %f seconds\n",
        x / 1000.0);
+
+    storeAppendPrintf(sentry, "server.requests = %f/sec\n",
+       XAVG(server.requests));
+    storeAppendPrintf(sentry, "server.errors = %f/sec\n",
+       XAVG(server.errors));
+    storeAppendPrintf(sentry, "server.kbytes_in = %f/sec\n",
+       XAVG(server.kbytes_in.kb));
+    storeAppendPrintf(sentry, "server.kbytes_out = %f/sec\n",
+       XAVG(server.kbytes_out.kb));
+
     storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n",
        XAVG(icp.pkts_sent));
     storeAppendPrintf(sentry, "icp.pkts_recv = %f/sec\n",
@@ -650,8 +694,11 @@ statAvgDump(StoreEntry * sentry, int minutes)
        XAVG(icp.kbytes_sent.kb));
     storeAppendPrintf(sentry, "icp.kbytes_recv = %f/sec\n",
        XAVG(icp.kbytes_recv.kb));
-    x = statLogHistDeltaMedian(&l->icp.svc_time, &f->icp.svc_time);
-    storeAppendPrintf(sentry, "icp.median_svc_time = %f seconds\n",
+    x = statLogHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time);
+    storeAppendPrintf(sentry, "icp.query_median_svc_time = %f seconds\n",
+       x / 1000000.0);
+    x = statLogHistDeltaMedian(&l->icp.reply_svc_time, &f->icp.reply_svc_time);
+    storeAppendPrintf(sentry, "icp.reply_median_svc_time = %f seconds\n",
        x / 1000000.0);
     x = statLogHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);
     storeAppendPrintf(sentry, "dns.median_svc_time = %f seconds\n",
@@ -674,11 +721,15 @@ statCounterInit(StatCounters * C)
     /*
      * HTTP svc_time hist is kept in milli-seconds; max of 3 hours.
      */
-    statLogHistInit(&C->client_http.svc_time, 0.0, 3600000.0 * 3.0);
+    statLogHistInit(&C->client_http.all_svc_time, 0.0, 3600000.0 * 3.0);
+    statLogHistInit(&C->client_http.miss_svc_time, 0.0, 3600000.0 * 3.0);
+    statLogHistInit(&C->client_http.nm_svc_time, 0.0, 3600000.0 * 3.0);
+    statLogHistInit(&C->client_http.hit_svc_time, 0.0, 3600000.0 * 3.0);
     /*
      * ICP svc_time hist is kept in micro-seconds; max of 1 minute.
      */
-    statLogHistInit(&C->icp.svc_time, 0.0, 1000000.0 * 60.0);
+    statLogHistInit(&C->icp.query_svc_time, 0.0, 1000000.0 * 60.0);
+    statLogHistInit(&C->icp.reply_svc_time, 0.0, 1000000.0 * 60.0);
     /*
      * DNS svc_time hist is kept in milli-seconds; max of 10 minutes.
      */
@@ -716,9 +767,6 @@ statInit(void)
     cachemgrRegister("5min",
        "5 Minute Average of Counters",
        statAvg5min, 0);
-    cachemgrRegister("60min",
-       "60 Minute Average of Counters",
-       statAvg60min, 0);
 }
 
 static void
@@ -750,12 +798,6 @@ statAvg5min(StoreEntry * e)
     statAvgDump(e, 5);
 }
 
-void
-statAvg60min(StoreEntry * e)
-{
-    statAvgDump(e, 60);
-}
-
 void
 statLogHistInit(StatLogHist * H, double min, double max)
 {
@@ -842,9 +884,11 @@ statLogHistVal(StatLogHist * H, double bin)
     return exp(bin / H->scale) + H->min - 1.0;
 }
 
-enum { HTTP_SVC, ICP_SVC, DNS_SVC };
+enum {
+    HTTP_SVC, ICP_SVC, DNS_SVC
+};
 
-int 
+int
 get_median_svc(int interval, int which)
 {
     StatCounters *f;
@@ -853,23 +897,23 @@ get_median_svc(int interval, int which)
 
     f = &CountHist[0];
     l = &CountHist[interval];
-       assert(f);
-       assert(l);
+    assert(f);
+    assert(l);
     switch (which) {
     case HTTP_SVC:
-        x = statLogHistDeltaMedian(&l->client_http.svc_time, &f->client_http.svc_time);
-        break;
+       x = statLogHistDeltaMedian(&l->client_http.all_svc_time, &f->client_http.all_svc_time);
+       break;
     case ICP_SVC:
-        x = statLogHistDeltaMedian(&l->icp.svc_time, &f->icp.svc_time);
-        break;
+       x = statLogHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time);
+       break;
     case DNS_SVC:
-        x = statLogHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);
-        break;
+       x = statLogHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);
+       break;
     default:
-        debug(49,5)("get_median_val: unknown type.\n");
-        x=0;
+       debug(49, 5) ("get_median_val: unknown type.\n");
+       x = 0;
     }
-    return (int)x;
+    return (int) x;
 }
 static void
 statLogHistDump(StoreEntry * sentry, StatLogHist * H)
index ba0e9aaa3a1d2bf6eb58bbed6ee47b831200c1fb..03d7f9ebaa484788fea99a95895a621a0ba5ef4d 100644 (file)
@@ -433,13 +433,13 @@ struct _hash_table {
 #include "Packer.h"
 #include "HttpReply.h"
 
-# if 0 /* tmp moved to HttpReply.h */
+#if 0                          /* tmp moved to HttpReply.h */
 #define Const const
 struct _http_reply {
     double version;
     int code;
     int content_length;
-    int hdr_sz;             /* includes _stored_ status-line, headers, and <CRLF> */
+    int hdr_sz;                        /* includes _stored_ status-line, headers, and <CRLF> */
     /* Note: fields below may not match info stored on disk */
     Const int cache_control;
     Const int misc_headers;
@@ -447,10 +447,11 @@ struct _http_reply {
     Const time_t expires;
     Const time_t last_modified;
     Const char content_type[HTTP_REPLY_FIELD_SZ];
-#if 0 /* unused 512 bytes? */
+#if 0                          /* unused 512 bytes? */
     Const char user_agent[HTTP_REPLY_FIELD_SZ << 2];
 #endif
 };
+
 #endif
 
 
@@ -492,7 +493,7 @@ struct _icp_ping_data {
 struct _HierarchyLogEntry {
     hier_code code;
     char host[SQUIDHOSTNAMELEN];
-    struct _icp_ping_data icp;
+    icp_ping_data icp;
 };
 
 struct _AccessLogEntry {
@@ -747,12 +748,13 @@ struct _icp_common_t {
     u_num32 shostid;           /* sender host id */
 };
 
-#if 0 /* this struct is not used */
+#if 0                          /* this struct is not used */
 struct _Stack {
     void **base;
     void **top;
     int stack_size;
 };
+
 #endif
 
 struct _Meta_data {
@@ -956,7 +958,10 @@ struct _StatCounters {
        kb_t kbytes_in;
        kb_t kbytes_out;
        kb_t hit_kbytes_out;
-       StatLogHist svc_time;
+       StatLogHist miss_svc_time;
+       StatLogHist nm_svc_time;
+       StatLogHist hit_svc_time;
+       StatLogHist all_svc_time;
     } client_http;
     struct {
        int requests;
@@ -971,7 +976,8 @@ struct _StatCounters {
        int hits_recv;
        kb_t kbytes_sent;
        kb_t kbytes_recv;
-       StatLogHist svc_time;
+       StatLogHist query_svc_time;
+       StatLogHist reply_svc_time;
     } icp;
     struct {
        int requests;
index a0124c8cf69327c0cf1d5d380fe0ce537c066337..f97a1ade12c38de63137e53a87b2389249253dc0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.73 1998/01/12 04:30:11 wessels Exp $
+ * $Id: tunnel.cc,v 1.74 1998/02/24 21:17:07 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -115,7 +115,10 @@ sslReadServer(int fd, void *data)
     SslStateData *sslState = data;
     int len;
     len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF);
-    fd_bytes(sslState->server.fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(sslState->server.fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(26, 5) ("sslReadServer FD %d, read %d bytes\n", fd, len);
     if (len < 0) {
        debug(50, 1) ("sslReadServer: FD %d: read failure: %s\n",
@@ -156,7 +159,10 @@ sslReadClient(int fd, void *data)
     SslStateData *sslState = data;
     int len;
     len = read(sslState->client.fd, sslState->client.buf, SQUID_TCP_SO_RCVBUF);
-    fd_bytes(sslState->client.fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(sslState->client.fd, len, FD_READ);
+       kb_incr(&Counter.client_http.kbytes_in, len);
+    }
     debug(26, 5) ("sslReadClient FD %d, read %d bytes\n",
        sslState->client.fd, len);
     if (len < 0) {
@@ -194,7 +200,10 @@ sslWriteServer(int fd, void *data)
     len = write(sslState->server.fd,
        sslState->client.buf + sslState->client.offset,
        sslState->client.len - sslState->client.offset);
-    fd_bytes(fd, len, FD_WRITE);
+    if (len > 0) {
+       fd_bytes(sslState->server.fd, len, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, len);
+    }
     debug(26, 5) ("sslWriteServer FD %d, wrote %d bytes\n", fd, len);
     if (len < 0) {
        if (ignoreErrno(errno)) {
@@ -241,7 +250,10 @@ sslWriteClient(int fd, void *data)
     len = write(sslState->client.fd,
        sslState->server.buf + sslState->server.offset,
        sslState->server.len - sslState->server.offset);
-    fd_bytes(fd, len, FD_WRITE);
+    if (len > 0) {
+       fd_bytes(sslState->client.fd, len, FD_WRITE);
+       kb_incr(&Counter.client_http.kbytes_out, len);
+    }
     debug(26, 5) ("sslWriteClient FD %d, wrote %d bytes\n", fd, len);
     if (len < 0) {
        if (ignoreErrno(errno)) {
index 61dc30c99b14b66832624b5a96e5a37380b4bbce..abd0f282079285806d193e2fc7e6c8be451df551 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.100 1998/01/12 04:30:17 wessels Exp $
+ * $Id: wais.cc,v 1.101 1998/02/24 21:17:09 wessels Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -173,7 +173,10 @@ waisReadReply(int fd, void *data)
     clen = entry->mem_obj->inmem_hi;
     off = storeLowestMemReaderOffset(entry);
     len = read(fd, buf, 4096);
-    fd_bytes(fd, len, FD_READ);
+    if (len > 0) {
+       fd_bytes(fd, len, FD_READ);
+       kb_incr(&Counter.server.kbytes_in, len);
+    }
     debug(24, 5) ("waisReadReply: FD %d read len:%d\n", fd, len);
     if (len > 0) {
        commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
@@ -229,6 +232,10 @@ waisSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data)
     StoreEntry *entry = waisState->entry;
     debug(24, 5) ("waisSendComplete: FD %d size: %d errflag: %d\n",
        fd, size, errflag);
+    if (size > 0) {
+       fd_bytes(fd, size, FD_WRITE);
+       kb_incr(&Counter.server.kbytes_out, size);
+    }
     if (errflag == COMM_ERR_CLOSING)
        return;
     if (errflag) {