From b8a46de08c1dc8875ae9cb27e840858ae8061cbb Mon Sep 17 00:00:00 2001 From: wessels <> Date: Mon, 26 Jun 2000 07:38:37 +0000 Subject: [PATCH] DW: - Make statAvgTick() print WARNINGS at debug level 0 if memory usage, response time, or page faults exceed admin-defined thresholds. --- src/cf.data.pre | 34 +++++++++++++++++++++++++++++++++- src/stat.cc | 27 ++++++++++++++++++++++++++- src/structs.h | 7 ++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/cf.data.pre b/src/cf.data.pre index 1a395f7261..3e1466900a 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.189 2000/06/25 22:41:21 wessels Exp $ +# $Id: cf.data.pre,v 1.190 2000/06/26 01:38:37 wessels Exp $ # # # SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -3194,5 +3194,37 @@ DOC_START You can add up to 20 additional "extension" methods here. DOC_END +NAME: high_response_time_warning +TYPE: int +COMMENT: (msec) +LOC: Config.warnings.high_rptm +DEFAULT: 0 +DOC_START + If the one-minute median response time exceeds this value, + Squid prints a WARNING with debug level 0 to get the + administrators attention. The value is in milliseconds. +DOC_END + +NAME: high_page_fault_warning +TYPE: int +LOC: Config.warnings.high_pf +DEFAULT: 0 +DOC_START + If the one-minute average page fault rate exceeds this + value, Squid prints a WARNING with debug level 0 to get + the administrators attention. The value is in page faults + per second. +DOC_END + +NAME: high_memory_warning +TYPE: b_size_t +LOC: Config.warnings.high_memory +DEFAULT: 0 +DOC_START + If the memory usage (as determined by mallinfo) exceeds + value, Squid prints a WARNING with debug level 0 to get + the administrators attention. +DOC_END + EOF diff --git a/src/stat.cc b/src/stat.cc index 7af228f63d..34ce9e0c99 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.328 2000/05/16 07:09:34 wessels Exp $ + * $Id: stat.cc,v 1.329 2000/06/26 01:38:37 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -903,6 +903,31 @@ statAvgTick(void *notused) statCountersCopy(t, c); NCountHourHist++; } + if (Config.warnings.high_rptm > 0) { + int i = (int) statMedianSvc(1, MEDIAN_HTTP); + if (Config.warnings.high_rptm < i) + debug(18, 0) ("WARNING: Median response time is %d milliseconds\n", i); + } + if (Config.warnings.high_pf) { + int i = (CountHist[0].page_faults - CountHist[1].page_faults); + double dt = tvSubDsec(CountHist[0].timestamp, CountHist[1].timestamp); + if (i > 0 && dt > 0.0) + i /= (int) dt; + if (Config.warnings.high_pf < i) + debug(18, 0) ("WARNING: Page faults occuring at %d/sec\n", i); + } + if (Config.warnings.high_memory) { + int i = 0; +#if HAVE_MSTATS && HAVE_GNUMALLOC_H + struct mstats ms = mstats(); + i = ms.bytes_total; +#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO + struct mallinfo mp = mallinfo(); + i = mp.arena; +#endif + if (Config.warnings.high_pf < i) + debug(18, 0) ("WARNING: Memory usage at %d MB\n", i >> 20); + } } static void diff --git a/src/structs.h b/src/structs.h index a401f96bed..09ee833f19 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.341 2000/06/25 22:41:22 wessels Exp $ + * $Id: structs.h,v 1.342 2000/06/26 01:38:38 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -499,6 +499,11 @@ struct _SquidConfig { } digest; #endif wordlist *ext_methods; + struct { + int high_rptm; + int high_pf; + int high_memory; + } warnings; }; struct _SquidConfig2 { -- 2.47.3