From: wessels <> Date: Thu, 5 Mar 1998 06:52:37 +0000 (+0000) Subject: Added more server-side counters and accounting based on patch from X-Git-Tag: SQUID_3_0_PRE1~3931 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0f327753bc3041cabaf2e606fa0c878a1854243;p=thirdparty%2Fsquid.git Added more server-side counters and accounting based on patch from Lincon Dale. Also removed some '#if 0' code chunks. --- diff --git a/src/ftp.cc b/src/ftp.cc index 5608e779cf..c67fee94c2 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.199 1998/03/03 00:31:05 rousskov Exp $ + * $Id: ftp.cc,v 1.200 1998/03/04 23:52:39 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -135,17 +135,10 @@ static PF ftpStateFree; static PF ftpTimeout; static PF ftpReadControlReply; static CWCB ftpWriteCommandCallback; -#if 0 -static char *ftpGetBasicAuth(const char *); -#endif static void ftpLoginParser(const char *, FtpStateData *); static wordlist *ftpParseControlReply(char *buf, size_t len, int *code); 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); -#endif static STABH ftpAbort; static void ftpHackShortcut(FtpStateData * ftpState, FTPSM * nextState); @@ -775,7 +768,8 @@ ftpDataRead(int fd, void *data) ftpState->data.size - ftpState->data.offset); if (len > 0) { fd_bytes(fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.ftp.kbytes_in, len); } debug(9, 5) ("ftpDataRead: FD %d, Read %d bytes\n", fd, len); if (len > 0) { @@ -819,26 +813,6 @@ ftpDataRead(int fd, void *data) } } -#if 0 /* moved to mime.c because cachemgr needs it too */ -static char * -ftpGetBasicAuth(const char *req_hdr) -{ - char *auth_hdr; - char *t; - if (req_hdr == NULL) - return NULL; - if ((auth_hdr = mime_get_header(req_hdr, "Authorization")) == NULL) - return NULL; - if ((t = strtok(auth_hdr, " \t")) == NULL) - return NULL; - if (strcasecmp(t, "Basic") != 0) - return NULL; - if ((t = strtok(NULL, " \t")) == NULL) - return NULL; - return base64_decode(t); -} -#endif - /* * ftpCheckAuth * @@ -930,13 +904,13 @@ ftpStart(request_t * request, StoreEntry * entry) LOCAL_ARRAY(char, realm, 8192); const char *url = storeUrl(entry); FtpStateData *ftpState = xcalloc(1, sizeof(FtpStateData)); -#if 0 - char *response; -#endif int fd; ErrorState *err; + HttpReply *reply; cbdataAdd(ftpState, MEM_NONE); debug(9, 3) ("FtpStart: '%s'\n", url); + Counter.server.all.requests++; + Counter.server.ftp.requests++; storeLockObject(entry); ftpState->entry = entry; ftpState->request = requestLink(request); @@ -952,20 +926,12 @@ ftpStart(request_t * request, StoreEntry * entry) snprintf(realm, 8192, "ftp %s port %d", ftpState->user, request->port); } -#if 0 - response = ftpAuthRequired(request, realm); - storeAppend(entry, response, strlen(response)); - httpParseReplyHeaders(response, entry->mem_obj->reply); -#else /* create reply */ - { - HttpReply *reply = entry->mem_obj->reply; - assert(reply); - /* create appropreate reply */ - ftpAuthRequired(reply, request, realm); - httpReplySwapOut(reply, entry); - } -#endif + reply = entry->mem_obj->reply; + assert(reply != NULL); + /* create appropriate reply */ + ftpAuthRequired(reply, request, realm); + httpReplySwapOut(reply, entry); storeComplete(entry); ftpStateFree(-1, ftpState); return; @@ -1065,7 +1031,8 @@ ftpWriteCommandCallback(int fd, char *bufnotused, size_t size, int errflag, void 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); + kb_incr(&Counter.server.all.kbytes_out, size); + kb_incr(&Counter.server.ftp.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) return; @@ -1137,7 +1104,8 @@ ftpReadControlReply(int fd, void *data) ftpState->ctrl.size - ftpState->ctrl.offset); if (len > 0) { fd_bytes(fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.ftp.kbytes_in,len); } debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, len); if (len < 0) { @@ -1984,30 +1952,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) } } storeBuffer(e); -#if 0 /* old code */ - storeAppendPrintf(e, "HTTP/1.0 200 Gatewaying\r\n"); - reply->code = 200; - reply->version = 1.0; - storeAppendPrintf(e, "Date: %s\r\n", mkrfc1123(squid_curtime)); - reply->date = squid_curtime; - storeAppendPrintf(e, "MIME-Version: 1.0\r\n"); - storeAppendPrintf(e, "Server: Squid %s\r\n", version_string); - if (ftpState->size > 0) { - storeAppendPrintf(e, "Content-Length: %d\r\n", ftpState->size); - reply->content_length = ftpState->size; - } - if (mime_type) { - storeAppendPrintf(e, "Content-Type: %s\r\n", mime_type); - xstrncpy(reply->content_type, mime_type, HTTP_REPLY_FIELD_SZ); - } - if (mime_enc) - storeAppendPrintf(e, "Content-Encoding: %s\r\n", mime_enc); - if (ftpState->mdtm > 0) { - storeAppendPrintf(e, "Last-Modified: %s\r\n", mkrfc1123(ftpState->mdtm)); - reply->last_modified = ftpState->mdtm; - } - storeAppendPrintf(e, "\r\n"); -#else httpReplyReset(reply); /* set standard stuff */ httpReplySetHeaders(reply, 1.0, HTTP_OK, "Gatewaying", @@ -2016,7 +1960,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) if (mime_enc) httpHeaderSetStr(&reply->hdr, HDR_CONTENT_ENCODING, mime_enc); httpReplySwapOut(reply, e); -#endif storeBufferFlush(e); reply->hdr_sz = e->mem_obj->inmem_hi; storeTimestampsSet(e); @@ -2035,57 +1978,6 @@ ftpAbort(void *data) comm_close(ftpState->ctrl.fd); } -#if 0 /* use new interfaces instead */ -static char * -ftpAuthRequired(const request_t * request, const char *realm) -{ - LOCAL_ARRAY(char, content, AUTH_MSG_SZ); - LOCAL_ARRAY(char, buf, AUTH_MSG_SZ); - char *hdr; - int s = AUTH_MSG_SZ; - int l = 0; - /* Generate the reply body */ - l += snprintf(content + l, s - l, - "Authorization needed\n" - "

Authorization needed

\n" - "

Sorry, you have to authorize yourself to request:\n" - "

    ftp://%s@%s%256.256s
\n" - "

from this cache. Please check with the\n" - "cache administrator\n" - "if you believe this is incorrect.\n" - "

\n" - "%s\n" - "


\n" - "
\n" - "Generated by %s/%s@%s\n" - "
\n" - "\n", - request->login, - request->host, - request->urlpath, - Config.adminEmail, - Config.errHtmlText, - appname, - version_string, - getMyHostname()); - /* Now generate reply headers with correct content length */ - hdr = httpReplyHeader(1.0, HTTP_UNAUTHORIZED, - "text/html", - strlen(content), - squid_curtime, - squid_curtime + Config.negativeTtl); - /* Now stuff them together and add Authenticate header */ - l = 0; - s = AUTH_MSG_SZ; - l += snprintf(buf + l, s - l, "%s", hdr); - l += snprintf(buf + l, s - l, - "WWW-Authenticate: Basic realm=\"%s\"\r\n", - realm); - l += snprintf(buf + l, s - l, "\r\n%s", content); - return buf; -} -#endif - static void ftpAuthRequired(HttpReply * old_reply, request_t * request, const char *realm) { diff --git a/src/gopher.cc b/src/gopher.cc index c54f54a7ab..881be4b12e 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.120 1998/03/03 00:31:06 rousskov Exp $ + * $Id: gopher.cc,v 1.121 1998/03/04 23:52:41 wessels Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -686,7 +686,8 @@ gopherReadReply(int fd, void *data) len = read(fd, buf, TEMP_BUF_SIZE - 1); if (len > 0) { fd_bytes(fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.other.kbytes_in, len); } debug(10, 5) ("gopherReadReply: FD %d read len=%d\n", fd, len); if (len > 0) { @@ -753,7 +754,8 @@ gopherSendComplete(int fd, char *buf, size_t size, int errflag, void *data) fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&Counter.server.kbytes_out, size); + kb_incr(&Counter.server.all.kbytes_out, size); + kb_incr(&Counter.server.other.kbytes_out, size); } if (errflag) { ErrorState *err; @@ -841,6 +843,8 @@ gopherStart(StoreEntry * entry) storeLockObject(entry); gopherState->entry = entry; debug(10, 3) ("gopherStart: %s\n", storeUrl(entry)); + Counter.server.all.requests++; + Counter.server.other.requests++; /* Parse url. */ if (gopher_url_parser(storeUrl(entry), gopherState->host, &gopherState->port, &gopherState->type_id, gopherState->request)) { diff --git a/src/http.cc b/src/http.cc index bd2dcdd4c3..3be3fefe50 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.243 1998/03/03 00:31:07 rousskov Exp $ + * $Id: http.cc,v 1.244 1998/03/04 23:52:40 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -661,7 +661,8 @@ httpReadReply(int fd, void *data) 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); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.http.kbytes_in, len); commSetTimeout(fd, Config.Timeout.read, NULL, NULL); IOStats.Http.reads++; for (clen = len - 1, bin = 0; clen; bin++) @@ -740,7 +741,8 @@ httpSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&Counter.server.kbytes_out, size); + kb_incr(&Counter.server.all.kbytes_out, size); + kb_incr(&Counter.server.http.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) return; @@ -1047,6 +1049,8 @@ httpStart(request_t * request, StoreEntry * entry, peer * e) int fd; debug(11, 3) ("httpStart: \"%s %s\"\n", RequestMethodStr[request->method], storeUrl(entry)); + Counter.server.all.requests++; + Counter.server.http.requests++; if (e) { if (e->options & NEIGHBOR_PROXY_ONLY) storeReleaseRequest(entry); diff --git a/src/ssl.cc b/src/ssl.cc index 638f63b27f..341358b013 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.74 1998/02/24 21:17:07 wessels Exp $ + * $Id: ssl.cc,v 1.75 1998/03/04 23:52:42 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -117,7 +117,8 @@ sslReadServer(int fd, void *data) len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF); if (len > 0) { fd_bytes(sslState->server.fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.other.kbytes_in, len); } debug(26, 5) ("sslReadServer FD %d, read %d bytes\n", fd, len); if (len < 0) { @@ -202,7 +203,8 @@ sslWriteServer(int fd, void *data) sslState->client.len - sslState->client.offset); if (len > 0) { fd_bytes(sslState->server.fd, len, FD_WRITE); - kb_incr(&Counter.server.kbytes_out, len); + kb_incr(&Counter.server.all.kbytes_out, len); + kb_incr(&Counter.server.other.kbytes_out, len); } debug(26, 5) ("sslWriteServer FD %d, wrote %d bytes\n", fd, len); if (len < 0) { @@ -364,6 +366,8 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr) ErrorState *err = NULL; debug(26, 3) ("sslStart: '%s %s'\n", RequestMethodStr[request->method], url); + Counter.server.all.requests++; + Counter.server.other.requests++; /* Create socket. */ sock = comm_open(SOCK_STREAM, 0, diff --git a/src/stat.cc b/src/stat.cc index 49c7271524..650be89fe6 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.210 1998/02/26 18:00:53 wessels Exp $ + * $Id: stat.cc,v 1.211 1998/03/04 23:52:37 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -112,7 +112,7 @@ static const char *describeStatuses(const StoreEntry *); static const char *describeFlags(const StoreEntry *); static const char *describeTimestamps(const StoreEntry *); static void statAvgTick(void *notused); -static void statAvgDump(StoreEntry *, int minutes); +static void statAvgDump(StoreEntry *, int minutes, int hours); static void statCountersInit(StatCounters *); static void statCountersInitSpecial(StatCounters *); static void statCountersClean(StatCounters *); @@ -131,14 +131,55 @@ static OBJH statAvg60min; static void info_get_mallstat(int, int, StoreEntry *); #endif -/* - * An hour's worth, plus the 'current' counter - */ -#if 0 /* moved to defines.h to get from snmp_oidlist.c */ -#define N_COUNT_HIST 61 -#endif StatCounters CountHist[N_COUNT_HIST]; static int NCountHist = 0; +static StatCounters CountHourHist[N_COUNT_HOUR_HIST]; +static int NCountHourHist = 0; + +void +stat_utilization_get(StoreEntry * e) +{ + storeAppendPrintf(e, "Cache Utilisation:\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last 5 minutes:\n"); + if (NCountHist >= 5) + statAvgDump(e, 5, 0); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last 15 minutes:\n"); + if (NCountHist >= 15) + statAvgDump(e, 15, 0); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last hour:\n"); + if (NCountHist >= 60) + statAvgDump(e, 60, 0); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last 8 hours:\n"); + if (NCountHourHist >= 8) + statAvgDump(e, 0, 8); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last day:\n"); + if (NCountHourHist >= 24) + statAvgDump(e, 0, 24); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Last 3 days:\n"); + if (NCountHourHist >= 72) + statAvgDump(e, 0, 72); + else + storeAppendPrintf(e, "(no values recorded yet)\n"); + storeAppendPrintf(e, "\n"); + storeAppendPrintf(e, "Totals since cache startup:\n"); + statCountersDump(e); +} void stat_io_get(StoreEntry * sentry) @@ -570,7 +611,7 @@ info_get(StoreEntry * sentry) #define XAVG(X) (dt ? (double) (f->X - l->X) / dt : 0.0) static void -statAvgDump(StoreEntry * sentry, int minutes) +statAvgDump(StoreEntry * sentry, int minutes, int hours) { StatCounters *f; StatCounters *l; @@ -578,14 +619,36 @@ statAvgDump(StoreEntry * sentry, int minutes) double ct; double x; assert(N_COUNT_HIST > 1); - assert(minutes > 0); + assert(minutes > 0 || hours > 0); f = &CountHist[0]; - if (minutes > N_COUNT_HIST - 1) - minutes = N_COUNT_HIST - 1; - l = &CountHist[minutes]; + l = f; + if (minutes > 0 && hours == 0) { + /* checking minute readings ... */ + if (minutes > N_COUNT_HIST - 1) + minutes = N_COUNT_HIST - 1; + l = &CountHist[minutes]; + } else if (minutes == 0 && hours > 0) { + /* checking hour readings ... */ + if (hours > N_COUNT_HOUR_HIST - 1) + hours = N_COUNT_HOUR_HIST - 1; + l = &CountHourHist[hours]; + } else { + debug(18,1)("statAvgDump: Invalid args, minutes=%d, hours=%d\n", + minutes, hours); + return; + } dt = tvSubDsec(l->timestamp, f->timestamp); ct = f->cputime - l->cputime; + storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n", + f->timestamp.tv_sec, + f->timestamp.tv_usec, + mkrfc1123(f->timestamp.tv_sec)); + storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n", + l->timestamp.tv_sec, + l->timestamp.tv_usec, + mkrfc1123(l->timestamp.tv_sec)); + storeAppendPrintf(sentry, "client_http.requests = %f/sec\n", XAVG(client_http.requests)); storeAppendPrintf(sentry, "client_http.hits = %f/sec\n", @@ -614,14 +677,41 @@ statAvgDump(StoreEntry * sentry, int minutes) 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, "server.all.requests = %f/sec\n", + XAVG(server.all.requests)); + storeAppendPrintf(sentry, "server.all.errors = %f/sec\n", + XAVG(server.all.errors)); + storeAppendPrintf(sentry, "server.all.kbytes_in = %f/sec\n", + XAVG(server.all.kbytes_in.kb)); + storeAppendPrintf(sentry, "server.all.kbytes_out = %f/sec\n", + XAVG(server.all.kbytes_out.kb)); + + storeAppendPrintf(sentry, "server.http.requests = %f/sec\n", + XAVG(server.http.requests)); + storeAppendPrintf(sentry, "server.http.errors = %f/sec\n", + XAVG(server.http.errors)); + storeAppendPrintf(sentry, "server.http.kbytes_in = %f/sec\n", + XAVG(server.http.kbytes_in.kb)); + storeAppendPrintf(sentry, "server.http.kbytes_out = %f/sec\n", + XAVG(server.http.kbytes_out.kb)); + + storeAppendPrintf(sentry, "server.ftp.requests = %f/sec\n", + XAVG(server.ftp.requests)); + storeAppendPrintf(sentry, "server.ftp.errors = %f/sec\n", + XAVG(server.ftp.errors)); + storeAppendPrintf(sentry, "server.ftp.kbytes_in = %f/sec\n", + XAVG(server.ftp.kbytes_in.kb)); + storeAppendPrintf(sentry, "server.ftp.kbytes_out = %f/sec\n", + XAVG(server.ftp.kbytes_out.kb)); + + storeAppendPrintf(sentry, "server.other.requests = %f/sec\n", + XAVG(server.other.requests)); + storeAppendPrintf(sentry, "server.other.errors = %f/sec\n", + XAVG(server.other.errors)); + storeAppendPrintf(sentry, "server.other.kbytes_in = %f/sec\n", + XAVG(server.other.kbytes_in.kb)); + storeAppendPrintf(sentry, "server.other.kbytes_out = %f/sec\n", + XAVG(server.other.kbytes_out.kb)); storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n", XAVG(icp.pkts_sent)); @@ -656,13 +746,12 @@ statInit(void) { int i; debug(18, 5) ("statInit: Initializing...\n"); -#if 0 /* we do it in statCountersInit */ - memset(CountHist, '\0', N_COUNT_HIST * sizeof(StatCounters)); -#endif for (i = 0; i < N_COUNT_HIST; i++) statCountersInit(&CountHist[i]); + for (i = 0; i < N_COUNT_HOUR_HIST; i++) + statCountersInit(&CountHourHist[i]); statCountersInit(&Counter); - eventAdd("statAvgTick", statAvgTick, NULL, 60); + eventAdd("statAvgTick", statAvgTick, NULL, COUNT_INTERVAL); cachemgrRegister("info", "General Runtime Information", info_get, 0); @@ -696,7 +785,7 @@ statAvgTick(void *notused) StatCounters *p = &CountHist[1]; StatCounters *c = &Counter; struct rusage rusage; - eventAdd("statAvgTick", statAvgTick, NULL, 60); + eventAdd("statAvgTick", statAvgTick, NULL, COUNT_INTERVAL); squid_getrusage(&rusage); c->page_faults = rusage_pagefaults(&rusage); c->cputime = rusage_cputime(&rusage); @@ -704,11 +793,18 @@ statAvgTick(void *notused) /* even if NCountHist is small, we already Init()ed the tail */ statCountersClean(CountHist + N_COUNT_HIST - 1); xmemmove(p, t, (N_COUNT_HIST - 1) * sizeof(StatCounters)); -#if 0 - memcpy(t, c, sizeof(StatCounters)); -#endif statCountersCopy(t, c); NCountHist++; + + if ((NCountHist % COUNT_INTERVAL) == 0) { + /* we have an hours worth of readings. store previous hour */ + StatCounters *p = &CountHourHist[0]; + StatCounters *t = &CountHourHist[1]; + StatCounters *c = &CountHist[N_COUNT_HIST]; + xmemmove(p, t, (N_COUNT_HOUR_HIST - 1) * sizeof(StatCounters)); + memcpy(t, c, sizeof(StatCounters)); + NCountHourHist++; + } } static void @@ -717,7 +813,6 @@ statCountersInit(StatCounters * C) assert(C); memset(C, 0, sizeof(*C)); C->timestamp = current_time; - statCountersInitSpecial(C); } @@ -786,6 +881,10 @@ statCountersDump(StoreEntry * sentry) f->page_faults = rusage_pagefaults(&rusage); f->cputime = rusage_cputime(&rusage); + storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n", + f->timestamp.tv_sec, + f->timestamp.tv_usec, + mkrfc1123(f->timestamp.tv_sec)); storeAppendPrintf(sentry, "client_http.requests = %d\n", f->client_http.requests); storeAppendPrintf(sentry, "client_http.hits = %d\n", @@ -805,14 +904,41 @@ statCountersDump(StoreEntry * sentry) storeAppendPrintf(sentry, "client_http.hit_svc_time histogram:\n"); statHistDump(&f->client_http.hit_svc_time, sentry, NULL); - 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, "server.all.requests = %d\n", + (int) f->server.all.requests); + storeAppendPrintf(sentry, "server.all.errors = %d\n", + (int) f->server.all.errors); + storeAppendPrintf(sentry, "server.all.kbytes_in = %d\n", + (int) f->server.all.kbytes_in.kb); + storeAppendPrintf(sentry, "server.all.kbytes_out = %d\n", + (int) f->server.all.kbytes_out.kb); + + storeAppendPrintf(sentry, "server.http.requests = %d\n", + (int) f->server.http.requests); + storeAppendPrintf(sentry, "server.http.errors = %d\n", + (int) f->server.http.errors); + storeAppendPrintf(sentry, "server.http.kbytes_in = %d\n", + (int) f->server.http.kbytes_in.kb); + storeAppendPrintf(sentry, "server.http.kbytes_out = %d\n", + (int) f->server.http.kbytes_out.kb); + + storeAppendPrintf(sentry, "server.ftp.requests = %d\n", + (int) f->server.ftp.requests); + storeAppendPrintf(sentry, "server.ftp.errors = %d\n", + (int) f->server.ftp.errors); + storeAppendPrintf(sentry, "server.ftp.kbytes_in = %d\n", + (int) f->server.ftp.kbytes_in.kb); + storeAppendPrintf(sentry, "server.ftp.kbytes_out = %d\n", + (int) f->server.ftp.kbytes_out.kb); + + storeAppendPrintf(sentry, "server.other.requests = %d\n", + (int) f->server.other.requests); + storeAppendPrintf(sentry, "server.other.errors = %d\n", + (int) f->server.other.errors); + storeAppendPrintf(sentry, "server.other.kbytes_in = %d\n", + (int) f->server.other.kbytes_in.kb); + storeAppendPrintf(sentry, "server.other.kbytes_out = %d\n", + (int) f->server.other.kbytes_out.kb); storeAppendPrintf(sentry, "icp.pkts_sent = %d\n", f->icp.pkts_sent); @@ -850,13 +976,13 @@ statCounters(StoreEntry * e) void statAvg5min(StoreEntry * e) { - statAvgDump(e, 5); + statAvgDump(e, 5, 0); } void statAvg60min(StoreEntry * e) { - statAvgDump(e, 60); + statAvgDump(e, 60, 0); } diff --git a/src/structs.h b/src/structs.h index 65514c8434..16141dd4d6 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1044,10 +1044,12 @@ struct _StatCounters { StatHist all_svc_time; } client_http; struct { - int requests; - int errors; - kb_t kbytes_in; - kb_t kbytes_out; + struct { + int requests; + int errors; + kb_t kbytes_in; + kb_t kbytes_out; + } all,http,ftp,other; } server; struct { int pkts_sent; diff --git a/src/tunnel.cc b/src/tunnel.cc index f97a1ade12..4d3d0f76c4 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.74 1998/02/24 21:17:07 wessels Exp $ + * $Id: tunnel.cc,v 1.75 1998/03/04 23:52:42 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -117,7 +117,8 @@ sslReadServer(int fd, void *data) len = read(sslState->server.fd, sslState->server.buf, SQUID_TCP_SO_RCVBUF); if (len > 0) { fd_bytes(sslState->server.fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.other.kbytes_in, len); } debug(26, 5) ("sslReadServer FD %d, read %d bytes\n", fd, len); if (len < 0) { @@ -202,7 +203,8 @@ sslWriteServer(int fd, void *data) sslState->client.len - sslState->client.offset); if (len > 0) { fd_bytes(sslState->server.fd, len, FD_WRITE); - kb_incr(&Counter.server.kbytes_out, len); + kb_incr(&Counter.server.all.kbytes_out, len); + kb_incr(&Counter.server.other.kbytes_out, len); } debug(26, 5) ("sslWriteServer FD %d, wrote %d bytes\n", fd, len); if (len < 0) { @@ -364,6 +366,8 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr) ErrorState *err = NULL; debug(26, 3) ("sslStart: '%s %s'\n", RequestMethodStr[request->method], url); + Counter.server.all.requests++; + Counter.server.other.requests++; /* Create socket. */ sock = comm_open(SOCK_STREAM, 0, diff --git a/src/wais.cc b/src/wais.cc index abd0f28207..7218b81aa8 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.101 1998/02/24 21:17:09 wessels Exp $ + * $Id: wais.cc,v 1.102 1998/03/04 23:52:41 wessels Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -175,7 +175,8 @@ waisReadReply(int fd, void *data) len = read(fd, buf, 4096); if (len > 0) { fd_bytes(fd, len, FD_READ); - kb_incr(&Counter.server.kbytes_in, len); + kb_incr(&Counter.server.all.kbytes_in, len); + kb_incr(&Counter.server.other.kbytes_in, len); } debug(24, 5) ("waisReadReply: FD %d read len:%d\n", fd, len); if (len > 0) { @@ -234,7 +235,8 @@ waisSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data) fd, size, errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); - kb_incr(&Counter.server.kbytes_out, size); + kb_incr(&Counter.server.all.kbytes_out, size); + kb_incr(&Counter.server.other.kbytes_out, size); } if (errflag == COMM_ERR_CLOSING) return; @@ -290,6 +292,8 @@ waisStart(request_t * request, StoreEntry * entry) const char *url = storeUrl(entry); method_t method = request->method; debug(24, 3) ("waisStart: \"%s %s\"\n", RequestMethodStr[method], url); + Counter.server.all.requests++; + Counter.server.other.requests++; if (!Config.Wais.relayHost) { ErrorState *err; debug(24, 0) ("waisStart: Failed because no relay host defined!\n");