]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
forwarding statistics
authorwessels <>
Wed, 16 Dec 1998 13:04:15 +0000 (13:04 +0000)
committerwessels <>
Wed, 16 Dec 1998 13:04:15 +0000 (13:04 +0000)
src/forward.cc
src/main.cc
src/protos.h

index 32753ffe6889c69730ec6007e9082de48c401449..92532204e0bafaca58e799ada0c6e25e1d6f8059 100644 (file)
@@ -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");
+       }
+}
index 6d1cf089175191e989be9eabeb309d0e543c0ab3..26a5403c0c6693a35ecef554f03bd79710cfbb13 100644 (file)
@@ -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) {
index 1c612df2ded597b252473faf1fff78e12f06bf2a..945b7ab237fd9a2acbea97e9b3131ce247c1e9ca 100644 (file)
@@ -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);