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