From: wessels <> Date: Wed, 16 Dec 1998 13:04:15 +0000 (+0000) Subject: forwarding statistics X-Git-Tag: SQUID_3_0_PRE1~2455 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ddcc35dff76f783eb73d51a685850384117f457;p=thirdparty%2Fsquid.git forwarding statistics --- diff --git a/src/forward.cc b/src/forward.cc index 32753ffe68..92532204e0 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.37 1998/12/14 05:19:36 wessels Exp $ + * $Id: forward.cc,v 1.38 1998/12/16 06:04:15 wessels Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -46,6 +46,11 @@ static CNCB fwdConnectDone; static int fwdCheckRetry(FwdState * fwdState); static int fwdReforward(FwdState *); static void fwdStartFail(FwdState *); +static void fwdLogReplyStatus(int tries, http_status status); +static OBJH fwdStats; + +#define MAX_FWD_STATS_IDX 9 +static int FwdReplyCodes[MAX_FWD_STATS_IDX+1][HTTP_INVALID_HEADER+1]; static void fwdServerFree(FwdServer * fs) @@ -493,6 +498,7 @@ fwdComplete(FwdState * fwdState) storeUrl(e)); if (fwdState->server_fd > -1) fwdUnregister(fwdState->server_fd, fwdState); + fwdLogReplyStatus(fwdState->n_tries, e->mem_obj->reply->sline.status); storeEntryReset(e); fwdStartComplete(fwdState->servers, fwdState); } else { @@ -508,3 +514,37 @@ fwdComplete(FwdState * fwdState) fwdStateFree(fwdState); } } + +void +fwdInit(void) +{ + cachemgrRegister("forward", + "Request Forwarding Statistics", + fwdStats, 0, 1); +} + +static void +fwdLogReplyStatus(int tries, http_status status) +{ + if (status > HTTP_INVALID_HEADER) + return; + assert(tries); + tries--; + if (tries > MAX_FWD_STATS_IDX) + tries = MAX_FWD_STATS_IDX; + FwdReplyCodes[tries][status]++; +} + +static void +fwdStats(StoreEntry *s) +{ + int i; + int j; + for (i=0; i<=(int) HTTP_INVALID_HEADER; i++) { + storeAppendPrintf(s, "%3d", i); + for (j=0; j<=MAX_FWD_STATS_IDX; j++) { + storeAppendPrintf(s, "\t%d", FwdReplyCodes[j][i]); + } + storeAppendPrintf(s, "\n"); + } +} diff --git a/src/main.cc b/src/main.cc index 6d1cf08917..26a5403c0c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.281 1998/12/11 21:01:13 wessels Exp $ + * $Id: main.cc,v 1.282 1998/12/16 06:04:16 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -441,6 +441,7 @@ mainInitialize(void) #if DELAY_POOLS delayPoolsInit(); #endif + fwdInit(); } serverConnectionsOpen(); if (theOutIcpConnection >= 0) { diff --git a/src/protos.h b/src/protos.h index 1c612df2de..945b7ab237 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.296 1998/12/11 23:45:12 wessels Exp $ + * $Id: protos.h,v 1.297 1998/12/16 06:04:17 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -650,7 +650,7 @@ extern void fwdFail(FwdState *, int, http_status, int); extern STABH fwdAbort; extern void fwdUnregister(int fd, FwdState *); extern void fwdComplete(FwdState * fwdState); - +extern void fwdInit(void); extern void urnStart(request_t *, StoreEntry *); @@ -910,8 +910,6 @@ extern void storeSwapInFileOpened(void *data, int fd, int errcode); /* * store_swapout.c */ -extern void storeSwapOutStart(StoreEntry * e); -extern void storeSwapOutHandle(int fdnotused, int flag, size_t len, void *data); extern void storeCheckSwapOut(StoreEntry * e); extern void storeSwapOutFileClose(StoreEntry * e); extern int storeSwapOutWriteQueued(MemObject * mem);