--------------------- PatchSet 6218 Date: 2004/05/13 16:26:19 Author: dwsquid Branch: icap-2_5 Tag: (none) Log: A user noticed that Squid's byte hit ratio numbers are really screwed up when using ICAP. That was becasue ICAP bytes were accounted to the HTTP server side. This patch creates an icap statCounter section where all ICAP bytes will be accounted. Also added reporting of ICAP counters in the cache manager output. Members: src/icap_opt.c:1.1.2.10->1.1.2.11 src/icap_reqmod.c:1.1.2.27->1.1.2.28 src/icap_respmod.c:1.1.2.33->1.1.2.34 src/stat.c:1.13.6.7.2.1->1.13.6.7.2.2 src/structs.h:1.48.2.9.2.27->1.48.2.9.2.28 Index: squid/src/icap_opt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_opt.c,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid/src/icap_opt.c 14 Jan 2004 08:23:21 -0000 1.1.2.10 +++ squid/src/icap_opt.c 13 May 2004 16:26:19 -0000 1.1.2.11 @@ -1,6 +1,6 @@ /* - * $Id: icap_opt.c,v 1.1.2.10 2004/01/14 08:23:21 rhorstmann Exp $ + * $Id: icap_opt.c,v 1.1.2.11 2004/05/13 16:26:19 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client OPTIONS * AUTHOR: Ralf Horstmann @@ -218,9 +218,7 @@ fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, size); - /* should use some ICAP statistics for this */ - /* kb_incr(&statCounter.server.http.kbytes_out, size); */ + kb_incr(&statCounter.icap.all.kbytes_out, size); } if (errflag) { /* cancel this for now */ @@ -269,6 +267,7 @@ if (size > 0) { /* do some statistics */ fd_bytes(fd, size, FD_READ); + kb_incr(&statCounter.icap.all.kbytes_in, size); /* * some icap servers seem to ignore the "Connection: close" header. so Index: squid/src/icap_reqmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_reqmod.c,v retrieving revision 1.1.2.27 retrieving revision 1.1.2.28 diff -u -r1.1.2.27 -r1.1.2.28 --- squid/src/icap_reqmod.c 2 Dec 2003 14:18:51 -0000 1.1.2.27 +++ squid/src/icap_reqmod.c 13 May 2004 16:26:19 -0000 1.1.2.28 @@ -1,6 +1,6 @@ /* - * $Id: icap_reqmod.c,v 1.1.2.27 2003/12/02 14:18:51 rhorstmann Exp $ + * $Id: icap_reqmod.c,v 1.1.2.28 2004/05/13 16:26:19 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -414,6 +414,7 @@ fatalf("need to handle read error at %s:%d", __FILE__, __LINE__); } fd_bytes(fd, rl, FD_READ); + kb_incr(&statCounter.icap.all.kbytes_in, rl); memBufAppend(&icap->reqmod.hdr_buf, tmpbuf, rl); icap->http_header_bytes_read_so_far += rl; if (rl != needed) { @@ -537,8 +538,7 @@ fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, size); - kb_incr(&statCounter.server.http.kbytes_out, size); + kb_incr(&statCounter.icap.all.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) return; @@ -696,6 +696,7 @@ if (!icapConnect(icap, icapSendReqMod)) return NULL; + statCounter.icap.all.requests++; debug(81, 3) ("icapReqModStart: returning %p\n", icap); return icap; } @@ -782,6 +783,7 @@ icap->flags.reqmod_http_entity_eof = 1; } else { fd_bytes(fd, len, FD_READ); + kb_incr(&statCounter.icap.all.kbytes_in, len); icap->reqmod.http_entity.bytes_read += icapParseChunkedBody(icap, icapReqModMemBufAppend, &icap->reqmod.http_entity.buf); Index: squid/src/icap_respmod.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/icap_respmod.c,v retrieving revision 1.1.2.33 retrieving revision 1.1.2.34 diff -u -r1.1.2.33 -r1.1.2.34 --- squid/src/icap_respmod.c 3 May 2004 12:24:10 -0000 1.1.2.33 +++ squid/src/icap_respmod.c 13 May 2004 16:26:20 -0000 1.1.2.34 @@ -1,6 +1,6 @@ /* - * $Id: icap_respmod.c,v 1.1.2.33 2004/05/03 12:24:10 rhorstmann Exp $ + * $Id: icap_respmod.c,v 1.1.2.34 2004/05/13 16:26:20 dwsquid Exp $ * * DEBUG: section 81 Internet Content Adaptation Protocol (ICAP) Client * AUTHOR: Geetha Manjunath, Hewlett Packard Company @@ -523,8 +523,7 @@ fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&statCounter.server.all.kbytes_out, size); - kb_incr(&statCounter.server.http.kbytes_out, size); + kb_incr(&statCounter.icap.all.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) return; @@ -656,6 +655,7 @@ * case it turns out to be a 204 */ icap->flags.copy_response = 1; + statCounter.icap.all.requests++; debug(81, 3) ("icapRespModStart: returning %p\n", icap); return icap; } @@ -764,6 +764,7 @@ debug(81, 5) ("icapReadReply: FD %d: len %d.\n", fd, len); if (len > 0) { fd_bytes(fd, len, FD_READ); + kb_incr(&statCounter.icap.all.kbytes_in, len); commSetTimeout(fd, Config.Timeout.read, icapReadTimeout, icap); if (icap->chunk_buf.size < icap->chunk_buf.capacity) { *(icap->chunk_buf.buf + icap->chunk_buf.size) = '\0'; Index: squid/src/stat.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stat.c,v retrieving revision 1.13.6.7.2.1 retrieving revision 1.13.6.7.2.2 diff -u -r1.13.6.7.2.1 -r1.13.6.7.2.2 --- squid/src/stat.c 27 Jun 2003 00:56:06 -0000 1.13.6.7.2.1 +++ squid/src/stat.c 13 May 2004 16:26:20 -0000 1.13.6.7.2.2 @@ -1,6 +1,6 @@ /* - * $Id: stat.c,v 1.13.6.7.2.1 2003/06/27 00:56:06 hno Exp $ + * $Id: stat.c,v 1.13.6.7.2.2 2004/05/13 16:26:20 dwsquid Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -748,6 +748,17 @@ storeAppendPrintf(sentry, "server.other.kbytes_out = %f/sec\n", XAVG(server.other.kbytes_out.kb)); +#ifdef HS_FEAT_ICAP + storeAppendPrintf(sentry, "icap.all.requests = %f/sec\n", + XAVG(icap.all.requests)); + storeAppendPrintf(sentry, "icap.all.errors = %f/sec\n", + XAVG(icap.all.errors)); + storeAppendPrintf(sentry, "icap.all.kbytes_in = %f/sec\n", + XAVG(icap.all.kbytes_in.kb)); + storeAppendPrintf(sentry, "icap.all.kbytes_out = %f/sec\n", + XAVG(icap.all.kbytes_out.kb)); +#endif + storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n", XAVG(icp.pkts_sent)); storeAppendPrintf(sentry, "icp.pkts_recv = %f/sec\n", @@ -1129,6 +1140,17 @@ storeAppendPrintf(sentry, "server.other.kbytes_out = %d\n", (int) f->server.other.kbytes_out.kb); +#if HS_FEAT_ICAP + storeAppendPrintf(sentry, "icap.all.requests = %d\n", + (int) f->icap.all.requests); + storeAppendPrintf(sentry, "icap.all.errors = %d\n", + (int) f->icap.all.errors); + storeAppendPrintf(sentry, "icap.all.kbytes_in = %d\n", + (int) f->icap.all.kbytes_in.kb); + storeAppendPrintf(sentry, "icap.all.kbytes_out = %d\n", + (int) f->icap.all.kbytes_out.kb); +#endif + storeAppendPrintf(sentry, "icp.pkts_sent = %d\n", f->icp.pkts_sent); storeAppendPrintf(sentry, "icp.pkts_recv = %d\n", Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.9.2.27 retrieving revision 1.48.2.9.2.28 diff -u -r1.48.2.9.2.27 -r1.48.2.9.2.28 --- squid/src/structs.h 3 May 2004 12:24:09 -0000 1.48.2.9.2.27 +++ squid/src/structs.h 13 May 2004 16:26:20 -0000 1.48.2.9.2.28 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.9.2.27 2004/05/03 12:24:09 rhorstmann Exp $ + * $Id: structs.h,v 1.48.2.9.2.28 2004/05/13 16:26:20 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1925,7 +1925,11 @@ kb_t kbytes_in; kb_t kbytes_out; } all , http, ftp, other; - } server; + } +#if HS_FEAT_ICAP + icap, +#endif + server; struct { int pkts_sent; int queries_sent;