--------------------- PatchSet 11230 Date: 2007/02/03 21:59:24 Author: hno Branch: SQUID_2_6 Tag: (none) Log: Author: Alter MFC: logging HTTP-request size I've made patch to Squid 2.5-stable14 (r4), which enables logging of http-request size and/or total request+reply size. Patch extends 'logformat' option of squid.conf. '>st' and 'st' can be used to log request size and total size respectively. If 'st' is used instead of 'a %Ss/%03Hs %st %rm %ru %un %Sh/%1.95.2.1 src/cf.data.pre:1.382->1.382.2.1 src/client_side.c:1.693.2.2->1.693.2.3 src/structs.h:1.507.2.1->1.507.2.2 Index: squid/src/access_log.c =================================================================== RCS file: /cvsroot/squid/squid/src/access_log.c,v retrieving revision 1.95 retrieving revision 1.95.2.1 diff -u -r1.95 -r1.95.2.1 --- squid/src/access_log.c 19 Jan 2007 00:19:26 -0000 1.95 +++ squid/src/access_log.c 3 Feb 2007 21:59:24 -0000 1.95.2.1 @@ -1,6 +1,6 @@ /* - * $Id: access_log.c,v 1.95 2007/01/19 00:19:26 hno Exp $ + * $Id: access_log.c,v 1.95.2.1 2007/02/03 21:59:24 hno Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -300,7 +300,7 @@ /*LFT_REQUEST_QUERY, * // * this is not needed. see strip_query_terms */ LFT_REQUEST_VERSION, -/*LFT_REQUEST_SIZE_TOTAL, */ + LFT_REQUEST_SIZE_TOTAL, /*LFT_REQUEST_SIZE_LINE, */ /*LFT_REQUEST_SIZE_HEADERS, */ /*LFT_REQUEST_SIZE_BODY, */ @@ -312,6 +312,8 @@ /*LFT_REPLY_SIZE_BODY, */ /*LFT_REPLY_SIZE_BODY_NO_TE, */ + LFT_IO_SIZE_TOTAL, + LFT_EXT_LOG, LFT_PERCENT /* special string cases for escaped chars */ @@ -402,20 +404,22 @@ {">v", LFT_REQUEST_VERSION}, {"rv", LFT_REQUEST_VERSION}, -/*{ ">st", LFT_REQUEST_SIZE_TOTAL }, */ + {">st", LFT_REQUEST_SIZE_TOTAL}, /*{ ">sl", LFT_REQUEST_SIZE_LINE }, * / / * the request line "GET ... " */ /*{ ">sh", LFT_REQUEST_SIZE_HEADERS }, */ /*{ ">sb", LFT_REQUEST_SIZE_BODY }, */ /*{ ">sB", LFT_REQUEST_SIZE_BODY_NO_TE }, */ - {"ea", LFT_EXT_LOG}, - {"cache.rq_size; + doint = 1; + break; /*case LFT_REQUEST_SIZE_LINE: */ /*case LFT_REQUEST_SIZE_HEADERS: */ /*case LFT_REQUEST_SIZE_BODY: */ @@ -649,6 +656,11 @@ /*case LFT_REPLY_SIZE_BODY: */ /*case LFT_REPLY_SIZE_BODY_NO_TE: */ + case LFT_IO_SIZE_TOTAL: + outint = al->cache.size + al->cache.rq_size; + doint = 1; + break; + case LFT_EXT_LOG: if (al->request) out = strBuf(al->request->extacl_log); Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid/squid/src/cf.data.pre,v retrieving revision 1.382 retrieving revision 1.382.2.1 diff -u -r1.382 -r1.382.2.1 --- squid/src/cf.data.pre 19 Jan 2007 22:03:03 -0000 1.382 +++ squid/src/cf.data.pre 3 Feb 2007 21:59:24 -0000 1.382.2.1 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.382 2007/01/19 22:03:03 hno Exp $ +# $Id: cf.data.pre,v 1.382.2.1 2007/02/03 21:59:24 hno Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1273,6 +1273,8 @@ rv Request protocol version ea Log string returned by external acl st Request size including HTTP headers + st Request+Reply size including HTTP headers % a literal % character logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %al.cache.size = http->out.size; http->al.cache.code = http->log_type; http->al.cache.msec = tvSubMsec(http->start, current_time); + http->al.cache.rq_size = http->req_sz; if (request) { + http->al.cache.rq_size += request->content_length; if (Config.onoff.log_mime_hdrs) { Packer p; MemBuf mb; Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.507.2.1 retrieving revision 1.507.2.2 diff -u -r1.507.2.1 -r1.507.2.2 --- squid/src/structs.h 21 Jan 2007 10:26:44 -0000 1.507.2.1 +++ squid/src/structs.h 3 Feb 2007 21:59:24 -0000 1.507.2.2 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.507.2.1 2007/01/21 10:26:44 hno Exp $ + * $Id: structs.h,v 1.507.2.2 2007/02/03 21:59:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1160,6 +1160,7 @@ struct { struct in_addr caddr; squid_off_t size; + size_t rq_size; log_type code; int msec; const char *rfc931;