]>
Commit | Line | Data |
---|---|---|
30a4f2a8 | 1 | /* |
262a0e14 | 2 | * $Id$ |
30a4f2a8 | 3 | * |
4 | * DEBUG: section 18 Cache Manager Statistics | |
5 | * AUTHOR: Harvest Derived | |
6 | * | |
2b6662ba | 7 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
e25c139f | 8 | * ---------------------------------------------------------- |
30a4f2a8 | 9 | * |
2b6662ba | 10 | * Squid is the result of efforts by numerous individuals from |
11 | * the Internet community; see the CONTRIBUTORS file for full | |
12 | * details. Many organizations have provided support for Squid's | |
13 | * development; see the SPONSORS file for full details. Squid is | |
14 | * Copyrighted (C) 2001 by the Regents of the University of | |
15 | * California; see the COPYRIGHT file for full details. Squid | |
16 | * incorporates software developed and/or copyrighted by other | |
17 | * sources; see the CREDITS file for full details. | |
30a4f2a8 | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | |
20 | * it under the terms of the GNU General Public License as published by | |
21 | * the Free Software Foundation; either version 2 of the License, or | |
22 | * (at your option) any later version. | |
26ac0430 | 23 | * |
30a4f2a8 | 24 | * This program is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | * GNU General Public License for more details. | |
26ac0430 | 28 | * |
30a4f2a8 | 29 | * You should have received a copy of the GNU General Public License |
30 | * along with this program; if not, write to the Free Software | |
cbdec147 | 31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
e25c139f | 32 | * |
019dd986 | 33 | */ |
ed43818f | 34 | |
582c2af2 FC |
35 | #include "squid.h" |
36 | #include "client_side_request.h" | |
37 | #include "client_side.h" | |
38 | #include "comm/Connection.h" | |
65d448bc | 39 | #include "comm/Loops.h" |
a553a5a3 | 40 | #include "event.h" |
582c2af2 | 41 | #include "fde.h" |
31971e6a | 42 | #include "format/Token.h" |
582c2af2 | 43 | #include "globals.h" |
d3f603c8 | 44 | #include "HttpRequest.h" |
528b2c61 | 45 | #include "MemObject.h" |
528b2c61 | 46 | #include "mem_node.h" |
0eb49b6d | 47 | #include "MemBuf.h" |
8822ebee AR |
48 | #include "mgr/CountersAction.h" |
49 | #include "mgr/FunAction.h" | |
50 | #include "mgr/InfoAction.h" | |
51 | #include "mgr/IntervalAction.h" | |
52 | #include "mgr/IoAction.h" | |
582c2af2 | 53 | #include "mgr/Registration.h" |
8822ebee | 54 | #include "mgr/ServiceTimesAction.h" |
582c2af2 FC |
55 | #include "protos.h" |
56 | #include "SquidMath.h" | |
57 | #include "SquidTime.h" | |
58 | #include "StatCounters.h" | |
59 | #include "StoreClient.h" | |
60 | #include "Store.h" | |
61 | #if USE_AUTH | |
62 | #include "auth/UserRequest.h" | |
63 | #endif | |
64 | #if USE_DELAY_POOLS | |
65 | #include "DelayId.h" | |
66 | #endif | |
4db984be CT |
67 | #if USE_SSL |
68 | #include "ssl/support.h" | |
69 | #endif | |
528b2c61 | 70 | |
71 | /* these are included because they expose stats calls */ | |
72 | /* TODO: provide a self registration mechanism for those classes | |
73 | * to use during static construction | |
74 | */ | |
75 | #include "comm.h" | |
c8f4eac4 | 76 | #include "StoreSearch.h" |
090089c4 | 77 | |
ae94d28e | 78 | #define DEBUG_OPENFD 1 |
79 | ||
1da3b90b | 80 | typedef int STOBJFLT(const StoreEntry *); |
62e76326 | 81 | |
c8f4eac4 | 82 | class StatObjectsState |
62e76326 | 83 | { |
c8f4eac4 | 84 | |
85 | public: | |
1da3b90b | 86 | StoreEntry *sentry; |
1da3b90b | 87 | STOBJFLT *filter; |
c8f4eac4 | 88 | StoreSearchPointer theSearch; |
89 | ||
90 | private: | |
91 | CBDATA_CLASS2(StatObjectsState); | |
92 | }; | |
62e76326 | 93 | |
67508012 | 94 | /* LOCALS */ |
f5b8bbc4 | 95 | static const char *describeStatuses(const StoreEntry *); |
f5b8bbc4 | 96 | static const char *describeTimestamps(const StoreEntry *); |
f2908497 | 97 | static void statAvgTick(void *notused); |
a0f32775 | 98 | static void statAvgDump(StoreEntry *, int minutes, int hours); |
01aebf31 | 99 | #if STAT_GRAPHS |
100 | static void statGraphDump(StoreEntry *); | |
101 | #endif | |
12cf1be2 | 102 | static void statCountersInit(StatCounters *); |
1d803566 | 103 | static void statCountersInitSpecial(StatCounters *); |
12cf1be2 | 104 | static void statCountersClean(StatCounters *); |
2ac76861 | 105 | static void statCountersCopy(StatCounters * dest, const StatCounters * orig); |
04a28d46 | 106 | static double statPctileSvc(double, int, int); |
fcc35180 | 107 | static void statStoreEntry(MemBuf * mb, StoreEntry * e); |
49ad0a8c | 108 | static double statCPUUsage(int minutes); |
ed7f5615 | 109 | static OBJH stat_objects_get; |
110 | static OBJH stat_vmobjects_get; | |
ae94d28e | 111 | #if DEBUG_OPENFD |
112 | static OBJH statOpenfdObj; | |
113 | #endif | |
1da3b90b | 114 | static EVH statObjects; |
071a3ae7 | 115 | static OBJH statCountersDump; |
a1e927f6 | 116 | static OBJH statPeerSelect; |
26b164ac | 117 | static OBJH statDigestBlob; |
e9b5ead4 | 118 | static OBJH statUtilization; |
ba4f8e5a | 119 | static OBJH statCountersHistograms; |
0f1bc304 | 120 | static OBJH statClientRequests; |
8822ebee AR |
121 | void GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours); |
122 | void DumpAvgStat(Mgr::IntervalActionData& stats, StoreEntry* sentry); | |
123 | void GetInfo(Mgr::InfoActionData& stats); | |
124 | void DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry); | |
125 | void DumpMallocStatistics(StoreEntry* sentry); | |
126 | void GetCountersStats(Mgr::CountersActionData& stats); | |
127 | void DumpCountersStats(Mgr::CountersActionData& stats, StoreEntry* sentry); | |
128 | void GetServiceTimesStats(Mgr::ServiceTimesActionData& stats); | |
129 | void DumpServiceTimesStats(Mgr::ServiceTimesActionData& stats, StoreEntry* sentry); | |
130 | void GetIoStats(Mgr::IoActionData& stats); | |
131 | void DumpIoStats(Mgr::IoActionData& stats, StoreEntry* sentry); | |
20882fb1 | 132 | |
32d002cb | 133 | #if XMALLOC_STATISTICS |
58cd5bbd | 134 | static void info_get_mallstat(int, int, int, void *); |
135 | static double xm_time; | |
136 | static double xm_deltat; | |
20882fb1 | 137 | #endif |
30a4f2a8 | 138 | |
a9113eb0 | 139 | StatCounters CountHist[N_COUNT_HIST]; |
d5649d9f | 140 | static int NCountHist = 0; |
a0f32775 | 141 | static StatCounters CountHourHist[N_COUNT_HOUR_HIST]; |
142 | static int NCountHourHist = 0; | |
c8f4eac4 | 143 | CBDATA_CLASS_INIT(StatObjectsState); |
a0f32775 | 144 | |
d480bbc0 | 145 | extern unsigned int mem_pool_alloc_calls; |
146 | extern unsigned int mem_pool_free_calls; | |
147 | ||
5e29a294 | 148 | static void |
e9b5ead4 | 149 | statUtilization(StoreEntry * e) |
a0f32775 | 150 | { |
151 | storeAppendPrintf(e, "Cache Utilisation:\n"); | |
152 | storeAppendPrintf(e, "\n"); | |
153 | storeAppendPrintf(e, "Last 5 minutes:\n"); | |
62e76326 | 154 | |
a0f32775 | 155 | if (NCountHist >= 5) |
62e76326 | 156 | statAvgDump(e, 5, 0); |
a0f32775 | 157 | else |
62e76326 | 158 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
159 | ||
a0f32775 | 160 | storeAppendPrintf(e, "\n"); |
62e76326 | 161 | |
a0f32775 | 162 | storeAppendPrintf(e, "Last 15 minutes:\n"); |
62e76326 | 163 | |
a0f32775 | 164 | if (NCountHist >= 15) |
62e76326 | 165 | statAvgDump(e, 15, 0); |
a0f32775 | 166 | else |
62e76326 | 167 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
168 | ||
a0f32775 | 169 | storeAppendPrintf(e, "\n"); |
62e76326 | 170 | |
a0f32775 | 171 | storeAppendPrintf(e, "Last hour:\n"); |
62e76326 | 172 | |
a0f32775 | 173 | if (NCountHist >= 60) |
62e76326 | 174 | statAvgDump(e, 60, 0); |
a0f32775 | 175 | else |
62e76326 | 176 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
177 | ||
a0f32775 | 178 | storeAppendPrintf(e, "\n"); |
62e76326 | 179 | |
a0f32775 | 180 | storeAppendPrintf(e, "Last 8 hours:\n"); |
62e76326 | 181 | |
a0f32775 | 182 | if (NCountHourHist >= 8) |
62e76326 | 183 | statAvgDump(e, 0, 8); |
a0f32775 | 184 | else |
62e76326 | 185 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
186 | ||
a0f32775 | 187 | storeAppendPrintf(e, "\n"); |
62e76326 | 188 | |
a0f32775 | 189 | storeAppendPrintf(e, "Last day:\n"); |
62e76326 | 190 | |
a0f32775 | 191 | if (NCountHourHist >= 24) |
62e76326 | 192 | statAvgDump(e, 0, 24); |
a0f32775 | 193 | else |
62e76326 | 194 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
195 | ||
a0f32775 | 196 | storeAppendPrintf(e, "\n"); |
62e76326 | 197 | |
a0f32775 | 198 | storeAppendPrintf(e, "Last 3 days:\n"); |
62e76326 | 199 | |
a0f32775 | 200 | if (NCountHourHist >= 72) |
62e76326 | 201 | statAvgDump(e, 0, 72); |
a0f32775 | 202 | else |
62e76326 | 203 | storeAppendPrintf(e, "(no values recorded yet)\n"); |
204 | ||
a0f32775 | 205 | storeAppendPrintf(e, "\n"); |
62e76326 | 206 | |
a0f32775 | 207 | storeAppendPrintf(e, "Totals since cache startup:\n"); |
62e76326 | 208 | |
a0f32775 | 209 | statCountersDump(e); |
210 | } | |
f2908497 | 211 | |
8822ebee AR |
212 | void |
213 | GetIoStats(Mgr::IoActionData& stats) | |
214 | { | |
215 | int i; | |
216 | ||
217 | stats.http_reads = IOStats.Http.reads; | |
218 | ||
5db6bf73 | 219 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee AR |
220 | stats.http_read_hist[i] = IOStats.Http.read_hist[i]; |
221 | } | |
222 | ||
223 | stats.ftp_reads = IOStats.Ftp.reads; | |
224 | ||
5db6bf73 | 225 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee AR |
226 | stats.ftp_read_hist[i] = IOStats.Ftp.read_hist[i]; |
227 | } | |
228 | ||
229 | stats.gopher_reads = IOStats.Gopher.reads; | |
230 | ||
5db6bf73 | 231 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee AR |
232 | stats.gopher_read_hist[i] = IOStats.Gopher.read_hist[i]; |
233 | } | |
234 | } | |
235 | ||
236 | void | |
237 | DumpIoStats(Mgr::IoActionData& stats, StoreEntry* sentry) | |
30a4f2a8 | 238 | { |
239 | int i; | |
240 | ||
15576b6a | 241 | storeAppendPrintf(sentry, "HTTP I/O\n"); |
8822ebee | 242 | storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.http_reads); |
15576b6a | 243 | storeAppendPrintf(sentry, "Read Histogram:\n"); |
62e76326 | 244 | |
5db6bf73 | 245 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee | 246 | storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n", |
d9fc6862 A |
247 | i ? (1 << (i - 1)) + 1 : 1, |
248 | 1 << i, | |
249 | stats.http_read_hist[i], | |
250 | Math::doublePercent(stats.http_read_hist[i], stats.http_reads)); | |
30a4f2a8 | 251 | } |
252 | ||
15576b6a | 253 | storeAppendPrintf(sentry, "\n"); |
254 | storeAppendPrintf(sentry, "FTP I/O\n"); | |
8822ebee | 255 | storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.ftp_reads); |
15576b6a | 256 | storeAppendPrintf(sentry, "Read Histogram:\n"); |
62e76326 | 257 | |
5db6bf73 | 258 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee | 259 | storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n", |
d9fc6862 A |
260 | i ? (1 << (i - 1)) + 1 : 1, |
261 | 1 << i, | |
262 | stats.ftp_read_hist[i], | |
263 | Math::doublePercent(stats.ftp_read_hist[i], stats.ftp_reads)); | |
30a4f2a8 | 264 | } |
265 | ||
15576b6a | 266 | storeAppendPrintf(sentry, "\n"); |
267 | storeAppendPrintf(sentry, "Gopher I/O\n"); | |
8822ebee | 268 | storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.gopher_reads); |
15576b6a | 269 | storeAppendPrintf(sentry, "Read Histogram:\n"); |
62e76326 | 270 | |
5db6bf73 | 271 | for (i = 0; i < _iostats::histSize; ++i) { |
8822ebee | 272 | storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n", |
d9fc6862 A |
273 | i ? (1 << (i - 1)) + 1 : 1, |
274 | 1 << i, | |
275 | stats.gopher_read_hist[i], | |
276 | Math::doublePercent(stats.gopher_read_hist[i], stats.gopher_reads)); | |
56fa4cad | 277 | } |
278 | ||
15576b6a | 279 | storeAppendPrintf(sentry, "\n"); |
090089c4 | 280 | } |
281 | ||
0ee4272b | 282 | static const char * |
fe4e214f | 283 | describeStatuses(const StoreEntry * entry) |
d1a43e28 | 284 | { |
285 | LOCAL_ARRAY(char, buf, 256); | |
56878878 | 286 | snprintf(buf, 256, "%-13s %-13s %-12s %-12s", |
62e76326 | 287 | storeStatusStr[entry->store_status], |
288 | memStatusStr[entry->mem_status], | |
289 | swapStatusStr[entry->swap_status], | |
290 | pingStatusStr[entry->ping_status]); | |
d1a43e28 | 291 | return buf; |
292 | } | |
293 | ||
415e0dd2 | 294 | const char * |
295 | storeEntryFlags(const StoreEntry * entry) | |
d1a43e28 | 296 | { |
297 | LOCAL_ARRAY(char, buf, 256); | |
315005bd | 298 | int flags = (int) entry->flags; |
d1a43e28 | 299 | char *t; |
300 | buf[0] = '\0'; | |
62e76326 | 301 | |
7d94ae33 | 302 | if (EBIT_TEST(flags, ENTRY_SPECIAL)) |
62e76326 | 303 | strcat(buf, "SPECIAL,"); |
304 | ||
7d94ae33 | 305 | if (EBIT_TEST(flags, ENTRY_REVALIDATE)) |
62e76326 | 306 | strcat(buf, "REVALIDATE,"); |
307 | ||
7d94ae33 | 308 | if (EBIT_TEST(flags, DELAY_SENDING)) |
62e76326 | 309 | strcat(buf, "DELAY_SENDING,"); |
310 | ||
7d94ae33 | 311 | if (EBIT_TEST(flags, RELEASE_REQUEST)) |
62e76326 | 312 | strcat(buf, "RELEASE_REQUEST,"); |
313 | ||
7d94ae33 | 314 | if (EBIT_TEST(flags, REFRESH_REQUEST)) |
62e76326 | 315 | strcat(buf, "REFRESH_REQUEST,"); |
316 | ||
7d94ae33 | 317 | if (EBIT_TEST(flags, ENTRY_CACHABLE)) |
62e76326 | 318 | strcat(buf, "CACHABLE,"); |
319 | ||
7d94ae33 | 320 | if (EBIT_TEST(flags, ENTRY_DISPATCHED)) |
62e76326 | 321 | strcat(buf, "DISPATCHED,"); |
322 | ||
7d94ae33 | 323 | if (EBIT_TEST(flags, KEY_PRIVATE)) |
62e76326 | 324 | strcat(buf, "PRIVATE,"); |
325 | ||
05b0ef8a | 326 | if (EBIT_TEST(flags, ENTRY_FWD_HDR_WAIT)) |
62e76326 | 327 | strcat(buf, "FWD_HDR_WAIT,"); |
328 | ||
7d94ae33 | 329 | if (EBIT_TEST(flags, ENTRY_NEGCACHED)) |
62e76326 | 330 | strcat(buf, "NEGCACHED,"); |
331 | ||
7d94ae33 | 332 | if (EBIT_TEST(flags, ENTRY_VALIDATED)) |
62e76326 | 333 | strcat(buf, "VALIDATED,"); |
334 | ||
7d94ae33 | 335 | if (EBIT_TEST(flags, ENTRY_BAD_LENGTH)) |
62e76326 | 336 | strcat(buf, "BAD_LENGTH,"); |
337 | ||
d2e002d1 | 338 | if (EBIT_TEST(flags, ENTRY_ABORTED)) |
62e76326 | 339 | strcat(buf, "ABORTED,"); |
340 | ||
d1a43e28 | 341 | if ((t = strrchr(buf, ','))) |
62e76326 | 342 | *t = '\0'; |
343 | ||
d1a43e28 | 344 | return buf; |
345 | } | |
346 | ||
0ee4272b | 347 | static const char * |
fe4e214f | 348 | describeTimestamps(const StoreEntry * entry) |
d1a43e28 | 349 | { |
350 | LOCAL_ARRAY(char, buf, 256); | |
56878878 | 351 | snprintf(buf, 256, "LV:%-9d LU:%-9d LM:%-9d EX:%-9d", |
62e76326 | 352 | (int) entry->timestamp, |
353 | (int) entry->lastref, | |
354 | (int) entry->lastmod, | |
355 | (int) entry->expires); | |
d1a43e28 | 356 | return buf; |
357 | } | |
358 | ||
b8d8561b | 359 | static void |
fcc35180 | 360 | statStoreEntry(MemBuf * mb, StoreEntry * e) |
090089c4 | 361 | { |
a5a5de87 | 362 | MemObject *mem = e->mem_obj; |
2fe7eff9 | 363 | mb->Printf("KEY %s\n", e->getMD5Text()); |
364 | mb->Printf("\t%s\n", describeStatuses(e)); | |
365 | mb->Printf("\t%s\n", storeEntryFlags(e)); | |
366 | mb->Printf("\t%s\n", describeTimestamps(e)); | |
367 | mb->Printf("\t%d locks, %d clients, %d refs\n", | |
368 | (int) e->lock_count, | |
369 | storePendingNClients(e), | |
370 | (int) e->refcount); | |
371 | mb->Printf("\tSwap Dir %d, File %#08X\n", | |
372 | e->swap_dirn, e->swap_filen); | |
62e76326 | 373 | |
528b2c61 | 374 | if (mem != NULL) |
fcc35180 | 375 | mem->stat (mb); |
62e76326 | 376 | |
2fe7eff9 | 377 | mb->Printf("\n"); |
a5a5de87 | 378 | } |
379 | ||
380 | /* process objects list */ | |
381 | static void | |
1da3b90b | 382 | statObjects(void *data) |
a5a5de87 | 383 | { |
e6ccf245 | 384 | StatObjectsState *state = static_cast<StatObjectsState *>(data); |
1da3b90b | 385 | StoreEntry *e; |
62e76326 | 386 | |
c8f4eac4 | 387 | if (state->theSearch->isDone()) { |
8822ebee AR |
388 | if (UsingSmp()) |
389 | storeAppendPrintf(state->sentry, "} by kid%d\n\n", KidIdentifier); | |
62e76326 | 390 | state->sentry->complete(); |
97b5e68f | 391 | state->sentry->unlock(); |
62e76326 | 392 | cbdataFree(state); |
393 | return; | |
b7fe0ab0 | 394 | } else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) { |
97b5e68f | 395 | state->sentry->unlock(); |
62e76326 | 396 | cbdataFree(state); |
397 | return; | |
a46d2c0e | 398 | } else if (state->sentry->checkDeferRead(-1)) { |
3f783384 | 399 | state->sentry->flush(); |
62e76326 | 400 | eventAdd("statObjects", statObjects, state, 0.1, 1); |
401 | return; | |
1da3b90b | 402 | } |
62e76326 | 403 | |
3900307b | 404 | state->sentry->buffer(); |
c8f4eac4 | 405 | size_t statCount = 0; |
406 | MemBuf mb; | |
2fe7eff9 | 407 | mb.init(); |
62e76326 | 408 | |
c8f4eac4 | 409 | while (statCount++ < static_cast<size_t>(Config.Store.objectsPerBucket) && state-> |
410 | theSearch->next()) { | |
411 | e = state->theSearch->currentItem(); | |
62e76326 | 412 | |
c8f4eac4 | 413 | if (state->filter && 0 == state->filter(e)) |
414 | continue; | |
62e76326 | 415 | |
c8f4eac4 | 416 | statStoreEntry(&mb, e); |
417 | } | |
fcc35180 | 418 | |
c8f4eac4 | 419 | if (mb.size) |
3900307b | 420 | state->sentry->append(mb.buf, mb.size); |
2fe7eff9 | 421 | mb.clean(); |
62e76326 | 422 | |
1da3b90b | 423 | eventAdd("statObjects", statObjects, state, 0.0, 1); |
a5a5de87 | 424 | } |
425 | ||
5e29a294 | 426 | static void |
1da3b90b | 427 | statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) |
428 | { | |
c8f4eac4 | 429 | StatObjectsState *state = new StatObjectsState; |
1da3b90b | 430 | state->sentry = sentry; |
431 | state->filter = filter; | |
34266cde | 432 | |
3d0ac046 | 433 | sentry->lock(); |
c8f4eac4 | 434 | state->theSearch = Store::Root().search(NULL, NULL); |
34266cde | 435 | |
1da3b90b | 436 | eventAdd("statObjects", statObjects, state, 0.0, 1); |
437 | } | |
438 | ||
439 | static void | |
440 | stat_objects_get(StoreEntry * sentry) | |
441 | { | |
442 | statObjectsStart(sentry, NULL); | |
443 | } | |
444 | ||
445 | static int | |
446 | statObjectsVmFilter(const StoreEntry * e) | |
090089c4 | 447 | { |
1da3b90b | 448 | return e->mem_obj ? 1 : 0; |
6684fec0 | 449 | } |
090089c4 | 450 | |
5e29a294 | 451 | static void |
1da3b90b | 452 | stat_vmobjects_get(StoreEntry * sentry) |
6684fec0 | 453 | { |
1da3b90b | 454 | statObjectsStart(sentry, statObjectsVmFilter); |
090089c4 | 455 | } |
456 | ||
ae94d28e | 457 | #if DEBUG_OPENFD |
1da3b90b | 458 | static int |
459 | statObjectsOpenfdFilter(const StoreEntry * e) | |
460 | { | |
461 | if (e->mem_obj == NULL) | |
62e76326 | 462 | return 0; |
463 | ||
2391a162 | 464 | if (e->mem_obj->swapout.sio == NULL) |
62e76326 | 465 | return 0; |
466 | ||
1da3b90b | 467 | return 1; |
468 | } | |
469 | ||
ae94d28e | 470 | static void |
471 | statOpenfdObj(StoreEntry * sentry) | |
472 | { | |
1da3b90b | 473 | statObjectsStart(sentry, statObjectsOpenfdFilter); |
ae94d28e | 474 | } |
1da3b90b | 475 | |
ae94d28e | 476 | #endif |
477 | ||
32d002cb | 478 | #if XMALLOC_STATISTICS |
b8d8561b | 479 | static void |
58cd5bbd | 480 | info_get_mallstat(int size, int number, int oldnum, void *data) |
30a4f2a8 | 481 | { |
18f2f920 | 482 | StoreEntry *sentry = (StoreEntry *)data; |
62e76326 | 483 | |
77b88b59 | 484 | // format: "%12s %15s %6s %12s\n","Alloc Size","Count","Delta","Alloc/sec" |
30a4f2a8 | 485 | if (number > 0) |
77b88b59 | 486 | storeAppendPrintf(sentry, "%12d %15d %6d %.1f\n", size, number, number - oldnum, xdiv((number - oldnum), xm_deltat)); |
30a4f2a8 | 487 | } |
62e76326 | 488 | |
30a4f2a8 | 489 | #endif |
090089c4 | 490 | |
8822ebee AR |
491 | void |
492 | GetInfo(Mgr::InfoActionData& stats) | |
090089c4 | 493 | { |
62e76326 | 494 | |
090089c4 | 495 | struct rusage rusage; |
f2908497 | 496 | double cputime; |
497 | double runtime; | |
88738790 | 498 | #if HAVE_MSTATS && HAVE_GNUMALLOC_H |
62e76326 | 499 | |
88738790 | 500 | struct mstats ms; |
eb824054 | 501 | #elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO |
62e76326 | 502 | |
090089c4 | 503 | struct mallinfo mp; |
504 | #endif | |
505 | ||
f2908497 | 506 | runtime = tvSubDsec(squid_start, current_time); |
62e76326 | 507 | |
f2908497 | 508 | if (runtime == 0.0) |
62e76326 | 509 | runtime = 1.0; |
510 | ||
8822ebee AR |
511 | stats.squid_start = squid_start; |
512 | ||
513 | stats.current_time = current_time; | |
514 | ||
515 | stats.client_http_clients = statCounter.client_http.clients; | |
516 | ||
517 | stats.client_http_requests = statCounter.client_http.requests; | |
518 | ||
519 | stats.icp_pkts_recv = statCounter.icp.pkts_recv; | |
520 | ||
521 | stats.icp_pkts_sent = statCounter.icp.pkts_sent; | |
522 | ||
523 | stats.icp_replies_queued = statCounter.icp.replies_queued; | |
524 | ||
525 | #if USE_HTCP | |
526 | ||
527 | stats.htcp_pkts_recv = statCounter.htcp.pkts_recv; | |
528 | ||
529 | stats.htcp_pkts_sent = statCounter.htcp.pkts_sent; | |
530 | ||
531 | #endif | |
532 | ||
533 | stats.request_failure_ratio = request_failure_ratio; | |
534 | ||
535 | stats.avg_client_http_requests = statCounter.client_http.requests / (runtime / 60.0); | |
536 | ||
537 | stats.avg_icp_messages = (statCounter.icp.pkts_sent + statCounter.icp.pkts_recv) / (runtime / 60.0); | |
538 | ||
539 | stats.select_loops = statCounter.select_loops; | |
540 | stats.avg_loop_time = 1000.0 * runtime / statCounter.select_loops; | |
541 | ||
542 | stats.request_hit_ratio5 = statRequestHitRatio(5); | |
543 | stats.request_hit_ratio60 = statRequestHitRatio(60); | |
544 | ||
545 | stats.byte_hit_ratio5 = statByteHitRatio(5); | |
546 | stats.byte_hit_ratio60 = statByteHitRatio(60); | |
547 | ||
548 | stats.request_hit_mem_ratio5 = statRequestHitMemoryRatio(5); | |
549 | stats.request_hit_mem_ratio60 = statRequestHitMemoryRatio(60); | |
550 | ||
551 | stats.request_hit_disk_ratio5 = statRequestHitDiskRatio(5); | |
552 | stats.request_hit_disk_ratio60 = statRequestHitDiskRatio(60); | |
553 | ||
93bc1434 | 554 | Store::Root().getStats(stats.store); |
8822ebee AR |
555 | |
556 | stats.unlink_requests = statCounter.unlink.requests; | |
557 | ||
558 | stats.http_requests5 = statPctileSvc(0.5, 5, PCTILE_HTTP); | |
559 | stats.http_requests60 = statPctileSvc(0.5, 60, PCTILE_HTTP); | |
560 | ||
561 | stats.cache_misses5 = statPctileSvc(0.5, 5, PCTILE_MISS); | |
562 | stats.cache_misses60 = statPctileSvc(0.5, 60, PCTILE_MISS); | |
563 | ||
564 | stats.cache_hits5 = statPctileSvc(0.5, 5, PCTILE_HIT); | |
565 | stats.cache_hits60 = statPctileSvc(0.5, 60, PCTILE_HIT); | |
566 | ||
567 | stats.near_hits5 = statPctileSvc(0.5, 5, PCTILE_NH); | |
568 | stats.near_hits60 = statPctileSvc(0.5, 60, PCTILE_NH); | |
569 | ||
570 | stats.not_modified_replies5 = statPctileSvc(0.5, 5, PCTILE_NM); | |
571 | stats.not_modified_replies60 = statPctileSvc(0.5, 60, PCTILE_NM); | |
572 | ||
573 | stats.dns_lookups5 = statPctileSvc(0.5, 5, PCTILE_DNS); | |
574 | stats.dns_lookups60 = statPctileSvc(0.5, 60, PCTILE_DNS); | |
575 | ||
576 | stats.icp_queries5 = statPctileSvc(0.5, 5, PCTILE_ICP_QUERY); | |
577 | stats.icp_queries60 = statPctileSvc(0.5, 60, PCTILE_ICP_QUERY); | |
578 | ||
579 | squid_getrusage(&rusage); | |
580 | cputime = rusage_cputime(&rusage); | |
581 | ||
582 | stats.up_time = runtime; | |
583 | stats.cpu_time = cputime; | |
584 | stats.cpu_usage = Math::doublePercent(cputime, runtime); | |
585 | stats.cpu_usage5 = statCPUUsage(5); | |
586 | stats.cpu_usage60 = statCPUUsage(60); | |
587 | ||
588 | #if HAVE_SBRK | |
589 | ||
590 | stats.proc_data_seg = ((char *) sbrk(0) - (char *) sbrk_start); | |
591 | ||
592 | #endif | |
593 | ||
594 | stats.maxrss = rusage_maxrss(&rusage); | |
595 | ||
596 | stats.page_faults = rusage_pagefaults(&rusage); | |
597 | ||
598 | #if HAVE_MSTATS && HAVE_GNUMALLOC_H | |
599 | ||
600 | ms = mstats(); | |
601 | ||
602 | stats.ms_bytes_total = ms.bytes_total; | |
603 | ||
604 | stats.ms_bytes_free = ms.bytes_free; | |
605 | ||
606 | #elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO | |
607 | ||
608 | mp = mallinfo(); | |
609 | ||
610 | stats.mp_arena = mp.arena; | |
611 | ||
612 | stats.mp_uordblks = mp.uordblks; | |
613 | stats.mp_ordblks = mp.ordblks; | |
614 | ||
615 | stats.mp_usmblks = mp.usmblks; | |
616 | stats.mp_smblks = mp.smblks; | |
617 | ||
618 | stats.mp_hblkhd = mp.hblkhd; | |
619 | stats.mp_hblks = mp.hblks; | |
620 | ||
621 | stats.mp_fsmblks = mp.fsmblks; | |
622 | ||
623 | stats.mp_fordblks = mp.fordblks; | |
624 | ||
625 | #if HAVE_STRUCT_MALLINFO_MXFAST | |
626 | ||
627 | stats.mp_mxfast = mp.mxfast; | |
628 | ||
629 | stats.mp_nlblks = mp.nlblks; | |
630 | ||
631 | stats.mp_grain = mp.grain; | |
632 | ||
633 | stats.mp_uordbytes = mp.uordbytes; | |
634 | ||
635 | stats.mp_allocated = mp.allocated; | |
636 | ||
637 | stats.mp_treeoverhead = mp.treeoverhead; | |
638 | ||
639 | #endif /* HAVE_STRUCT_MALLINFO_MXFAST */ | |
640 | #endif /* HAVE_MALLINFO */ | |
641 | ||
642 | stats.total_accounted = statMemoryAccounted(); | |
643 | ||
644 | { | |
645 | MemPoolGlobalStats mp_stats; | |
646 | memPoolGetGlobalStats(&mp_stats); | |
647 | #if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO | |
648 | ||
649 | stats.mem_pool_allocated = mp_stats.TheMeter->alloc.level; | |
650 | #endif | |
651 | ||
83ddbaf4 | 652 | stats.gb_saved_count = mp_stats.TheMeter->gb_saved.count; |
8822ebee AR |
653 | stats.gb_freed_count = mp_stats.TheMeter->gb_freed.count; |
654 | } | |
655 | ||
656 | stats.max_fd = Squid_MaxFD; | |
657 | stats.biggest_fd = Biggest_FD; | |
658 | stats.number_fd = Number_FD; | |
659 | stats.opening_fd = Opening_FD; | |
660 | stats.num_fd_free = fdNFree(); | |
661 | stats.reserved_fd = RESERVED_FD; | |
8822ebee AR |
662 | } |
663 | ||
664 | void | |
665 | DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry) | |
666 | { | |
15576b6a | 667 | storeAppendPrintf(sentry, "Squid Object Cache: Version %s\n", |
62e76326 | 668 | version_string); |
669 | ||
be266cb2 | 670 | #if _SQUID_WINDOWS_ |
1a774556 | 671 | if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { |
672 | storeAppendPrintf(sentry,"\nRunning as %s Windows System Service on %s\n", | |
673 | WIN32_Service_name, WIN32_OS_string); | |
674 | storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line); | |
675 | } else | |
676 | storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string); | |
1a774556 | 677 | #endif |
678 | ||
15576b6a | 679 | storeAppendPrintf(sentry, "Start Time:\t%s\n", |
8822ebee | 680 | mkrfc1123(stats.squid_start.tv_sec)); |
62e76326 | 681 | |
15576b6a | 682 | storeAppendPrintf(sentry, "Current Time:\t%s\n", |
8822ebee | 683 | mkrfc1123(stats.current_time.tv_sec)); |
62e76326 | 684 | |
7dbca7a4 | 685 | storeAppendPrintf(sentry, "Connection information for %s:\n",APP_SHORTNAME); |
62e76326 | 686 | |
8822ebee AR |
687 | storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%.0f\n", |
688 | stats.client_http_clients); | |
62e76326 | 689 | |
8822ebee AR |
690 | storeAppendPrintf(sentry, "\tNumber of HTTP requests received:\t%.0f\n", |
691 | stats.client_http_requests); | |
62e76326 | 692 | |
8822ebee AR |
693 | storeAppendPrintf(sentry, "\tNumber of ICP messages received:\t%.0f\n", |
694 | stats.icp_pkts_recv); | |
62e76326 | 695 | |
8822ebee AR |
696 | storeAppendPrintf(sentry, "\tNumber of ICP messages sent:\t%.0f\n", |
697 | stats.icp_pkts_sent); | |
62e76326 | 698 | |
8822ebee AR |
699 | storeAppendPrintf(sentry, "\tNumber of queued ICP replies:\t%.0f\n", |
700 | stats.icp_replies_queued); | |
62e76326 | 701 | |
c4ebc830 | 702 | #if USE_HTCP |
703 | ||
8822ebee AR |
704 | storeAppendPrintf(sentry, "\tNumber of HTCP messages received:\t%.0f\n", |
705 | stats.htcp_pkts_recv); | |
c4ebc830 | 706 | |
8822ebee AR |
707 | storeAppendPrintf(sentry, "\tNumber of HTCP messages sent:\t%.0f\n", |
708 | stats.htcp_pkts_sent); | |
c4ebc830 | 709 | |
710 | #endif | |
711 | ||
8822ebee | 712 | double fct = stats.count > 1 ? stats.count : 1.0; |
a4ba1105 | 713 | storeAppendPrintf(sentry, "\tRequest failure ratio:\t%5.2f\n", |
8822ebee | 714 | stats.request_failure_ratio / fct); |
f2908497 | 715 | |
b51b0e13 | 716 | storeAppendPrintf(sentry, "\tAverage HTTP requests per minute since start:\t%.1f\n", |
61564333 | 717 | stats.avg_client_http_requests); |
62e76326 | 718 | |
b51b0e13 | 719 | storeAppendPrintf(sentry, "\tAverage ICP messages per minute since start:\t%.1f\n", |
61564333 | 720 | stats.avg_icp_messages); |
62e76326 | 721 | |
8822ebee AR |
722 | storeAppendPrintf(sentry, "\tSelect loop called: %.0f times, %0.3f ms avg\n", |
723 | stats.select_loops, stats.avg_loop_time / fct); | |
090089c4 | 724 | |
7dbca7a4 | 725 | storeAppendPrintf(sentry, "Cache information for %s:\n",APP_SHORTNAME); |
62e76326 | 726 | |
5bf79e53 | 727 | storeAppendPrintf(sentry, "\tHits as %% of all requests:\t5min: %3.1f%%, 60min: %3.1f%%\n", |
8822ebee AR |
728 | stats.request_hit_ratio5 / fct, |
729 | stats.request_hit_ratio60 / fct); | |
62e76326 | 730 | |
5bf79e53 | 731 | storeAppendPrintf(sentry, "\tHits as %% of bytes sent:\t5min: %3.1f%%, 60min: %3.1f%%\n", |
8822ebee AR |
732 | stats.byte_hit_ratio5 / fct, |
733 | stats.byte_hit_ratio60 / fct); | |
62e76326 | 734 | |
5bf79e53 | 735 | storeAppendPrintf(sentry, "\tMemory hits as %% of hit requests:\t5min: %3.1f%%, 60min: %3.1f%%\n", |
8822ebee AR |
736 | stats.request_hit_mem_ratio5 / fct, |
737 | stats.request_hit_mem_ratio60 / fct); | |
62e76326 | 738 | |
5bf79e53 | 739 | storeAppendPrintf(sentry, "\tDisk hits as %% of hit requests:\t5min: %3.1f%%, 60min: %3.1f%%\n", |
8822ebee AR |
740 | stats.request_hit_disk_ratio5 / fct, |
741 | stats.request_hit_disk_ratio60 / fct); | |
62e76326 | 742 | |
8822ebee | 743 | storeAppendPrintf(sentry, "\tStorage Swap size:\t%.0f KB\n", |
93bc1434 | 744 | stats.store.swap.size / 1024); |
62e76326 | 745 | |
6a52823b | 746 | storeAppendPrintf(sentry, "\tStorage Swap capacity:\t%4.1f%% used, %4.1f%% free\n", |
93bc1434 AR |
747 | Math::doublePercent(stats.store.swap.size, stats.store.swap.capacity), |
748 | Math::doublePercent(stats.store.swap.available(), stats.store.swap.capacity)); | |
6a52823b | 749 | |
8822ebee | 750 | storeAppendPrintf(sentry, "\tStorage Mem size:\t%.0f KB\n", |
93bc1434 | 751 | stats.store.mem.size / 1024); |
62e76326 | 752 | |
6a52823b | 753 | storeAppendPrintf(sentry, "\tStorage Mem capacity:\t%4.1f%% used, %4.1f%% free\n", |
93bc1434 AR |
754 | Math::doublePercent(stats.store.mem.size, stats.store.mem.capacity), |
755 | Math::doublePercent(stats.store.mem.available(), stats.store.mem.capacity)); | |
6a52823b | 756 | |
0faf70d0 | 757 | storeAppendPrintf(sentry, "\tMean Object Size:\t%0.2f KB\n", |
93bc1434 | 758 | stats.store.swap.meanObjectSize() / 1024); |
62e76326 | 759 | |
8822ebee AR |
760 | storeAppendPrintf(sentry, "\tRequests given to unlinkd:\t%.0f\n", |
761 | stats.unlink_requests); | |
090089c4 | 762 | |
b87b92fb | 763 | storeAppendPrintf(sentry, "Median Service Times (seconds) 5 min 60 min:\n"); |
62e76326 | 764 | |
8822ebee | 765 | fct = stats.count > 1 ? stats.count * 1000.0 : 1000.0; |
b87b92fb | 766 | storeAppendPrintf(sentry, "\tHTTP Requests (All): %8.5f %8.5f\n", |
8822ebee AR |
767 | stats.http_requests5 / fct, |
768 | stats.http_requests60 / fct); | |
62e76326 | 769 | |
b87b92fb | 770 | storeAppendPrintf(sentry, "\tCache Misses: %8.5f %8.5f\n", |
8822ebee AR |
771 | stats.cache_misses5 / fct, |
772 | stats.cache_misses60 / fct); | |
62e76326 | 773 | |
b87b92fb | 774 | storeAppendPrintf(sentry, "\tCache Hits: %8.5f %8.5f\n", |
8822ebee AR |
775 | stats.cache_hits5 / fct, |
776 | stats.cache_hits60 / fct); | |
62e76326 | 777 | |
7c9c84ad | 778 | storeAppendPrintf(sentry, "\tNear Hits: %8.5f %8.5f\n", |
8822ebee AR |
779 | stats.near_hits5 / fct, |
780 | stats.near_hits60 / fct); | |
62e76326 | 781 | |
b87b92fb | 782 | storeAppendPrintf(sentry, "\tNot-Modified Replies: %8.5f %8.5f\n", |
8822ebee AR |
783 | stats.not_modified_replies5 / fct, |
784 | stats.not_modified_replies60 / fct); | |
62e76326 | 785 | |
b87b92fb | 786 | storeAppendPrintf(sentry, "\tDNS Lookups: %8.5f %8.5f\n", |
8822ebee AR |
787 | stats.dns_lookups5 / fct, |
788 | stats.dns_lookups60 / fct); | |
62e76326 | 789 | |
8822ebee | 790 | fct = stats.count > 1 ? stats.count * 1000000.0 : 1000000.0; |
b87b92fb | 791 | storeAppendPrintf(sentry, "\tICP Queries: %8.5f %8.5f\n", |
8822ebee AR |
792 | stats.icp_queries5 / fct, |
793 | stats.icp_queries60 / fct); | |
62e76326 | 794 | |
7dbca7a4 | 795 | storeAppendPrintf(sentry, "Resource usage for %s:\n", APP_SHORTNAME); |
62e76326 | 796 | |
8822ebee | 797 | storeAppendPrintf(sentry, "\tUP Time:\t%.3f seconds\n", stats.up_time); |
62e76326 | 798 | |
8822ebee | 799 | storeAppendPrintf(sentry, "\tCPU Time:\t%.3f seconds\n", stats.cpu_time); |
62e76326 | 800 | |
15576b6a | 801 | storeAppendPrintf(sentry, "\tCPU Usage:\t%.2f%%\n", |
8822ebee | 802 | stats.cpu_usage); |
62e76326 | 803 | |
979533fa | 804 | storeAppendPrintf(sentry, "\tCPU Usage, 5 minute avg:\t%.2f%%\n", |
8822ebee | 805 | stats.cpu_usage5); |
62e76326 | 806 | |
49ad0a8c | 807 | storeAppendPrintf(sentry, "\tCPU Usage, 60 minute avg:\t%.2f%%\n", |
8822ebee | 808 | stats.cpu_usage60); |
62e76326 | 809 | |
a4ba1105 | 810 | #if HAVE_SBRK |
62e76326 | 811 | |
8822ebee AR |
812 | storeAppendPrintf(sentry, "\tProcess Data Segment Size via sbrk(): %.0f KB\n", |
813 | stats.proc_data_seg / 1024); | |
62e76326 | 814 | |
a4ba1105 | 815 | #endif |
62e76326 | 816 | |
8822ebee AR |
817 | storeAppendPrintf(sentry, "\tMaximum Resident Size: %.0f KB\n", |
818 | stats.maxrss); | |
62e76326 | 819 | |
8822ebee AR |
820 | storeAppendPrintf(sentry, "\tPage faults with physical i/o: %.0f\n", |
821 | stats.page_faults); | |
090089c4 | 822 | |
88738790 | 823 | #if HAVE_MSTATS && HAVE_GNUMALLOC_H |
62e76326 | 824 | |
7dbca7a4 | 825 | storeAppendPrintf(sentry, "Memory usage for %s via mstats():\n",APP_SHORTNAME); |
62e76326 | 826 | |
8822ebee AR |
827 | storeAppendPrintf(sentry, "\tTotal space in arena: %6.0f KB\n", |
828 | stats.ms_bytes_total / 1024); | |
62e76326 | 829 | |
8822ebee AR |
830 | storeAppendPrintf(sentry, "\tTotal free: %6.0f KB %.0f%%\n", |
831 | stats.ms_bytes_free / 1024, | |
832 | Math::doublePercent(stats.ms_bytes_free, stats.ms_bytes_total)); | |
62e76326 | 833 | |
eb824054 | 834 | #elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO |
62e76326 | 835 | |
7dbca7a4 | 836 | storeAppendPrintf(sentry, "Memory usage for %s via mallinfo():\n",APP_SHORTNAME); |
62e76326 | 837 | |
8822ebee AR |
838 | storeAppendPrintf(sentry, "\tTotal space in arena: %6.0f KB\n", |
839 | stats.mp_arena / 1024); | |
62e76326 | 840 | |
8822ebee AR |
841 | storeAppendPrintf(sentry, "\tOrdinary blocks: %6.0f KB %6.0f blks\n", |
842 | stats.mp_uordblks / 1024, stats.mp_ordblks); | |
62e76326 | 843 | |
8822ebee AR |
844 | storeAppendPrintf(sentry, "\tSmall blocks: %6.0f KB %6.0f blks\n", |
845 | stats.mp_usmblks / 1024, stats.mp_smblks); | |
62e76326 | 846 | |
8822ebee AR |
847 | storeAppendPrintf(sentry, "\tHolding blocks: %6.0f KB %6.0f blks\n", |
848 | stats.mp_hblkhd / 1024, stats.mp_hblks); | |
62e76326 | 849 | |
8822ebee AR |
850 | storeAppendPrintf(sentry, "\tFree Small blocks: %6.0f KB\n", |
851 | stats.mp_fsmblks / 1024); | |
62e76326 | 852 | |
8822ebee AR |
853 | storeAppendPrintf(sentry, "\tFree Ordinary blocks: %6.0f KB\n", |
854 | stats.mp_fordblks / 1024); | |
62e76326 | 855 | |
8822ebee | 856 | double t = stats.mp_fsmblks + stats.mp_fordblks; |
62e76326 | 857 | |
8822ebee AR |
858 | storeAppendPrintf(sentry, "\tTotal in use: %6.0f KB %.0f%%\n", |
859 | t / 1024, Math::doublePercent(t, stats.mp_arena + stats.mp_hblkhd)); | |
62e76326 | 860 | |
8822ebee | 861 | t = stats.mp_fsmblks + stats.mp_fordblks; |
62e76326 | 862 | |
8822ebee AR |
863 | storeAppendPrintf(sentry, "\tTotal free: %6.0f KB %.0f%%\n", |
864 | t / 1024, Math::doublePercent(t, stats.mp_arena + stats.mp_hblkhd)); | |
62e76326 | 865 | |
8822ebee | 866 | t = stats.mp_arena + stats.mp_hblkhd; |
62e76326 | 867 | |
8822ebee AR |
868 | storeAppendPrintf(sentry, "\tTotal size: %6.0f KB\n", |
869 | t / 1024); | |
62e76326 | 870 | |
6a9f6389 | 871 | #if HAVE_STRUCT_MALLINFO_MXFAST |
62e76326 | 872 | |
8822ebee | 873 | storeAppendPrintf(sentry, "\tmax size of small blocks:\t%.0f\n", stats.mp_mxfast); |
62e76326 | 874 | |
8822ebee AR |
875 | storeAppendPrintf(sentry, "\tnumber of small blocks in a holding block:\t%.0f\n", |
876 | stats.mp_nlblks); | |
62e76326 | 877 | |
8822ebee | 878 | storeAppendPrintf(sentry, "\tsmall block rounding factor:\t%.0f\n", stats.mp_grain); |
62e76326 | 879 | |
8822ebee AR |
880 | storeAppendPrintf(sentry, "\tspace (including overhead) allocated in ord. blks:\t%.0f\n" |
881 | ,stats.mp_uordbytes); | |
62e76326 | 882 | |
8822ebee AR |
883 | storeAppendPrintf(sentry, "\tnumber of ordinary blocks allocated:\t%.0f\n", |
884 | stats.mp_allocated); | |
62e76326 | 885 | |
8822ebee AR |
886 | storeAppendPrintf(sentry, "\tbytes used in maintaining the free tree:\t%.0f\n", |
887 | stats.mp_treeoverhead); | |
62e76326 | 888 | |
6a9f6389 | 889 | #endif /* HAVE_STRUCT_MALLINFO_MXFAST */ |
50bc2565 | 890 | #endif /* HAVE_MALLINFO */ |
62e76326 | 891 | |
5d1f3c82 | 892 | storeAppendPrintf(sentry, "Memory accounted for:\n"); |
62e76326 | 893 | |
d96ceb8e | 894 | #if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO |
62e76326 | 895 | |
8822ebee AR |
896 | storeAppendPrintf(sentry, "\tTotal accounted: %6.0f KB %3.0f%%\n", |
897 | stats.total_accounted / 1024, Math::doublePercent(stats.total_accounted, t)); | |
62e76326 | 898 | |
d96ceb8e | 899 | #else |
62e76326 | 900 | |
8822ebee AR |
901 | storeAppendPrintf(sentry, "\tTotal accounted: %6.0f KB\n", |
902 | stats.total_accounted / 1024); | |
62e76326 | 903 | |
d96ceb8e | 904 | #endif |
905 | { | |
62e76326 | 906 | MemPoolGlobalStats mp_stats; |
907 | memPoolGetGlobalStats(&mp_stats); | |
1ce8e204 | 908 | #if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO |
62e76326 | 909 | |
8822ebee AR |
910 | storeAppendPrintf(sentry, "\tmemPool accounted: %6.0f KB %3.0f%%\n", |
911 | stats.mem_pool_allocated / 1024, | |
912 | Math::doublePercent(stats.mem_pool_allocated, t)); | |
95c03392 | 913 | |
8822ebee AR |
914 | const double iFree = max(0.0, t - stats.mem_pool_allocated); |
915 | storeAppendPrintf(sentry, "\tmemPool unaccounted: %6.0f KB %3.0f%%\n", | |
916 | (t - stats.mem_pool_allocated) / 1024, | |
917 | Math::doublePercent(iFree, t)); | |
1ce8e204 | 918 | #endif |
62e76326 | 919 | |
920 | storeAppendPrintf(sentry, "\tmemPoolAlloc calls: %9.0f\n", | |
8822ebee | 921 | stats.gb_saved_count); |
62e76326 | 922 | storeAppendPrintf(sentry, "\tmemPoolFree calls: %9.0f\n", |
8822ebee | 923 | stats.gb_freed_count); |
d96ceb8e | 924 | } |
62e76326 | 925 | |
7dbca7a4 | 926 | storeAppendPrintf(sentry, "File descriptor usage for %s:\n", APP_SHORTNAME); |
8822ebee AR |
927 | storeAppendPrintf(sentry, "\tMaximum number of file descriptors: %4.0f\n", |
928 | stats.max_fd); | |
929 | storeAppendPrintf(sentry, "\tLargest file desc currently in use: %4.0f\n", | |
930 | stats.biggest_fd); | |
931 | storeAppendPrintf(sentry, "\tNumber of file desc currently in use: %4.0f\n", | |
932 | stats.number_fd); | |
933 | storeAppendPrintf(sentry, "\tFiles queued for open: %4.0f\n", | |
934 | stats.opening_fd); | |
935 | storeAppendPrintf(sentry, "\tAvailable number of file descriptors: %4.0f\n", | |
936 | stats.num_fd_free); | |
937 | storeAppendPrintf(sentry, "\tReserved number of file descriptors: %4.0f\n", | |
938 | stats.reserved_fd); | |
939 | storeAppendPrintf(sentry, "\tStore Disk files open: %4.0f\n", | |
93bc1434 | 940 | stats.store.swap.open_disk_fd); |
090089c4 | 941 | |
15576b6a | 942 | storeAppendPrintf(sentry, "Internal Data Structures:\n"); |
8822ebee | 943 | storeAppendPrintf(sentry, "\t%6.0f StoreEntries\n", |
93bc1434 | 944 | stats.store.store_entry_count); |
8822ebee | 945 | storeAppendPrintf(sentry, "\t%6.0f StoreEntries with MemObjects\n", |
93bc1434 | 946 | stats.store.mem_object_count); |
8822ebee | 947 | storeAppendPrintf(sentry, "\t%6.0f Hot Object Cache Items\n", |
93bc1434 | 948 | stats.store.mem.count); |
8822ebee | 949 | storeAppendPrintf(sentry, "\t%6.0f on-disk objects\n", |
93bc1434 | 950 | stats.store.swap.count); |
8822ebee | 951 | } |
30a4f2a8 | 952 | |
8822ebee AR |
953 | void |
954 | DumpMallocStatistics(StoreEntry* sentry) | |
955 | { | |
30a4f2a8 | 956 | #if XMALLOC_STATISTICS |
62e76326 | 957 | |
58cd5bbd | 958 | xm_deltat = current_dtime - xm_time; |
959 | xm_time = current_dtime; | |
960 | storeAppendPrintf(sentry, "\nMemory allocation statistics\n"); | |
77b88b59 | 961 | storeAppendPrintf(sentry, "%12s %15s %6s %12s\n","Alloc Size","Count","Delta","Alloc/sec"); |
30a4f2a8 | 962 | malloc_statistics(info_get_mallstat, sentry); |
963 | #endif | |
090089c4 | 964 | } |
965 | ||
8822ebee AR |
966 | void |
967 | GetServiceTimesStats(Mgr::ServiceTimesActionData& stats) | |
968 | { | |
969 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { | |
970 | double p = (i + 1) * 5 / 100.0; | |
971 | stats.http_requests5[i] = statPctileSvc(p, 5, PCTILE_HTTP); | |
972 | stats.http_requests60[i] = statPctileSvc(p, 60, PCTILE_HTTP); | |
973 | ||
974 | stats.cache_misses5[i] = statPctileSvc(p, 5, PCTILE_MISS); | |
975 | stats.cache_misses60[i] = statPctileSvc(p, 60, PCTILE_MISS); | |
976 | ||
977 | stats.cache_hits5[i] = statPctileSvc(p, 5, PCTILE_HIT); | |
978 | stats.cache_hits60[i] = statPctileSvc(p, 60, PCTILE_HIT); | |
979 | ||
980 | stats.near_hits5[i] = statPctileSvc(p, 5, PCTILE_NH); | |
981 | stats.near_hits60[i] = statPctileSvc(p, 60, PCTILE_NH); | |
982 | ||
983 | stats.not_modified_replies5[i] = statPctileSvc(p, 5, PCTILE_NM); | |
984 | stats.not_modified_replies60[i] = statPctileSvc(p, 60, PCTILE_NM); | |
985 | ||
986 | stats.dns_lookups5[i] = statPctileSvc(p, 5, PCTILE_DNS); | |
987 | stats.dns_lookups60[i] = statPctileSvc(p, 60, PCTILE_DNS); | |
988 | ||
989 | stats.icp_queries5[i] = statPctileSvc(p, 5, PCTILE_ICP_QUERY); | |
990 | stats.icp_queries60[i] = statPctileSvc(p, 60, PCTILE_ICP_QUERY); | |
991 | } | |
992 | } | |
993 | ||
994 | void | |
995 | DumpServiceTimesStats(Mgr::ServiceTimesActionData& stats, StoreEntry* sentry) | |
04a28d46 | 996 | { |
04a28d46 | 997 | storeAppendPrintf(sentry, "Service Time Percentiles 5 min 60 min:\n"); |
8822ebee AR |
998 | double fct = stats.count > 1 ? stats.count * 1000.0 : 1000.0; |
999 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { | |
26ac0430 | 1000 | storeAppendPrintf(sentry, "\tHTTP Requests (All): %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1001 | (i + 1) * 5, |
1002 | stats.http_requests5[i] / fct, | |
1003 | stats.http_requests60[i] / fct); | |
04a28d46 | 1004 | } |
8822ebee | 1005 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { |
26ac0430 | 1006 | storeAppendPrintf(sentry, "\tCache Misses: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1007 | (i + 1) * 5, |
1008 | stats.cache_misses5[i] / fct, | |
1009 | stats.cache_misses60[i] / fct); | |
04a28d46 | 1010 | } |
8822ebee | 1011 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { |
26ac0430 | 1012 | storeAppendPrintf(sentry, "\tCache Hits: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1013 | (i + 1) * 5, |
1014 | stats.cache_hits5[i] / fct, | |
1015 | stats.cache_hits60[i] / fct); | |
04a28d46 | 1016 | } |
8822ebee | 1017 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { |
26ac0430 | 1018 | storeAppendPrintf(sentry, "\tNear Hits: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1019 | (i + 1) * 5, |
1020 | stats.near_hits5[i] / fct, | |
1021 | stats.near_hits60[i] / fct); | |
04a28d46 | 1022 | } |
8822ebee | 1023 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { |
26ac0430 | 1024 | storeAppendPrintf(sentry, "\tNot-Modified Replies: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1025 | (i + 1) * 5, |
1026 | stats.not_modified_replies5[i] / fct, | |
1027 | stats.not_modified_replies60[i] / fct); | |
04a28d46 | 1028 | } |
8822ebee | 1029 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { |
26ac0430 | 1030 | storeAppendPrintf(sentry, "\tDNS Lookups: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1031 | (i + 1) * 5, |
1032 | stats.dns_lookups5[i] / fct, | |
1033 | stats.dns_lookups60[i] / fct); | |
04a28d46 | 1034 | } |
8822ebee AR |
1035 | fct = stats.count > 1 ? stats.count * 1000000.0 : 1000000.0; |
1036 | for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) { | |
26ac0430 | 1037 | storeAppendPrintf(sentry, "\tICP Queries: %2d%% %8.5f %8.5f\n", |
8822ebee AR |
1038 | (i + 1) * 5, |
1039 | stats.icp_queries5[i] / fct, | |
1040 | stats.icp_queries60[i] / fct); | |
04a28d46 | 1041 | } |
1042 | } | |
1043 | ||
b8d8561b | 1044 | static void |
a0f32775 | 1045 | statAvgDump(StoreEntry * sentry, int minutes, int hours) |
8822ebee AR |
1046 | { |
1047 | Mgr::IntervalActionData stats; | |
1048 | GetAvgStat(stats, minutes, hours); | |
1049 | DumpAvgStat(stats, sentry); | |
1050 | } | |
1051 | ||
1052 | #define XAVG(X) (dt ? (double) (f->X - l->X) / dt : 0.0) | |
1053 | void | |
1054 | GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours) | |
090089c4 | 1055 | { |
a7c05555 | 1056 | StatCounters *f; |
1057 | StatCounters *l; | |
1058 | double dt; | |
1059 | double ct; | |
1060 | assert(N_COUNT_HIST > 1); | |
a0f32775 | 1061 | assert(minutes > 0 || hours > 0); |
a7c05555 | 1062 | f = &CountHist[0]; |
a0f32775 | 1063 | l = f; |
62e76326 | 1064 | |
a0f32775 | 1065 | if (minutes > 0 && hours == 0) { |
62e76326 | 1066 | /* checking minute readings ... */ |
1067 | ||
1068 | if (minutes > N_COUNT_HIST - 1) | |
1069 | minutes = N_COUNT_HIST - 1; | |
1070 | ||
1071 | l = &CountHist[minutes]; | |
a0f32775 | 1072 | } else if (minutes == 0 && hours > 0) { |
62e76326 | 1073 | /* checking hour readings ... */ |
1074 | ||
1075 | if (hours > N_COUNT_HOUR_HIST - 1) | |
1076 | hours = N_COUNT_HOUR_HIST - 1; | |
1077 | ||
1078 | l = &CountHourHist[hours]; | |
a0f32775 | 1079 | } else { |
e0236918 | 1080 | debugs(18, DBG_IMPORTANT, "statAvgDump: Invalid args, minutes=" << minutes << ", hours=" << hours); |
62e76326 | 1081 | return; |
a0f32775 | 1082 | } |
62e76326 | 1083 | |
a7c05555 | 1084 | dt = tvSubDsec(l->timestamp, f->timestamp); |
1085 | ct = f->cputime - l->cputime; | |
ee1679df | 1086 | |
8822ebee AR |
1087 | stats.sample_start_time = l->timestamp; |
1088 | stats.sample_end_time = f->timestamp; | |
1089 | ||
1090 | stats.client_http_requests = XAVG(client_http.requests); | |
1091 | stats.client_http_hits = XAVG(client_http.hits); | |
1092 | stats.client_http_errors = XAVG(client_http.errors); | |
1093 | stats.client_http_kbytes_in = XAVG(client_http.kbytes_in.kb); | |
1094 | stats.client_http_kbytes_out = XAVG(client_http.kbytes_out.kb); | |
1095 | ||
e8baef82 FC |
1096 | stats.client_http_all_median_svc_time = statHistDeltaMedian(l->client_http.allSvcTime, |
1097 | f->client_http.allSvcTime) / 1000.0; | |
1098 | stats.client_http_miss_median_svc_time = statHistDeltaMedian(l->client_http.missSvcTime, | |
1099 | f->client_http.missSvcTime) / 1000.0; | |
1100 | stats.client_http_nm_median_svc_time = statHistDeltaMedian(l->client_http.nearMissSvcTime, | |
1101 | f->client_http.nearMissSvcTime) / 1000.0; | |
1102 | stats.client_http_nh_median_svc_time = statHistDeltaMedian(l->client_http.nearHitSvcTime, | |
1103 | f->client_http.nearHitSvcTime) / 1000.0; | |
1104 | stats.client_http_hit_median_svc_time = statHistDeltaMedian(l->client_http.hitSvcTime, | |
1105 | f->client_http.hitSvcTime) / 1000.0; | |
8822ebee AR |
1106 | |
1107 | stats.server_all_requests = XAVG(server.all.requests); | |
1108 | stats.server_all_errors = XAVG(server.all.errors); | |
1109 | stats.server_all_kbytes_in = XAVG(server.all.kbytes_in.kb); | |
1110 | stats.server_all_kbytes_out = XAVG(server.all.kbytes_out.kb); | |
1111 | ||
1112 | stats.server_http_requests = XAVG(server.http.requests); | |
1113 | stats.server_http_errors = XAVG(server.http.errors); | |
1114 | stats.server_http_kbytes_in = XAVG(server.http.kbytes_in.kb); | |
1115 | stats.server_http_kbytes_out = XAVG(server.http.kbytes_out.kb); | |
1116 | ||
1117 | stats.server_ftp_requests = XAVG(server.ftp.requests); | |
1118 | stats.server_ftp_errors = XAVG(server.ftp.errors); | |
1119 | stats.server_ftp_kbytes_in = XAVG(server.ftp.kbytes_in.kb); | |
1120 | stats.server_ftp_kbytes_out = XAVG(server.ftp.kbytes_out.kb); | |
1121 | ||
1122 | stats.server_other_requests = XAVG(server.other.requests); | |
1123 | stats.server_other_errors = XAVG(server.other.errors); | |
1124 | stats.server_other_kbytes_in = XAVG(server.other.kbytes_in.kb); | |
1125 | stats.server_other_kbytes_out = XAVG(server.other.kbytes_out.kb); | |
1126 | ||
1127 | stats.icp_pkts_sent = XAVG(icp.pkts_sent); | |
1128 | stats.icp_pkts_recv = XAVG(icp.pkts_recv); | |
1129 | stats.icp_queries_sent = XAVG(icp.queries_sent); | |
1130 | stats.icp_replies_sent = XAVG(icp.replies_sent); | |
1131 | stats.icp_queries_recv = XAVG(icp.queries_recv); | |
1132 | stats.icp_replies_recv = XAVG(icp.replies_recv); | |
1133 | stats.icp_replies_queued = XAVG(icp.replies_queued); | |
1134 | stats.icp_query_timeouts = XAVG(icp.query_timeouts); | |
1135 | stats.icp_kbytes_sent = XAVG(icp.kbytes_sent.kb); | |
1136 | stats.icp_kbytes_recv = XAVG(icp.kbytes_recv.kb); | |
1137 | stats.icp_q_kbytes_sent = XAVG(icp.q_kbytes_sent.kb); | |
1138 | stats.icp_r_kbytes_sent = XAVG(icp.r_kbytes_sent.kb); | |
1139 | stats.icp_q_kbytes_recv = XAVG(icp.q_kbytes_recv.kb); | |
1140 | stats.icp_r_kbytes_recv = XAVG(icp.r_kbytes_recv.kb); | |
1141 | ||
e8baef82 FC |
1142 | stats.icp_query_median_svc_time = statHistDeltaMedian(l->icp.querySvcTime, |
1143 | f->icp.querySvcTime) / 1000000.0; | |
1144 | stats.icp_reply_median_svc_time = statHistDeltaMedian(l->icp.replySvcTime, | |
1145 | f->icp.replySvcTime) / 1000000.0; | |
1146 | stats.dns_median_svc_time = statHistDeltaMedian(l->dns.svcTime, | |
1147 | f->dns.svcTime) / 1000.0; | |
8822ebee AR |
1148 | |
1149 | stats.unlink_requests = XAVG(unlink.requests); | |
1150 | stats.page_faults = XAVG(page_faults); | |
1151 | stats.select_loops = XAVG(select_loops); | |
1152 | stats.select_fds = XAVG(select_fds); | |
1153 | stats.average_select_fd_period = f->select_fds > l->select_fds ? | |
d9fc6862 | 1154 | (f->select_time - l->select_time) / (f->select_fds - l->select_fds) : 0.0; |
8822ebee | 1155 | |
3888201e | 1156 | stats.median_select_fds = statHistDeltaMedian(l->select_fds_hist, f->select_fds_hist); |
8822ebee AR |
1157 | stats.swap_outs = XAVG(swap.outs); |
1158 | stats.swap_ins = XAVG(swap.ins); | |
1159 | stats.swap_files_cleaned = XAVG(swap.files_cleaned); | |
1160 | stats.aborted_requests = XAVG(aborted_requests); | |
1161 | ||
1162 | stats.syscalls_disk_opens = XAVG(syscalls.disk.opens); | |
1163 | stats.syscalls_disk_closes = XAVG(syscalls.disk.closes); | |
1164 | stats.syscalls_disk_reads = XAVG(syscalls.disk.reads); | |
1165 | stats.syscalls_disk_writes = XAVG(syscalls.disk.writes); | |
1166 | stats.syscalls_disk_seeks = XAVG(syscalls.disk.seeks); | |
1167 | stats.syscalls_disk_unlinks = XAVG(syscalls.disk.unlinks); | |
1168 | stats.syscalls_sock_accepts = XAVG(syscalls.sock.accepts); | |
1169 | stats.syscalls_sock_sockets = XAVG(syscalls.sock.sockets); | |
1170 | stats.syscalls_sock_connects = XAVG(syscalls.sock.connects); | |
1171 | stats.syscalls_sock_binds = XAVG(syscalls.sock.binds); | |
1172 | stats.syscalls_sock_closes = XAVG(syscalls.sock.closes); | |
1173 | stats.syscalls_sock_reads = XAVG(syscalls.sock.reads); | |
1174 | stats.syscalls_sock_writes = XAVG(syscalls.sock.writes); | |
1175 | stats.syscalls_sock_recvfroms = XAVG(syscalls.sock.recvfroms); | |
1176 | stats.syscalls_sock_sendtos = XAVG(syscalls.sock.sendtos); | |
1177 | stats.syscalls_selects = XAVG(syscalls.selects); | |
1178 | ||
1179 | stats.cpu_time = ct; | |
1180 | stats.wall_time = dt; | |
1181 | } | |
1182 | ||
1183 | void | |
1184 | DumpAvgStat(Mgr::IntervalActionData& stats, StoreEntry* sentry) | |
1185 | { | |
399e85ea | 1186 | storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n", |
8822ebee AR |
1187 | (int)stats.sample_start_time.tv_sec, |
1188 | (int)stats.sample_start_time.tv_usec, | |
1189 | mkrfc1123(stats.sample_start_time.tv_sec)); | |
5843f24a | 1190 | storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n", |
8822ebee AR |
1191 | (int)stats.sample_end_time.tv_sec, |
1192 | (int)stats.sample_end_time.tv_usec, | |
1193 | mkrfc1123(stats.sample_end_time.tv_sec)); | |
a0f32775 | 1194 | |
a7c05555 | 1195 | storeAppendPrintf(sentry, "client_http.requests = %f/sec\n", |
8822ebee | 1196 | stats.client_http_requests); |
a7c05555 | 1197 | storeAppendPrintf(sentry, "client_http.hits = %f/sec\n", |
8822ebee | 1198 | stats.client_http_hits); |
a7c05555 | 1199 | storeAppendPrintf(sentry, "client_http.errors = %f/sec\n", |
8822ebee | 1200 | stats.client_http_errors); |
a7c05555 | 1201 | storeAppendPrintf(sentry, "client_http.kbytes_in = %f/sec\n", |
8822ebee | 1202 | stats.client_http_kbytes_in); |
a7c05555 | 1203 | storeAppendPrintf(sentry, "client_http.kbytes_out = %f/sec\n", |
8822ebee | 1204 | stats.client_http_kbytes_out); |
ee1679df | 1205 | |
8822ebee | 1206 | double fct = stats.count > 1 ? stats.count : 1.0; |
ee1679df | 1207 | storeAppendPrintf(sentry, "client_http.all_median_svc_time = %f seconds\n", |
8822ebee | 1208 | stats.client_http_all_median_svc_time / fct); |
ee1679df | 1209 | storeAppendPrintf(sentry, "client_http.miss_median_svc_time = %f seconds\n", |
8822ebee | 1210 | stats.client_http_miss_median_svc_time / fct); |
ee1679df | 1211 | storeAppendPrintf(sentry, "client_http.nm_median_svc_time = %f seconds\n", |
8822ebee | 1212 | stats.client_http_nm_median_svc_time / fct); |
7c9c84ad | 1213 | storeAppendPrintf(sentry, "client_http.nh_median_svc_time = %f seconds\n", |
8822ebee | 1214 | stats.client_http_nh_median_svc_time / fct); |
ee1679df | 1215 | storeAppendPrintf(sentry, "client_http.hit_median_svc_time = %f seconds\n", |
8822ebee | 1216 | stats.client_http_hit_median_svc_time / fct); |
071a3ae7 | 1217 | |
a0f32775 | 1218 | storeAppendPrintf(sentry, "server.all.requests = %f/sec\n", |
8822ebee | 1219 | stats.server_all_requests); |
a0f32775 | 1220 | storeAppendPrintf(sentry, "server.all.errors = %f/sec\n", |
8822ebee | 1221 | stats.server_all_errors); |
a0f32775 | 1222 | storeAppendPrintf(sentry, "server.all.kbytes_in = %f/sec\n", |
8822ebee | 1223 | stats.server_all_kbytes_in); |
a0f32775 | 1224 | storeAppendPrintf(sentry, "server.all.kbytes_out = %f/sec\n", |
8822ebee | 1225 | stats.server_all_kbytes_out); |
a0f32775 | 1226 | |
1227 | storeAppendPrintf(sentry, "server.http.requests = %f/sec\n", | |
8822ebee | 1228 | stats.server_http_requests); |
a0f32775 | 1229 | storeAppendPrintf(sentry, "server.http.errors = %f/sec\n", |
8822ebee | 1230 | stats.server_http_errors); |
a0f32775 | 1231 | storeAppendPrintf(sentry, "server.http.kbytes_in = %f/sec\n", |
8822ebee | 1232 | stats.server_http_kbytes_in); |
a0f32775 | 1233 | storeAppendPrintf(sentry, "server.http.kbytes_out = %f/sec\n", |
8822ebee | 1234 | stats.server_http_kbytes_out); |
a0f32775 | 1235 | |
1236 | storeAppendPrintf(sentry, "server.ftp.requests = %f/sec\n", | |
8822ebee | 1237 | stats.server_ftp_requests); |
a0f32775 | 1238 | storeAppendPrintf(sentry, "server.ftp.errors = %f/sec\n", |
8822ebee | 1239 | stats.server_ftp_errors); |
a0f32775 | 1240 | storeAppendPrintf(sentry, "server.ftp.kbytes_in = %f/sec\n", |
8822ebee | 1241 | stats.server_ftp_kbytes_in); |
a0f32775 | 1242 | storeAppendPrintf(sentry, "server.ftp.kbytes_out = %f/sec\n", |
8822ebee | 1243 | stats.server_ftp_kbytes_out); |
a0f32775 | 1244 | |
1245 | storeAppendPrintf(sentry, "server.other.requests = %f/sec\n", | |
8822ebee | 1246 | stats.server_other_requests); |
a0f32775 | 1247 | storeAppendPrintf(sentry, "server.other.errors = %f/sec\n", |
8822ebee | 1248 | stats.server_other_errors); |
a0f32775 | 1249 | storeAppendPrintf(sentry, "server.other.kbytes_in = %f/sec\n", |
8822ebee | 1250 | stats.server_other_kbytes_in); |
a0f32775 | 1251 | storeAppendPrintf(sentry, "server.other.kbytes_out = %f/sec\n", |
8822ebee | 1252 | stats.server_other_kbytes_out); |
ee1679df | 1253 | |
a7c05555 | 1254 | storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n", |
8822ebee | 1255 | stats.icp_pkts_sent); |
a7c05555 | 1256 | storeAppendPrintf(sentry, "icp.pkts_recv = %f/sec\n", |
8822ebee | 1257 | stats.icp_pkts_recv); |
071a3ae7 | 1258 | storeAppendPrintf(sentry, "icp.queries_sent = %f/sec\n", |
8822ebee | 1259 | stats.icp_queries_sent); |
071a3ae7 | 1260 | storeAppendPrintf(sentry, "icp.replies_sent = %f/sec\n", |
8822ebee | 1261 | stats.icp_replies_sent); |
071a3ae7 | 1262 | storeAppendPrintf(sentry, "icp.queries_recv = %f/sec\n", |
8822ebee | 1263 | stats.icp_queries_recv); |
071a3ae7 | 1264 | storeAppendPrintf(sentry, "icp.replies_recv = %f/sec\n", |
8822ebee | 1265 | stats.icp_replies_recv); |
2e8e29b8 | 1266 | storeAppendPrintf(sentry, "icp.replies_queued = %f/sec\n", |
8822ebee | 1267 | stats.icp_replies_queued); |
071a3ae7 | 1268 | storeAppendPrintf(sentry, "icp.query_timeouts = %f/sec\n", |
8822ebee | 1269 | stats.icp_query_timeouts); |
a7c05555 | 1270 | storeAppendPrintf(sentry, "icp.kbytes_sent = %f/sec\n", |
8822ebee | 1271 | stats.icp_kbytes_sent); |
a7c05555 | 1272 | storeAppendPrintf(sentry, "icp.kbytes_recv = %f/sec\n", |
8822ebee | 1273 | stats.icp_kbytes_recv); |
071a3ae7 | 1274 | storeAppendPrintf(sentry, "icp.q_kbytes_sent = %f/sec\n", |
8822ebee | 1275 | stats.icp_q_kbytes_sent); |
071a3ae7 | 1276 | storeAppendPrintf(sentry, "icp.r_kbytes_sent = %f/sec\n", |
8822ebee | 1277 | stats.icp_r_kbytes_sent); |
071a3ae7 | 1278 | storeAppendPrintf(sentry, "icp.q_kbytes_recv = %f/sec\n", |
8822ebee | 1279 | stats.icp_q_kbytes_recv); |
071a3ae7 | 1280 | storeAppendPrintf(sentry, "icp.r_kbytes_recv = %f/sec\n", |
8822ebee | 1281 | stats.icp_r_kbytes_recv); |
ee1679df | 1282 | storeAppendPrintf(sentry, "icp.query_median_svc_time = %f seconds\n", |
8822ebee | 1283 | stats.icp_query_median_svc_time / fct); |
ee1679df | 1284 | storeAppendPrintf(sentry, "icp.reply_median_svc_time = %f seconds\n", |
8822ebee | 1285 | stats.icp_reply_median_svc_time / fct); |
9973e9fe | 1286 | storeAppendPrintf(sentry, "dns.median_svc_time = %f seconds\n", |
8822ebee | 1287 | stats.dns_median_svc_time / fct); |
a7c05555 | 1288 | storeAppendPrintf(sentry, "unlink.requests = %f/sec\n", |
8822ebee | 1289 | stats.unlink_requests); |
a7c05555 | 1290 | storeAppendPrintf(sentry, "page_faults = %f/sec\n", |
8822ebee | 1291 | stats.page_faults); |
a7c05555 | 1292 | storeAppendPrintf(sentry, "select_loops = %f/sec\n", |
8822ebee | 1293 | stats.select_loops); |
d239c2f5 | 1294 | storeAppendPrintf(sentry, "select_fds = %f/sec\n", |
8822ebee | 1295 | stats.select_fds); |
d239c2f5 | 1296 | storeAppendPrintf(sentry, "average_select_fd_period = %f/fd\n", |
8822ebee AR |
1297 | stats.average_select_fd_period / fct); |
1298 | storeAppendPrintf(sentry, "median_select_fds = %f\n", | |
1299 | stats.median_select_fds / fct); | |
23dc8aca | 1300 | storeAppendPrintf(sentry, "swap.outs = %f/sec\n", |
8822ebee | 1301 | stats.swap_outs); |
23dc8aca | 1302 | storeAppendPrintf(sentry, "swap.ins = %f/sec\n", |
8822ebee | 1303 | stats.swap_ins); |
23dc8aca | 1304 | storeAppendPrintf(sentry, "swap.files_cleaned = %f/sec\n", |
8822ebee | 1305 | stats.swap_files_cleaned); |
bfae3379 | 1306 | storeAppendPrintf(sentry, "aborted_requests = %f/sec\n", |
8822ebee | 1307 | stats.aborted_requests); |
886f2785 | 1308 | |
1b3db6d9 | 1309 | #if USE_POLL |
8822ebee | 1310 | storeAppendPrintf(sentry, "syscalls.polls = %f/sec\n", stats.syscalls_selects); |
7d63e639 | 1311 | #elif defined(USE_SELECT) || defined(USE_SELECT_WIN32) |
8822ebee | 1312 | storeAppendPrintf(sentry, "syscalls.selects = %f/sec\n", stats.syscalls_selects); |
886f2785 | 1313 | #endif |
62e76326 | 1314 | |
8822ebee AR |
1315 | storeAppendPrintf(sentry, "syscalls.disk.opens = %f/sec\n", stats.syscalls_disk_opens); |
1316 | storeAppendPrintf(sentry, "syscalls.disk.closes = %f/sec\n", stats.syscalls_disk_closes); | |
1317 | storeAppendPrintf(sentry, "syscalls.disk.reads = %f/sec\n", stats.syscalls_disk_reads); | |
1318 | storeAppendPrintf(sentry, "syscalls.disk.writes = %f/sec\n", stats.syscalls_disk_writes); | |
1319 | storeAppendPrintf(sentry, "syscalls.disk.seeks = %f/sec\n", stats.syscalls_disk_seeks); | |
1320 | storeAppendPrintf(sentry, "syscalls.disk.unlinks = %f/sec\n", stats.syscalls_disk_unlinks); | |
1321 | storeAppendPrintf(sentry, "syscalls.sock.accepts = %f/sec\n", stats.syscalls_sock_accepts); | |
1322 | storeAppendPrintf(sentry, "syscalls.sock.sockets = %f/sec\n", stats.syscalls_sock_sockets); | |
1323 | storeAppendPrintf(sentry, "syscalls.sock.connects = %f/sec\n", stats.syscalls_sock_connects); | |
1324 | storeAppendPrintf(sentry, "syscalls.sock.binds = %f/sec\n", stats.syscalls_sock_binds); | |
1325 | storeAppendPrintf(sentry, "syscalls.sock.closes = %f/sec\n", stats.syscalls_sock_closes); | |
1326 | storeAppendPrintf(sentry, "syscalls.sock.reads = %f/sec\n", stats.syscalls_sock_reads); | |
1327 | storeAppendPrintf(sentry, "syscalls.sock.writes = %f/sec\n", stats.syscalls_sock_writes); | |
1328 | storeAppendPrintf(sentry, "syscalls.sock.recvfroms = %f/sec\n", stats.syscalls_sock_recvfroms); | |
1329 | storeAppendPrintf(sentry, "syscalls.sock.sendtos = %f/sec\n", stats.syscalls_sock_sendtos); | |
1330 | ||
1331 | storeAppendPrintf(sentry, "cpu_time = %f seconds\n", stats.cpu_time); | |
1332 | storeAppendPrintf(sentry, "wall_time = %f seconds\n", stats.wall_time); | |
1333 | storeAppendPrintf(sentry, "cpu_usage = %f%%\n", Math::doublePercent(stats.cpu_time, stats.wall_time)); | |
090089c4 | 1334 | } |
1335 | ||
5f5e883f | 1336 | static void |
b8083b1c | 1337 | statRegisterWithCacheManager(void) |
62ee09ca | 1338 | { |
8822ebee | 1339 | Mgr::RegisterAction("info", "General Runtime Information", |
d9fc6862 | 1340 | &Mgr::InfoAction::Create, 0, 1); |
8822ebee | 1341 | Mgr::RegisterAction("service_times", "Service Times (Percentiles)", |
d9fc6862 | 1342 | &Mgr::ServiceTimesAction::Create, 0, 1); |
8822ebee | 1343 | Mgr::RegisterAction("filedescriptors", "Process Filedescriptor Allocation", |
d9fc6862 | 1344 | fde::DumpStats, 0, 1); |
8822ebee AR |
1345 | Mgr::RegisterAction("objects", "All Cache Objects", stat_objects_get, 0, 0); |
1346 | Mgr::RegisterAction("vm_objects", "In-Memory and In-Transit Objects", | |
d9fc6862 | 1347 | stat_vmobjects_get, 0, 0); |
8822ebee | 1348 | Mgr::RegisterAction("io", "Server-side network read() size histograms", |
d9fc6862 | 1349 | &Mgr::IoAction::Create, 0, 1); |
8822ebee | 1350 | Mgr::RegisterAction("counters", "Traffic and Resource Counters", |
d9fc6862 | 1351 | &Mgr::CountersAction::Create, 0, 1); |
8822ebee | 1352 | Mgr::RegisterAction("peer_select", "Peer Selection Algorithms", |
d9fc6862 | 1353 | statPeerSelect, 0, 1); |
8822ebee | 1354 | Mgr::RegisterAction("digest_stats", "Cache Digest and ICP blob", |
d9fc6862 | 1355 | statDigestBlob, 0, 1); |
8822ebee | 1356 | Mgr::RegisterAction("5min", "5 Minute Average of Counters", |
d9fc6862 | 1357 | &Mgr::IntervalAction::Create5min, 0, 1); |
8822ebee | 1358 | Mgr::RegisterAction("60min", "60 Minute Average of Counters", |
d9fc6862 | 1359 | &Mgr::IntervalAction::Create60min, 0, 1); |
8822ebee | 1360 | Mgr::RegisterAction("utilization", "Cache Utilization", |
d9fc6862 | 1361 | statUtilization, 0, 1); |
8822ebee | 1362 | Mgr::RegisterAction("histograms", "Full Histogram Counts", |
d9fc6862 | 1363 | statCountersHistograms, 0, 1); |
8822ebee | 1364 | Mgr::RegisterAction("active_requests", |
d9fc6862 A |
1365 | "Client-side Active Requests", |
1366 | statClientRequests, 0, 1); | |
2f1431ea | 1367 | #if USE_AUTH |
8822ebee | 1368 | Mgr::RegisterAction("username_cache", |
d9fc6862 | 1369 | "Active Cached Usernames", |
d87154ee | 1370 | Auth::User::UsernameCacheStats, 0, 1); |
2f1431ea | 1371 | #endif |
b8083b1c | 1372 | #if DEBUG_OPENFD |
8822ebee | 1373 | Mgr::RegisterAction("openfd_objects", "Objects with Swapout files open", |
d9fc6862 | 1374 | statOpenfdObj, 0, 0); |
b8083b1c FC |
1375 | #endif |
1376 | #if STAT_GRAPHS | |
8822ebee | 1377 | Mgr::RegisterAction("graph_variables", "Display cache metrics graphically", |
d9fc6862 | 1378 | statGraphDump, 0, 1); |
b8083b1c | 1379 | #endif |
090089c4 | 1380 | } |
f2908497 | 1381 | |
5f5e883f FC |
1382 | void |
1383 | statInit(void) | |
1384 | { | |
1385 | int i; | |
1386 | debugs(18, 5, "statInit: Initializing..."); | |
1387 | ||
5db6bf73 | 1388 | for (i = 0; i < N_COUNT_HIST; ++i) |
5f5e883f FC |
1389 | statCountersInit(&CountHist[i]); |
1390 | ||
5db6bf73 | 1391 | for (i = 0; i < N_COUNT_HOUR_HIST; ++i) |
5f5e883f FC |
1392 | statCountersInit(&CountHourHist[i]); |
1393 | ||
1394 | statCountersInit(&statCounter); | |
1395 | ||
1396 | eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1); | |
1397 | ||
1398 | ClientActiveRequests.head = NULL; | |
1399 | ||
1400 | ClientActiveRequests.tail = NULL; | |
1401 | ||
1402 | statRegisterWithCacheManager(); | |
1403 | } | |
1404 | ||
f2908497 | 1405 | static void |
1406 | statAvgTick(void *notused) | |
1407 | { | |
d5649d9f | 1408 | StatCounters *t = &CountHist[0]; |
1409 | StatCounters *p = &CountHist[1]; | |
83704487 | 1410 | StatCounters *c = &statCounter; |
62e76326 | 1411 | |
f2908497 | 1412 | struct rusage rusage; |
b6a2f15e | 1413 | eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1); |
20903cac | 1414 | squid_getrusage(&rusage); |
1415 | c->page_faults = rusage_pagefaults(&rusage); | |
1416 | c->cputime = rusage_cputime(&rusage); | |
d5649d9f | 1417 | c->timestamp = current_time; |
12cf1be2 | 1418 | /* even if NCountHist is small, we already Init()ed the tail */ |
2ac76861 | 1419 | statCountersClean(CountHist + N_COUNT_HIST - 1); |
41d00cd3 | 1420 | memmove(p, t, (N_COUNT_HIST - 1) * sizeof(StatCounters)); |
12cf1be2 | 1421 | statCountersCopy(t, c); |
5db6bf73 | 1422 | ++NCountHist; |
a0f32775 | 1423 | |
1424 | if ((NCountHist % COUNT_INTERVAL) == 0) { | |
62e76326 | 1425 | /* we have an hours worth of readings. store previous hour */ |
e053c141 FC |
1426 | StatCounters *t2 = &CountHourHist[0]; |
1427 | StatCounters *p2 = &CountHourHist[1]; | |
1428 | StatCounters *c2 = &CountHist[N_COUNT_HIST - 1]; | |
62e76326 | 1429 | statCountersClean(CountHourHist + N_COUNT_HOUR_HIST - 1); |
41d00cd3 | 1430 | memmove(p2, t2, (N_COUNT_HOUR_HIST - 1) * sizeof(StatCounters)); |
e053c141 | 1431 | statCountersCopy(t2, c2); |
5db6bf73 | 1432 | ++NCountHourHist; |
a0f32775 | 1433 | } |
62e76326 | 1434 | |
b8a46de0 | 1435 | if (Config.warnings.high_rptm > 0) { |
04a28d46 | 1436 | int i = (int) statPctileSvc(0.5, 20, PCTILE_HTTP); |
62e76326 | 1437 | |
1438 | if (Config.warnings.high_rptm < i) | |
fa84c01d | 1439 | debugs(18, DBG_CRITICAL, "WARNING: Median response time is " << i << " milliseconds"); |
b8a46de0 | 1440 | } |
62e76326 | 1441 | |
b8a46de0 | 1442 | if (Config.warnings.high_pf) { |
62e76326 | 1443 | int i = (CountHist[0].page_faults - CountHist[1].page_faults); |
1444 | double dt = tvSubDsec(CountHist[0].timestamp, CountHist[1].timestamp); | |
1445 | ||
1446 | if (i > 0 && dt > 0.0) { | |
1447 | i /= (int) dt; | |
1448 | ||
1449 | if (Config.warnings.high_pf < i) | |
fa84c01d | 1450 | debugs(18, DBG_CRITICAL, "WARNING: Page faults occuring at " << i << "/sec"); |
62e76326 | 1451 | } |
b8a46de0 | 1452 | } |
62e76326 | 1453 | |
b8a46de0 | 1454 | if (Config.warnings.high_memory) { |
62e76326 | 1455 | size_t i = 0; |
b8a46de0 | 1456 | #if HAVE_MSTATS && HAVE_GNUMALLOC_H |
62e76326 | 1457 | |
1458 | struct mstats ms = mstats(); | |
1459 | i = ms.bytes_total; | |
b8a46de0 | 1460 | #elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO |
62e76326 | 1461 | |
1462 | struct mallinfo mp = mallinfo(); | |
1463 | i = mp.arena; | |
703cc8e8 | 1464 | #elif HAVE_SBRK |
1465 | ||
1466 | i = (size_t) ((char *) sbrk(0) - (char *) sbrk_start); | |
b8a46de0 | 1467 | #endif |
62e76326 | 1468 | |
1469 | if (Config.warnings.high_memory < i) | |
fa84c01d | 1470 | debugs(18, DBG_CRITICAL, "WARNING: Memory usage at " << ((unsigned long int)(i >> 20)) << " MB"); |
b8a46de0 | 1471 | } |
20903cac | 1472 | } |
1473 | ||
12cf1be2 | 1474 | static void |
2ac76861 | 1475 | statCountersInit(StatCounters * C) |
20903cac | 1476 | { |
12cf1be2 | 1477 | assert(C); |
1d803566 | 1478 | memset(C, 0, sizeof(*C)); |
12cf1be2 | 1479 | C->timestamp = current_time; |
1d803566 | 1480 | statCountersInitSpecial(C); |
1481 | } | |
1482 | ||
1483 | /* add special cases here as they arrive */ | |
1484 | static void | |
2ac76861 | 1485 | statCountersInitSpecial(StatCounters * C) |
1d803566 | 1486 | { |
12cf1be2 | 1487 | /* |
1488 | * HTTP svc_time hist is kept in milli-seconds; max of 3 hours. | |
1489 | */ | |
e8baef82 FC |
1490 | C->client_http.allSvcTime.logInit(300, 0.0, 3600000.0 * 3.0); |
1491 | C->client_http.missSvcTime.logInit(300, 0.0, 3600000.0 * 3.0); | |
1492 | C->client_http.nearMissSvcTime.logInit(300, 0.0, 3600000.0 * 3.0); | |
1493 | C->client_http.nearHitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0); | |
1494 | C->client_http.hitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0); | |
12cf1be2 | 1495 | /* |
1496 | * ICP svc_time hist is kept in micro-seconds; max of 1 minute. | |
1497 | */ | |
e8baef82 FC |
1498 | C->icp.querySvcTime.logInit(300, 0.0, 1000000.0 * 60.0); |
1499 | C->icp.replySvcTime.logInit(300, 0.0, 1000000.0 * 60.0); | |
12cf1be2 | 1500 | /* |
1501 | * DNS svc_time hist is kept in milli-seconds; max of 10 minutes. | |
1502 | */ | |
e8baef82 | 1503 | C->dns.svcTime.logInit(300, 0.0, 60000.0 * 10.0); |
a1e927f6 | 1504 | /* |
69c95dd3 | 1505 | * Cache Digest Stuff |
a1e927f6 | 1506 | */ |
e161cb08 | 1507 | C->cd.on_xition_count.enumInit(CacheDigestHashFuncCount); |
65d448bc | 1508 | C->comm_udp_incoming.enumInit(INCOMING_UDP_MAX); |
e161cb08 | 1509 | C->comm_dns_incoming.enumInit(INCOMING_DNS_MAX); |
65d448bc | 1510 | C->comm_tcp_incoming.enumInit(INCOMING_TCP_MAX); |
e161cb08 | 1511 | C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */ |
0f5607d9 | 1512 | } |
1513 | ||
12cf1be2 | 1514 | /* add special cases here as they arrive */ |
5e29a294 | 1515 | static void |
2ac76861 | 1516 | statCountersClean(StatCounters * C) |
0f5607d9 | 1517 | { |
12cf1be2 | 1518 | assert(C); |
e8baef82 FC |
1519 | C->client_http.allSvcTime.clear(); |
1520 | C->client_http.missSvcTime.clear(); | |
1521 | C->client_http.nearMissSvcTime.clear(); | |
1522 | C->client_http.nearHitSvcTime.clear(); | |
1523 | C->client_http.hitSvcTime.clear(); | |
1524 | C->icp.querySvcTime.clear(); | |
1525 | C->icp.replySvcTime.clear(); | |
1526 | C->dns.svcTime.clear(); | |
2ebbe7a4 | 1527 | C->cd.on_xition_count.clear(); |
65d448bc | 1528 | C->comm_udp_incoming.clear(); |
2ebbe7a4 | 1529 | C->comm_dns_incoming.clear(); |
65d448bc | 1530 | C->comm_tcp_incoming.clear(); |
2ebbe7a4 | 1531 | C->select_fds_hist.clear(); |
a7c05555 | 1532 | } |
1533 | ||
12cf1be2 | 1534 | /* add special cases here as they arrive */ |
5e29a294 | 1535 | static void |
2ac76861 | 1536 | statCountersCopy(StatCounters * dest, const StatCounters * orig) |
45eb7f49 | 1537 | { |
12cf1be2 | 1538 | assert(dest && orig); |
1d803566 | 1539 | /* this should take care of all the fields, but "special" ones */ |
41d00cd3 | 1540 | memcpy(dest, orig, sizeof(*dest)); |
1d803566 | 1541 | /* prepare space where to copy special entries */ |
1542 | statCountersInitSpecial(dest); | |
1543 | /* now handle special cases */ | |
1544 | /* note: we assert that histogram capacities do not change */ | |
e8baef82 FC |
1545 | dest->client_http.allSvcTime=orig->client_http.allSvcTime; |
1546 | dest->client_http.missSvcTime=orig->client_http.missSvcTime; | |
1547 | dest->client_http.nearMissSvcTime=orig->client_http.nearMissSvcTime; | |
1548 | dest->client_http.nearHitSvcTime=orig->client_http.nearHitSvcTime; | |
1549 | ||
1550 | dest->client_http.hitSvcTime=orig->client_http.hitSvcTime; | |
1551 | dest->icp.querySvcTime=orig->icp.querySvcTime; | |
1552 | dest->icp.replySvcTime=orig->icp.replySvcTime; | |
1553 | dest->dns.svcTime=orig->dns.svcTime; | |
7c8db219 | 1554 | dest->cd.on_xition_count=orig->cd.on_xition_count; |
65d448bc AJ |
1555 | dest->comm_udp_incoming=orig->comm_udp_incoming; |
1556 | dest->comm_dns_incoming=orig->comm_dns_incoming; | |
1557 | dest->comm_tcp_incoming=orig->comm_tcp_incoming; | |
7c8db219 | 1558 | dest->select_fds_hist=orig->select_fds_hist; |
45eb7f49 | 1559 | } |
1560 | ||
071a3ae7 | 1561 | static void |
5d406e78 | 1562 | statCountersHistograms(StoreEntry * sentry) |
071a3ae7 | 1563 | { |
e8baef82 FC |
1564 | storeAppendPrintf(sentry, "client_http.allSvcTime histogram:\n"); |
1565 | statCounter.client_http.allSvcTime.dump(sentry, NULL); | |
1566 | storeAppendPrintf(sentry, "client_http.missSvcTime histogram:\n"); | |
1567 | statCounter.client_http.missSvcTime.dump(sentry, NULL); | |
1568 | storeAppendPrintf(sentry, "client_http.nearMissSvcTime histogram:\n"); | |
1569 | statCounter.client_http.nearMissSvcTime.dump(sentry, NULL); | |
1570 | storeAppendPrintf(sentry, "client_http.nearHitSvcTime histogram:\n"); | |
1571 | statCounter.client_http.nearHitSvcTime.dump(sentry, NULL); | |
1572 | storeAppendPrintf(sentry, "client_http.hitSvcTime histogram:\n"); | |
1573 | statCounter.client_http.hitSvcTime.dump(sentry, NULL); | |
1574 | storeAppendPrintf(sentry, "icp.querySvcTime histogram:\n"); | |
1575 | statCounter.icp.querySvcTime.dump(sentry, NULL); | |
1576 | storeAppendPrintf(sentry, "icp.replySvcTime histogram:\n"); | |
1577 | statCounter.icp.replySvcTime.dump(sentry, NULL); | |
071a3ae7 | 1578 | storeAppendPrintf(sentry, "dns.svc_time histogram:\n"); |
e8baef82 | 1579 | statCounter.dns.svcTime.dump(sentry, NULL); |
2a73b7cb | 1580 | storeAppendPrintf(sentry, "select_fds_hist histogram:\n"); |
96886986 | 1581 | statCounter.select_fds_hist.dump(sentry, NULL); |
071a3ae7 | 1582 | } |
1583 | ||
12cf1be2 | 1584 | static void |
1585 | statCountersDump(StoreEntry * sentry) | |
8822ebee AR |
1586 | { |
1587 | Mgr::CountersActionData stats; | |
1588 | GetCountersStats(stats); | |
1589 | DumpCountersStats(stats, sentry); | |
1590 | } | |
1591 | ||
1592 | void | |
1593 | GetCountersStats(Mgr::CountersActionData& stats) | |
7ae52c25 | 1594 | { |
83704487 | 1595 | StatCounters *f = &statCounter; |
62e76326 | 1596 | |
12cf1be2 | 1597 | struct rusage rusage; |
1598 | squid_getrusage(&rusage); | |
1599 | f->page_faults = rusage_pagefaults(&rusage); | |
1600 | f->cputime = rusage_cputime(&rusage); | |
1601 | ||
8822ebee AR |
1602 | stats.sample_time = f->timestamp; |
1603 | stats.client_http_requests = f->client_http.requests; | |
1604 | stats.client_http_hits = f->client_http.hits; | |
1605 | stats.client_http_errors = f->client_http.errors; | |
1606 | stats.client_http_kbytes_in = f->client_http.kbytes_in.kb; | |
1607 | stats.client_http_kbytes_out = f->client_http.kbytes_out.kb; | |
1608 | stats.client_http_hit_kbytes_out = f->client_http.hit_kbytes_out.kb; | |
1609 | ||
1610 | stats.server_all_requests = f->server.all.requests; | |
1611 | stats.server_all_errors = f->server.all.errors; | |
1612 | stats.server_all_kbytes_in = f->server.all.kbytes_in.kb; | |
1613 | stats.server_all_kbytes_out = f->server.all.kbytes_out.kb; | |
1614 | ||
1615 | stats.server_http_requests = f->server.http.requests; | |
1616 | stats.server_http_errors = f->server.http.errors; | |
1617 | stats.server_http_kbytes_in = f->server.http.kbytes_in.kb; | |
1618 | stats.server_http_kbytes_out = f->server.http.kbytes_out.kb; | |
1619 | ||
1620 | stats.server_ftp_requests = f->server.ftp.requests; | |
1621 | stats.server_ftp_errors = f->server.ftp.errors; | |
1622 | stats.server_ftp_kbytes_in = f->server.ftp.kbytes_in.kb; | |
1623 | stats.server_ftp_kbytes_out = f->server.ftp.kbytes_out.kb; | |
1624 | ||
1625 | stats.server_other_requests = f->server.other.requests; | |
1626 | stats.server_other_errors = f->server.other.errors; | |
1627 | stats.server_other_kbytes_in = f->server.other.kbytes_in.kb; | |
1628 | stats.server_other_kbytes_out = f->server.other.kbytes_out.kb; | |
1629 | ||
1630 | stats.icp_pkts_sent = f->icp.pkts_sent; | |
1631 | stats.icp_pkts_recv = f->icp.pkts_recv; | |
1632 | stats.icp_queries_sent = f->icp.queries_sent; | |
1633 | stats.icp_replies_sent = f->icp.replies_sent; | |
1634 | stats.icp_queries_recv = f->icp.queries_recv; | |
1635 | stats.icp_replies_recv = f->icp.replies_recv; | |
1636 | stats.icp_query_timeouts = f->icp.query_timeouts; | |
1637 | stats.icp_replies_queued = f->icp.replies_queued; | |
1638 | stats.icp_kbytes_sent = f->icp.kbytes_sent.kb; | |
1639 | stats.icp_kbytes_recv = f->icp.kbytes_recv.kb; | |
1640 | stats.icp_q_kbytes_sent = f->icp.q_kbytes_sent.kb; | |
1641 | stats.icp_r_kbytes_sent = f->icp.r_kbytes_sent.kb; | |
1642 | stats.icp_q_kbytes_recv = f->icp.q_kbytes_recv.kb; | |
1643 | stats.icp_r_kbytes_recv = f->icp.r_kbytes_recv.kb; | |
1644 | ||
1645 | #if USE_CACHE_DIGESTS | |
1646 | ||
1647 | stats.icp_times_used = f->icp.times_used; | |
1648 | stats.cd_times_used = f->cd.times_used; | |
1649 | stats.cd_msgs_sent = f->cd.msgs_sent; | |
1650 | stats.cd_msgs_recv = f->cd.msgs_recv; | |
1651 | stats.cd_memory = f->cd.memory.kb; | |
1652 | stats.cd_local_memory = store_digest ? store_digest->mask_size / 1024 : 0; | |
1653 | stats.cd_kbytes_sent = f->cd.kbytes_sent.kb; | |
1654 | stats.cd_kbytes_recv = f->cd.kbytes_recv.kb; | |
1655 | #endif | |
1656 | ||
1657 | stats.unlink_requests = f->unlink.requests; | |
1658 | stats.page_faults = f->page_faults; | |
1659 | stats.select_loops = f->select_loops; | |
1660 | stats.cpu_time = f->cputime; | |
1661 | stats.wall_time = tvSubDsec(f->timestamp, current_time); | |
1662 | stats.swap_outs = f->swap.outs; | |
1663 | stats.swap_ins = f->swap.ins; | |
1664 | stats.swap_files_cleaned = f->swap.files_cleaned; | |
1665 | stats.aborted_requests = f->aborted_requests; | |
1666 | } | |
1667 | ||
1668 | void | |
1669 | DumpCountersStats(Mgr::CountersActionData& stats, StoreEntry* sentry) | |
1670 | { | |
a0f32775 | 1671 | storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n", |
8822ebee AR |
1672 | (int) stats.sample_time.tv_sec, |
1673 | (int) stats.sample_time.tv_usec, | |
1674 | mkrfc1123(stats.sample_time.tv_sec)); | |
1675 | storeAppendPrintf(sentry, "client_http.requests = %.0f\n", | |
1676 | stats.client_http_requests); | |
1677 | storeAppendPrintf(sentry, "client_http.hits = %.0f\n", | |
1678 | stats.client_http_hits); | |
1679 | storeAppendPrintf(sentry, "client_http.errors = %.0f\n", | |
1680 | stats.client_http_errors); | |
1681 | storeAppendPrintf(sentry, "client_http.kbytes_in = %.0f\n", | |
1682 | stats.client_http_kbytes_in); | |
1683 | storeAppendPrintf(sentry, "client_http.kbytes_out = %.0f\n", | |
1684 | stats.client_http_kbytes_out); | |
1685 | storeAppendPrintf(sentry, "client_http.hit_kbytes_out = %.0f\n", | |
1686 | stats.client_http_hit_kbytes_out); | |
1687 | ||
1688 | storeAppendPrintf(sentry, "server.all.requests = %.0f\n", | |
1689 | stats.server_all_requests); | |
1690 | storeAppendPrintf(sentry, "server.all.errors = %.0f\n", | |
1691 | stats.server_all_errors); | |
1692 | storeAppendPrintf(sentry, "server.all.kbytes_in = %.0f\n", | |
1693 | stats.server_all_kbytes_in); | |
1694 | storeAppendPrintf(sentry, "server.all.kbytes_out = %.0f\n", | |
1695 | stats.server_all_kbytes_out); | |
1696 | ||
1697 | storeAppendPrintf(sentry, "server.http.requests = %.0f\n", | |
1698 | stats.server_http_requests); | |
1699 | storeAppendPrintf(sentry, "server.http.errors = %.0f\n", | |
1700 | stats.server_http_errors); | |
1701 | storeAppendPrintf(sentry, "server.http.kbytes_in = %.0f\n", | |
1702 | stats.server_http_kbytes_in); | |
1703 | storeAppendPrintf(sentry, "server.http.kbytes_out = %.0f\n", | |
1704 | stats.server_http_kbytes_out); | |
1705 | ||
1706 | storeAppendPrintf(sentry, "server.ftp.requests = %.0f\n", | |
1707 | stats.server_ftp_requests); | |
1708 | storeAppendPrintf(sentry, "server.ftp.errors = %.0f\n", | |
1709 | stats.server_ftp_errors); | |
1710 | storeAppendPrintf(sentry, "server.ftp.kbytes_in = %.0f\n", | |
1711 | stats.server_ftp_kbytes_in); | |
1712 | storeAppendPrintf(sentry, "server.ftp.kbytes_out = %.0f\n", | |
1713 | stats.server_ftp_kbytes_out); | |
1714 | ||
1715 | storeAppendPrintf(sentry, "server.other.requests = %.0f\n", | |
1716 | stats.server_other_requests); | |
1717 | storeAppendPrintf(sentry, "server.other.errors = %.0f\n", | |
1718 | stats.server_other_errors); | |
1719 | storeAppendPrintf(sentry, "server.other.kbytes_in = %.0f\n", | |
1720 | stats.server_other_kbytes_in); | |
1721 | storeAppendPrintf(sentry, "server.other.kbytes_out = %.0f\n", | |
1722 | stats.server_other_kbytes_out); | |
1723 | ||
1724 | storeAppendPrintf(sentry, "icp.pkts_sent = %.0f\n", | |
1725 | stats.icp_pkts_sent); | |
1726 | storeAppendPrintf(sentry, "icp.pkts_recv = %.0f\n", | |
1727 | stats.icp_pkts_recv); | |
1728 | storeAppendPrintf(sentry, "icp.queries_sent = %.0f\n", | |
1729 | stats.icp_queries_sent); | |
1730 | storeAppendPrintf(sentry, "icp.replies_sent = %.0f\n", | |
1731 | stats.icp_replies_sent); | |
1732 | storeAppendPrintf(sentry, "icp.queries_recv = %.0f\n", | |
1733 | stats.icp_queries_recv); | |
1734 | storeAppendPrintf(sentry, "icp.replies_recv = %.0f\n", | |
1735 | stats.icp_replies_recv); | |
1736 | storeAppendPrintf(sentry, "icp.query_timeouts = %.0f\n", | |
1737 | stats.icp_query_timeouts); | |
1738 | storeAppendPrintf(sentry, "icp.replies_queued = %.0f\n", | |
1739 | stats.icp_replies_queued); | |
1740 | storeAppendPrintf(sentry, "icp.kbytes_sent = %.0f\n", | |
1741 | stats.icp_kbytes_sent); | |
1742 | storeAppendPrintf(sentry, "icp.kbytes_recv = %.0f\n", | |
1743 | stats.icp_kbytes_recv); | |
1744 | storeAppendPrintf(sentry, "icp.q_kbytes_sent = %.0f\n", | |
1745 | stats.icp_q_kbytes_sent); | |
1746 | storeAppendPrintf(sentry, "icp.r_kbytes_sent = %.0f\n", | |
1747 | stats.icp_r_kbytes_sent); | |
1748 | storeAppendPrintf(sentry, "icp.q_kbytes_recv = %.0f\n", | |
1749 | stats.icp_q_kbytes_recv); | |
1750 | storeAppendPrintf(sentry, "icp.r_kbytes_recv = %.0f\n", | |
1751 | stats.icp_r_kbytes_recv); | |
0567f2a6 | 1752 | |
6cfa8966 | 1753 | #if USE_CACHE_DIGESTS |
62e76326 | 1754 | |
8822ebee AR |
1755 | storeAppendPrintf(sentry, "icp.times_used = %.0f\n", |
1756 | stats.icp_times_used); | |
1757 | storeAppendPrintf(sentry, "cd.times_used = %.0f\n", | |
1758 | stats.cd_times_used); | |
1759 | storeAppendPrintf(sentry, "cd.msgs_sent = %.0f\n", | |
1760 | stats.cd_msgs_sent); | |
1761 | storeAppendPrintf(sentry, "cd.msgs_recv = %.0f\n", | |
1762 | stats.cd_msgs_recv); | |
1763 | storeAppendPrintf(sentry, "cd.memory = %.0f\n", | |
1764 | stats.cd_memory); | |
1765 | storeAppendPrintf(sentry, "cd.local_memory = %.0f\n", | |
1766 | stats.cd_local_memory); | |
1767 | storeAppendPrintf(sentry, "cd.kbytes_sent = %.0f\n", | |
1768 | stats.cd_kbytes_sent); | |
1769 | storeAppendPrintf(sentry, "cd.kbytes_recv = %.0f\n", | |
1770 | stats.cd_kbytes_recv); | |
0567f2a6 | 1771 | #endif |
1772 | ||
8822ebee AR |
1773 | storeAppendPrintf(sentry, "unlink.requests = %.0f\n", |
1774 | stats.unlink_requests); | |
1775 | storeAppendPrintf(sentry, "page_faults = %.0f\n", | |
1776 | stats.page_faults); | |
1777 | storeAppendPrintf(sentry, "select_loops = %.0f\n", | |
1778 | stats.select_loops); | |
12cf1be2 | 1779 | storeAppendPrintf(sentry, "cpu_time = %f\n", |
8822ebee | 1780 | stats.cpu_time); |
12cf1be2 | 1781 | storeAppendPrintf(sentry, "wall_time = %f\n", |
8822ebee AR |
1782 | stats.wall_time); |
1783 | storeAppendPrintf(sentry, "swap.outs = %.0f\n", | |
1784 | stats.swap_outs); | |
1785 | storeAppendPrintf(sentry, "swap.ins = %.0f\n", | |
1786 | stats.swap_ins); | |
1787 | storeAppendPrintf(sentry, "swap.files_cleaned = %.0f\n", | |
1788 | stats.swap_files_cleaned); | |
1789 | storeAppendPrintf(sentry, "aborted_requests = %.0f\n", | |
1790 | stats.aborted_requests); | |
7ae52c25 | 1791 | } |
1792 | ||
d2db411c | 1793 | void |
1794 | statFreeMemory(void) | |
1795 | { | |
1796 | int i; | |
62e76326 | 1797 | |
5db6bf73 | 1798 | for (i = 0; i < N_COUNT_HIST; ++i) |
62e76326 | 1799 | statCountersClean(&CountHist[i]); |
1800 | ||
5db6bf73 | 1801 | for (i = 0; i < N_COUNT_HOUR_HIST; ++i) |
62e76326 | 1802 | statCountersClean(&CountHourHist[i]); |
d2db411c | 1803 | } |
1804 | ||
5e29a294 | 1805 | static void |
a1e927f6 | 1806 | statPeerSelect(StoreEntry * sentry) |
1807 | { | |
6cfa8966 | 1808 | #if USE_CACHE_DIGESTS |
83704487 | 1809 | StatCounters *f = &statCounter; |
a1e927f6 | 1810 | peer *peer; |
1811 | const int tot_used = f->cd.times_used + f->icp.times_used; | |
1812 | ||
1813 | /* totals */ | |
1814 | cacheDigestGuessStatsReport(&f->cd.guess, sentry, "all peers"); | |
1815 | /* per-peer */ | |
1816 | storeAppendPrintf(sentry, "\nPer-peer statistics:\n"); | |
62e76326 | 1817 | |
a1e927f6 | 1818 | for (peer = getFirstPeer(); peer; peer = getNextPeer(peer)) { |
62e76326 | 1819 | if (peer->digest) |
1820 | peerDigestStatsReport(peer->digest, sentry); | |
1821 | else | |
1822 | storeAppendPrintf(sentry, "\nNo peer digest from %s\n", peer->host); | |
1823 | ||
1824 | storeAppendPrintf(sentry, "\n"); | |
a1e927f6 | 1825 | } |
1826 | ||
1827 | storeAppendPrintf(sentry, "\nAlgorithm usage:\n"); | |
1828 | storeAppendPrintf(sentry, "Cache Digest: %7d (%3d%%)\n", | |
62e76326 | 1829 | f->cd.times_used, xpercentInt(f->cd.times_used, tot_used)); |
a1e927f6 | 1830 | storeAppendPrintf(sentry, "Icp: %7d (%3d%%)\n", |
62e76326 | 1831 | f->icp.times_used, xpercentInt(f->icp.times_used, tot_used)); |
a1e927f6 | 1832 | storeAppendPrintf(sentry, "Total: %7d (%3d%%)\n", |
62e76326 | 1833 | tot_used, xpercentInt(tot_used, tot_used)); |
a1e927f6 | 1834 | #else |
62e76326 | 1835 | |
a1e927f6 | 1836 | storeAppendPrintf(sentry, "peer digests are disabled; no stats is available.\n"); |
1837 | #endif | |
1838 | } | |
1839 | ||
1840 | static void | |
26b164ac | 1841 | statDigestBlob(StoreEntry * sentry) |
1842 | { | |
071a3ae7 | 1843 | storeAppendPrintf(sentry, "\nCounters:\n"); |
1844 | statCountersDump(sentry); | |
86e2a291 | 1845 | storeAppendPrintf(sentry, "\n5 Min Averages:\n"); |
1846 | statAvgDump(sentry, 5, 0); | |
071a3ae7 | 1847 | storeAppendPrintf(sentry, "\nHistograms:\n"); |
1848 | statCountersHistograms(sentry); | |
1849 | storeAppendPrintf(sentry, "\nPeer Digests:\n"); | |
26b164ac | 1850 | statPeerSelect(sentry); |
588d9545 | 1851 | storeAppendPrintf(sentry, "\nLocal Digest:\n"); |
26b164ac | 1852 | storeDigestReport(sentry); |
1853 | } | |
1854 | ||
7d94ae33 | 1855 | static double |
04a28d46 | 1856 | statPctileSvc(double pctile, int interval, int which) |
a9113eb0 | 1857 | { |
1858 | StatCounters *f; | |
1859 | StatCounters *l; | |
1860 | double x; | |
f8d264b8 | 1861 | assert(interval > 0); |
62e76326 | 1862 | |
f8d264b8 | 1863 | if (interval > N_COUNT_HIST - 1) |
62e76326 | 1864 | interval = N_COUNT_HIST - 1; |
1865 | ||
a9113eb0 | 1866 | f = &CountHist[0]; |
62e76326 | 1867 | |
a9113eb0 | 1868 | l = &CountHist[interval]; |
62e76326 | 1869 | |
ee1679df | 1870 | assert(f); |
62e76326 | 1871 | |
ee1679df | 1872 | assert(l); |
62e76326 | 1873 | |
a9113eb0 | 1874 | switch (which) { |
62e76326 | 1875 | |
04a28d46 | 1876 | case PCTILE_HTTP: |
e8baef82 | 1877 | x = statHistDeltaPctile(l->client_http.allSvcTime,f->client_http.allSvcTime, pctile); |
62e76326 | 1878 | break; |
1879 | ||
04a28d46 | 1880 | case PCTILE_HIT: |
e8baef82 | 1881 | x = statHistDeltaPctile(l->client_http.hitSvcTime,f->client_http.hitSvcTime, pctile); |
62e76326 | 1882 | break; |
1883 | ||
04a28d46 | 1884 | case PCTILE_MISS: |
e8baef82 | 1885 | x = statHistDeltaPctile(l->client_http.missSvcTime,f->client_http.missSvcTime, pctile); |
62e76326 | 1886 | break; |
1887 | ||
04a28d46 | 1888 | case PCTILE_NM: |
e8baef82 | 1889 | x = statHistDeltaPctile(l->client_http.nearMissSvcTime,f->client_http.nearMissSvcTime, pctile); |
62e76326 | 1890 | break; |
1891 | ||
04a28d46 | 1892 | case PCTILE_NH: |
e8baef82 | 1893 | x = statHistDeltaPctile(l->client_http.nearHitSvcTime,f->client_http.nearHitSvcTime, pctile); |
62e76326 | 1894 | break; |
1895 | ||
04a28d46 | 1896 | case PCTILE_ICP_QUERY: |
e8baef82 | 1897 | x = statHistDeltaPctile(l->icp.querySvcTime,f->icp.querySvcTime, pctile); |
62e76326 | 1898 | break; |
1899 | ||
04a28d46 | 1900 | case PCTILE_DNS: |
e8baef82 | 1901 | x = statHistDeltaPctile(l->dns.svcTime,f->dns.svcTime, pctile); |
62e76326 | 1902 | break; |
1903 | ||
a9113eb0 | 1904 | default: |
bf8fe701 | 1905 | debugs(49, 5, "statPctileSvc: unknown type."); |
62e76326 | 1906 | x = 0; |
a9113eb0 | 1907 | } |
62e76326 | 1908 | |
b87b92fb | 1909 | return x; |
1910 | } | |
1911 | ||
451b07c5 | 1912 | StatCounters * |
1913 | snmpStatGet(int minutes) | |
1914 | { | |
2ac76861 | 1915 | return &CountHist[minutes]; |
451b07c5 | 1916 | } |
01aebf31 | 1917 | |
1f3c4622 | 1918 | int |
1919 | stat5minClientRequests(void) | |
1920 | { | |
5999b776 | 1921 | assert(N_COUNT_HIST > 5); |
83704487 | 1922 | return statCounter.client_http.requests - CountHist[5].client_http.requests; |
1f3c4622 | 1923 | } |
1924 | ||
49ad0a8c | 1925 | static double |
1926 | statCPUUsage(int minutes) | |
979533fa | 1927 | { |
49ad0a8c | 1928 | assert(minutes < N_COUNT_HIST); |
a98bcbee | 1929 | return Math::doublePercent(CountHist[0].cputime - CountHist[minutes].cputime, |
f9afa4fb | 1930 | tvSubDsec(CountHist[minutes].timestamp, CountHist[0].timestamp)); |
979533fa | 1931 | } |
01aebf31 | 1932 | |
1d5b6d43 | 1933 | extern double |
e1381638 | 1934 | statRequestHitRatio(int minutes) |
491a980b | 1935 | { |
1936 | assert(minutes < N_COUNT_HIST); | |
a98bcbee | 1937 | return Math::doublePercent(CountHist[0].client_http.hits - |
f9afa4fb A |
1938 | CountHist[minutes].client_http.hits, |
1939 | CountHist[0].client_http.requests - | |
1940 | CountHist[minutes].client_http.requests); | |
491a980b | 1941 | } |
1942 | ||
4f4d1d6e | 1943 | extern double |
e1381638 | 1944 | statRequestHitMemoryRatio(int minutes) |
4f4d1d6e | 1945 | { |
1946 | assert(minutes < N_COUNT_HIST); | |
a98bcbee | 1947 | return Math::doublePercent(CountHist[0].client_http.mem_hits - |
f9afa4fb A |
1948 | CountHist[minutes].client_http.mem_hits, |
1949 | CountHist[0].client_http.hits - | |
1950 | CountHist[minutes].client_http.hits); | |
4f4d1d6e | 1951 | } |
1952 | ||
1953 | extern double | |
e1381638 | 1954 | statRequestHitDiskRatio(int minutes) |
4f4d1d6e | 1955 | { |
1956 | assert(minutes < N_COUNT_HIST); | |
a98bcbee | 1957 | return Math::doublePercent(CountHist[0].client_http.disk_hits - |
f9afa4fb A |
1958 | CountHist[minutes].client_http.disk_hits, |
1959 | CountHist[0].client_http.hits - | |
1960 | CountHist[minutes].client_http.hits); | |
4f4d1d6e | 1961 | } |
1962 | ||
1d5b6d43 | 1963 | extern double |
e1381638 | 1964 | statByteHitRatio(int minutes) |
491a980b | 1965 | { |
1966 | size_t s; | |
1967 | size_t c; | |
ac342231 | 1968 | #if USE_CACHE_DIGESTS |
62e76326 | 1969 | |
ac342231 | 1970 | size_t cd; |
1971 | #endif | |
1972 | /* size_t might be unsigned */ | |
491a980b | 1973 | assert(minutes < N_COUNT_HIST); |
1974 | c = CountHist[0].client_http.kbytes_out.kb - CountHist[minutes].client_http.kbytes_out.kb; | |
1975 | s = CountHist[0].server.all.kbytes_in.kb - CountHist[minutes].server.all.kbytes_in.kb; | |
ac342231 | 1976 | #if USE_CACHE_DIGESTS |
1977 | /* | |
1978 | * This ugly hack is here to prevent the user from seeing a | |
1979 | * negative byte hit ratio. When we fetch a cache digest from | |
1980 | * a neighbor, it gets treated like a cache miss because the | |
1981 | * object is consumed internally. Thus, we subtract cache | |
1982 | * digest bytes out before calculating the byte hit ratio. | |
1983 | */ | |
1984 | cd = CountHist[0].cd.kbytes_recv.kb - CountHist[minutes].cd.kbytes_recv.kb; | |
62e76326 | 1985 | |
49d7ce5f | 1986 | if (s < cd) |
e0236918 | 1987 | debugs(18, DBG_IMPORTANT, "STRANGE: srv_kbytes=" << s << ", cd_kbytes=" << cd); |
62e76326 | 1988 | |
ac342231 | 1989 | s -= cd; |
62e76326 | 1990 | |
ac342231 | 1991 | #endif |
62e76326 | 1992 | |
94e56ef7 | 1993 | if (c > s) |
a98bcbee | 1994 | return Math::doublePercent(c - s, c); |
94e56ef7 | 1995 | else |
a98bcbee | 1996 | return (-1.0 * Math::doublePercent(s - c, c)); |
491a980b | 1997 | } |
1998 | ||
0f1bc304 | 1999 | static void |
2000 | statClientRequests(StoreEntry * s) | |
2001 | { | |
2002 | dlink_node *i; | |
59a1efb2 | 2003 | ClientHttpRequest *http; |
0f1bc304 | 2004 | StoreEntry *e; |
cc192b50 | 2005 | char buf[MAX_IPSTRLEN]; |
62e76326 | 2006 | |
0f1bc304 | 2007 | for (i = ClientActiveRequests.head; i; i = i->next) { |
f4bd6296 | 2008 | const char *p = NULL; |
59a1efb2 | 2009 | http = static_cast<ClientHttpRequest *>(i->data); |
62e76326 | 2010 | assert(http); |
9512de47 | 2011 | ConnStateData * conn = http->getConn(); |
2012 | storeAppendPrintf(s, "Connection: %p\n", conn); | |
62e76326 | 2013 | |
85a4b153 | 2014 | if (conn != NULL) { |
73c36fd9 | 2015 | const int fd = conn->clientConnection->fd; |
c91ca3ce | 2016 | storeAppendPrintf(s, "\tFD %d, read %" PRId64 ", wrote %" PRId64 "\n", fd, |
62e76326 | 2017 | fd_table[fd].bytes_read, fd_table[fd].bytes_written); |
2018 | storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc); | |
2019 | storeAppendPrintf(s, "\tin: buf %p, offset %ld, size %ld\n", | |
2020 | conn->in.buf, (long int) conn->in.notYetUsed, (long int) conn->in.allocatedSize); | |
be364179 | 2021 | storeAppendPrintf(s, "\tremote: %s\n", |
73c36fd9 | 2022 | conn->clientConnection->remote.ToURL(buf,MAX_IPSTRLEN)); |
be364179 | 2023 | storeAppendPrintf(s, "\tlocal: %s\n", |
73c36fd9 | 2024 | conn->clientConnection->local.ToURL(buf,MAX_IPSTRLEN)); |
62e76326 | 2025 | storeAppendPrintf(s, "\tnrequests: %d\n", |
2026 | conn->nrequests); | |
62e76326 | 2027 | } |
2028 | ||
2029 | storeAppendPrintf(s, "uri %s\n", http->uri); | |
38e16f92 | 2030 | storeAppendPrintf(s, "logType %s\n", Format::log_tags[http->logType]); |
62e76326 | 2031 | storeAppendPrintf(s, "out.offset %ld, out.size %lu\n", |
2032 | (long int) http->out.offset, (unsigned long int) http->out.size); | |
2033 | storeAppendPrintf(s, "req_sz %ld\n", (long int) http->req_sz); | |
86a2f789 | 2034 | e = http->storeEntry(); |
62e76326 | 2035 | storeAppendPrintf(s, "entry %p/%s\n", e, e ? e->getMD5Text() : "N/A"); |
0655fa4d | 2036 | #if 0 |
2037 | /* Not a member anymore */ | |
62e76326 | 2038 | e = http->old_entry; |
2039 | storeAppendPrintf(s, "old_entry %p/%s\n", e, e ? e->getMD5Text() : "N/A"); | |
0655fa4d | 2040 | #endif |
2041 | ||
62e76326 | 2042 | storeAppendPrintf(s, "start %ld.%06d (%f seconds ago)\n", |
9512de47 | 2043 | (long int) http->start_time.tv_sec, |
2044 | (int) http->start_time.tv_usec, | |
2045 | tvSubDsec(http->start_time, current_time)); | |
2f1431ea | 2046 | #if USE_AUTH |
a33a428a | 2047 | if (http->request->auth_user_request != NULL) |
d3f603c8 | 2048 | p = http->request->auth_user_request->username(); |
2f1431ea AJ |
2049 | else |
2050 | #endif | |
74174c03 A |
2051 | if (http->request->extacl_user.defined()) { |
2052 | p = http->request->extacl_user.termedBuf(); | |
2053 | } | |
d3f603c8 | 2054 | |
73c36fd9 AJ |
2055 | if (!p && conn != NULL && conn->clientConnection->rfc931[0]) |
2056 | p = conn->clientConnection->rfc931; | |
d3f603c8 | 2057 | |
f4bd6296 | 2058 | #if USE_SSL |
2059 | ||
73c36fd9 AJ |
2060 | if (!p && conn != NULL && Comm::IsConnOpen(conn->clientConnection)) |
2061 | p = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl); | |
f4bd6296 | 2062 | |
2063 | #endif | |
2064 | ||
2065 | if (!p) | |
2066 | p = dash_str; | |
2067 | ||
2068 | storeAppendPrintf(s, "username %s\n", p); | |
d3f603c8 | 2069 | |
9a0a18de | 2070 | #if USE_DELAY_POOLS |
65a29f29 | 2071 | storeAppendPrintf(s, "delay_pool %d\n", DelayId::DelayClient(http).pool()); |
8faa78e6 | 2072 | #endif |
2073 | ||
62e76326 | 2074 | storeAppendPrintf(s, "\n"); |
0f1bc304 | 2075 | } |
2076 | } | |
2077 | ||
01aebf31 | 2078 | #if STAT_GRAPHS |
2079 | /* | |
2080 | * urgh, i don't like these, but they do cut the amount of code down immensely | |
2081 | */ | |
2082 | ||
2083 | #define GRAPH_PER_MIN(Y) \ | |
5db6bf73 | 2084 | for (i=0;i<(N_COUNT_HIST-2);++i) { \ |
79d15b05 | 2085 | dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \ |
01aebf31 | 2086 | if (dt <= 0.0) \ |
2087 | break; \ | |
2088 | storeAppendPrintf(e, "%lu,%0.2f:", \ | |
2089 | CountHist[i].timestamp.tv_sec, \ | |
2090 | ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \ | |
2091 | } | |
2092 | ||
2093 | #define GRAPH_PER_HOUR(Y) \ | |
5db6bf73 | 2094 | for (i=0;i<(N_COUNT_HOUR_HIST-2);++i) { \ |
79d15b05 | 2095 | dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \ |
01aebf31 | 2096 | if (dt <= 0.0) \ |
2097 | break; \ | |
2098 | storeAppendPrintf(e, "%lu,%0.2f:", \ | |
2099 | CountHourHist[i].timestamp.tv_sec, \ | |
2100 | ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \ | |
2101 | } | |
2102 | ||
2103 | #define GRAPH_TITLE(X,Y) storeAppendPrintf(e,"%s\t%s\t",X,Y); | |
2104 | #define GRAPH_END storeAppendPrintf(e,"\n"); | |
2105 | ||
2106 | #define GENGRAPH(X,Y,Z) \ | |
2107 | GRAPH_TITLE(Y,Z) \ | |
2108 | GRAPH_PER_MIN(X) \ | |
2109 | GRAPH_PER_HOUR(X) \ | |
2110 | GRAPH_END | |
2111 | ||
2112 | static void | |
2113 | statGraphDump(StoreEntry * e) | |
2114 | { | |
2115 | int i; | |
2116 | double dt; | |
2117 | ||
2118 | GENGRAPH(client_http.requests, "client_http.requests", "Client HTTP requests/sec"); | |
2119 | GENGRAPH(client_http.hits, "client_http.hits", "Client HTTP hits/sec"); | |
2120 | GENGRAPH(client_http.errors, "client_http.errors", "Client HTTP errors/sec"); | |
2121 | GENGRAPH(client_http.kbytes_in.kb, "client_http.kbytes_in", "Client HTTP kbytes_in/sec"); | |
2122 | GENGRAPH(client_http.kbytes_out.kb, "client_http.kbytes_out", "Client HTTP kbytes_out/sec"); | |
2123 | ||
2124 | /* XXX todo: http median service times */ | |
2125 | ||
2126 | GENGRAPH(server.all.requests, "server.all.requests", "Server requests/sec"); | |
2127 | GENGRAPH(server.all.errors, "server.all.errors", "Server errors/sec"); | |
2128 | GENGRAPH(server.all.kbytes_in.kb, "server.all.kbytes_in", "Server total kbytes_in/sec"); | |
2129 | GENGRAPH(server.all.kbytes_out.kb, "server.all.kbytes_out", "Server total kbytes_out/sec"); | |
2130 | ||
2131 | GENGRAPH(server.http.requests, "server.http.requests", "Server HTTP requests/sec"); | |
2132 | GENGRAPH(server.http.errors, "server.http.errors", "Server HTTP errors/sec"); | |
2133 | GENGRAPH(server.http.kbytes_in.kb, "server.http.kbytes_in", "Server HTTP kbytes_in/sec"); | |
2134 | GENGRAPH(server.http.kbytes_out.kb, "server.http.kbytes_out", "Server HTTP kbytes_out/sec"); | |
2135 | ||
2136 | GENGRAPH(server.ftp.requests, "server.ftp.requests", "Server FTP requests/sec"); | |
2137 | GENGRAPH(server.ftp.errors, "server.ftp.errors", "Server FTP errors/sec"); | |
2138 | GENGRAPH(server.ftp.kbytes_in.kb, "server.ftp.kbytes_in", "Server FTP kbytes_in/sec"); | |
2139 | GENGRAPH(server.ftp.kbytes_out.kb, "server.ftp.kbytes_out", "Server FTP kbytes_out/sec"); | |
2140 | ||
2141 | GENGRAPH(server.other.requests, "server.other.requests", "Server other requests/sec"); | |
2142 | GENGRAPH(server.other.errors, "server.other.errors", "Server other errors/sec"); | |
2143 | GENGRAPH(server.other.kbytes_in.kb, "server.other.kbytes_in", "Server other kbytes_in/sec"); | |
2144 | GENGRAPH(server.other.kbytes_out.kb, "server.other.kbytes_out", "Server other kbytes_out/sec"); | |
2145 | ||
2146 | GENGRAPH(icp.pkts_sent, "icp.pkts_sent", "ICP packets sent/sec"); | |
2147 | GENGRAPH(icp.pkts_recv, "icp.pkts_recv", "ICP packets received/sec"); | |
2148 | GENGRAPH(icp.kbytes_sent.kb, "icp.kbytes_sent", "ICP kbytes_sent/sec"); | |
2149 | GENGRAPH(icp.kbytes_recv.kb, "icp.kbytes_recv", "ICP kbytes_received/sec"); | |
2150 | ||
2151 | /* XXX todo: icp median service times */ | |
2152 | /* XXX todo: dns median service times */ | |
2153 | ||
2154 | GENGRAPH(unlink.requests, "unlink.requests", "Cache File unlink requests/sec"); | |
2155 | GENGRAPH(page_faults, "page_faults", "System Page Faults/sec"); | |
2156 | GENGRAPH(select_loops, "select_loops", "System Select Loop calls/sec"); | |
2157 | GENGRAPH(cputime, "cputime", "CPU utilisation"); | |
2158 | } | |
1afe05c5 | 2159 | |
d96ceb8e | 2160 | #endif /* STAT_GRAPHS */ |
2161 | ||
2d72d4fd | 2162 | int |
2163 | statMemoryAccounted(void) | |
2164 | { | |
d96ceb8e | 2165 | return memPoolsTotalAllocated(); |
2d72d4fd | 2166 | } |