stat.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 18 Cache Manager Statistics */
10 
11 #include "squid.h"
12 #include "AccessLogEntry.h"
13 #include "CacheDigest.h"
14 #include "CachePeer.h"
15 #include "client_side.h"
16 #include "client_side_request.h"
17 #include "comm/Connection.h"
18 #include "comm/Loops.h"
19 #include "event.h"
20 #include "fde.h"
21 #include "format/Token.h"
22 #include "globals.h"
23 #include "http/Stream.h"
24 #include "HttpRequest.h"
25 #include "IoStats.h"
26 #include "mem/Pool.h"
27 #include "mem_node.h"
28 #include "MemBuf.h"
29 #include "MemObject.h"
30 #include "mgr/CountersAction.h"
31 #include "mgr/FunAction.h"
32 #include "mgr/InfoAction.h"
33 #include "mgr/IntervalAction.h"
34 #include "mgr/IoAction.h"
35 #include "mgr/Registration.h"
36 #include "mgr/ServiceTimesAction.h"
37 #include "neighbors.h"
38 #include "PeerDigest.h"
39 #include "SquidConfig.h"
40 #include "SquidMath.h"
41 #include "stat.h"
42 #include "StatCounters.h"
43 #include "Store.h"
44 #include "store_digest.h"
45 #include "StoreClient.h"
46 #include "tools.h"
47 #if USE_AUTH
48 #include "auth/UserRequest.h"
49 #endif
50 #if USE_DELAY_POOLS
51 #include "DelayId.h"
52 #endif
53 #if USE_OPENSSL
54 #include "ssl/support.h"
55 #endif
56 
57 /* these are included because they expose stats calls */
58 /* TODO: provide a self registration mechanism for those classes
59  * to use during static construction
60  */
61 #include "comm.h"
62 #include "StoreSearch.h"
63 
64 typedef int STOBJFLT(const StoreEntry *);
65 
67 {
69 
70 public:
74 };
75 
76 /* LOCALS */
77 static const char *describeStatuses(const StoreEntry *);
78 static void statAvgTick(void *notused);
79 static void statAvgDump(StoreEntry *, int minutes, int hours);
80 #if STAT_GRAPHS
81 static void statGraphDump(StoreEntry *);
82 #endif
83 static double statPctileSvc(double, int, int);
84 static void statStoreEntry(MemBuf * mb, StoreEntry * e);
85 static double statCPUUsage(int minutes);
96 void GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours);
100 void DumpMallocStatistics(StoreEntry* sentry);
107 
108 #if XMALLOC_STATISTICS
109 static void info_get_mallstat(int, int, int, void *);
110 static double xm_time;
111 static double xm_deltat;
112 #endif
113 
115 static int NCountHist = 0;
117 static int NCountHourHist = 0;
119 
120 extern unsigned int mem_pool_alloc_calls;
121 extern unsigned int mem_pool_free_calls;
122 
123 static void
125 {
126  storeAppendPrintf(e, "Cache Utilisation:\n");
127  storeAppendPrintf(e, "\n");
128  storeAppendPrintf(e, "Last 5 minutes:\n");
129 
130  if (NCountHist >= 5)
131  statAvgDump(e, 5, 0);
132  else
133  storeAppendPrintf(e, "(no values recorded yet)\n");
134 
135  storeAppendPrintf(e, "\n");
136 
137  storeAppendPrintf(e, "Last 15 minutes:\n");
138 
139  if (NCountHist >= 15)
140  statAvgDump(e, 15, 0);
141  else
142  storeAppendPrintf(e, "(no values recorded yet)\n");
143 
144  storeAppendPrintf(e, "\n");
145 
146  storeAppendPrintf(e, "Last hour:\n");
147 
148  if (NCountHist >= 60)
149  statAvgDump(e, 60, 0);
150  else
151  storeAppendPrintf(e, "(no values recorded yet)\n");
152 
153  storeAppendPrintf(e, "\n");
154 
155  storeAppendPrintf(e, "Last 8 hours:\n");
156 
157  if (NCountHourHist >= 8)
158  statAvgDump(e, 0, 8);
159  else
160  storeAppendPrintf(e, "(no values recorded yet)\n");
161 
162  storeAppendPrintf(e, "\n");
163 
164  storeAppendPrintf(e, "Last day:\n");
165 
166  if (NCountHourHist >= 24)
167  statAvgDump(e, 0, 24);
168  else
169  storeAppendPrintf(e, "(no values recorded yet)\n");
170 
171  storeAppendPrintf(e, "\n");
172 
173  storeAppendPrintf(e, "Last 3 days:\n");
174 
175  if (NCountHourHist >= 72)
176  statAvgDump(e, 0, 72);
177  else
178  storeAppendPrintf(e, "(no values recorded yet)\n");
179 
180  storeAppendPrintf(e, "\n");
181 
182  storeAppendPrintf(e, "Totals since cache startup:\n");
183 
184  statCountersDump(e);
185 }
186 
187 void
189 {
190  int i;
191 
192  stats.http_reads = IOStats.Http.reads;
193 
194  for (i = 0; i < IoStats::histSize; ++i) {
195  stats.http_read_hist[i] = IOStats.Http.read_hist[i];
196  }
197 
198  stats.ftp_reads = IOStats.Ftp.reads;
199 
200  for (i = 0; i < IoStats::histSize; ++i) {
201  stats.ftp_read_hist[i] = IOStats.Ftp.read_hist[i];
202  }
203 
204  stats.gopher_reads = IOStats.Gopher.reads;
205 
206  for (i = 0; i < IoStats::histSize; ++i) {
207  stats.gopher_read_hist[i] = IOStats.Gopher.read_hist[i];
208  }
209 }
210 
211 void
213 {
214  int i;
215 
216  storeAppendPrintf(sentry, "HTTP I/O\n");
217  storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.http_reads);
218  storeAppendPrintf(sentry, "Read Histogram:\n");
219 
220  for (i = 0; i < IoStats::histSize; ++i) {
221  storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n",
222  i ? (1 << (i - 1)) + 1 : 1,
223  1 << i,
224  stats.http_read_hist[i],
225  Math::doublePercent(stats.http_read_hist[i], stats.http_reads));
226  }
227 
228  storeAppendPrintf(sentry, "\n");
229  storeAppendPrintf(sentry, "FTP I/O\n");
230  storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.ftp_reads);
231  storeAppendPrintf(sentry, "Read Histogram:\n");
232 
233  for (i = 0; i < IoStats::histSize; ++i) {
234  storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n",
235  i ? (1 << (i - 1)) + 1 : 1,
236  1 << i,
237  stats.ftp_read_hist[i],
238  Math::doublePercent(stats.ftp_read_hist[i], stats.ftp_reads));
239  }
240 
241  storeAppendPrintf(sentry, "\n");
242  storeAppendPrintf(sentry, "Gopher I/O\n");
243  storeAppendPrintf(sentry, "number of reads: %.0f\n", stats.gopher_reads);
244  storeAppendPrintf(sentry, "Read Histogram:\n");
245 
246  for (i = 0; i < IoStats::histSize; ++i) {
247  storeAppendPrintf(sentry, "%5d-%5d: %9.0f %2.0f%%\n",
248  i ? (1 << (i - 1)) + 1 : 1,
249  1 << i,
250  stats.gopher_read_hist[i],
251  Math::doublePercent(stats.gopher_read_hist[i], stats.gopher_reads));
252  }
253 
254  storeAppendPrintf(sentry, "\n");
255 }
256 
257 static const char *
259 {
260  LOCAL_ARRAY(char, buf, 256);
261  snprintf(buf, 256, "%-13s %-13s %-12s %-12s",
263  memStatusStr[entry->mem_status],
264  swapStatusStr[entry->swap_status],
265  pingStatusStr[entry->ping_status]);
266  return buf;
267 }
268 
269 const char *
271 {
272  LOCAL_ARRAY(char, buf, 256);
273  int flags = (int) entry->flags;
274  char *t;
275  buf[0] = '\0';
276 
277  if (EBIT_TEST(flags, ENTRY_SPECIAL))
278  strcat(buf, "SPECIAL,");
279 
281  strcat(buf, "REVALIDATE_ALWAYS,");
282 
283  if (EBIT_TEST(flags, DELAY_SENDING))
284  strcat(buf, "DELAY_SENDING,");
285 
286  if (EBIT_TEST(flags, RELEASE_REQUEST))
287  strcat(buf, "RELEASE_REQUEST,");
288 
289  if (EBIT_TEST(flags, REFRESH_REQUEST))
290  strcat(buf, "REFRESH_REQUEST,");
291 
292  if (EBIT_TEST(flags, ENTRY_REVALIDATE_STALE))
293  strcat(buf, "REVALIDATE_STALE,");
294 
295  if (EBIT_TEST(flags, ENTRY_DISPATCHED))
296  strcat(buf, "DISPATCHED,");
297 
298  if (EBIT_TEST(flags, KEY_PRIVATE))
299  strcat(buf, "PRIVATE,");
300 
301  if (EBIT_TEST(flags, ENTRY_FWD_HDR_WAIT))
302  strcat(buf, "FWD_HDR_WAIT,");
303 
304  if (EBIT_TEST(flags, ENTRY_NEGCACHED))
305  strcat(buf, "NEGCACHED,");
306 
307  if (EBIT_TEST(flags, ENTRY_VALIDATED))
308  strcat(buf, "VALIDATED,");
309 
310  if (EBIT_TEST(flags, ENTRY_BAD_LENGTH))
311  strcat(buf, "BAD_LENGTH,");
312 
313  if (EBIT_TEST(flags, ENTRY_ABORTED))
314  strcat(buf, "ABORTED,");
315 
316  if ((t = strrchr(buf, ',')))
317  *t = '\0';
318 
319  return buf;
320 }
321 
322 static void
324 {
325  MemObject *mem = e->mem_obj;
326  mb->appendf("KEY %s\n", e->getMD5Text());
327  mb->appendf("\t%s\n", describeStatuses(e));
328  mb->appendf("\t%s\n", storeEntryFlags(e));
329  mb->appendf("\t%s\n", e->describeTimestamps());
330  mb->appendf("\t%d locks, %d clients, %d refs\n", (int) e->locks(), storePendingNClients(e), (int) e->refcount);
331  mb->appendf("\tSwap Dir %d, File %#08X\n", e->swap_dirn, e->swap_filen);
332 
333  if (mem != NULL)
334  mem->stat (mb);
335 
336  mb->append("\n", 1);
337 }
338 
339 /* process objects list */
340 static void
341 statObjects(void *data)
342 {
343  StatObjectsState *state = static_cast<StatObjectsState *>(data);
344  StoreEntry *e;
345 
346  if (state->theSearch->isDone()) {
347  if (UsingSmp())
348  storeAppendPrintf(state->sentry, "} by kid%d\n\n", KidIdentifier);
349  state->sentry->complete();
350  state->sentry->unlock("statObjects+isDone");
351  delete state;
352  return;
353  } else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) {
354  state->sentry->unlock("statObjects+aborted");
355  delete state;
356  return;
357  } else if (state->sentry->checkDeferRead(-1)) {
358  state->sentry->flush();
359  eventAdd("statObjects", statObjects, state, 0.1, 1);
360  return;
361  }
362 
363  state->sentry->buffer();
364  size_t statCount = 0;
365  MemBuf mb;
366  mb.init();
367 
368  while (statCount++ < static_cast<size_t>(Config.Store.objectsPerBucket) && state->
369  theSearch->next()) {
370  e = state->theSearch->currentItem();
371 
372  if (state->filter && 0 == state->filter(e))
373  continue;
374 
375  statStoreEntry(&mb, e);
376  }
377 
378  if (mb.size)
379  state->sentry->append(mb.buf, mb.size);
380  mb.clean();
381 
382  eventAdd("statObjects", statObjects, state, 0.0, 1);
383 }
384 
385 static void
387 {
388  StatObjectsState *state = new StatObjectsState;
389  state->sentry = sentry;
390  state->filter = filter;
391 
392  sentry->lock("statObjects");
393  state->theSearch = Store::Root().search();
394 
395  eventAdd("statObjects", statObjects, state, 0.0, 1);
396 }
397 
398 static void
400 {
401  statObjectsStart(sentry, NULL);
402 }
403 
404 static int
406 {
407  return e->mem_obj ? 1 : 0;
408 }
409 
410 static void
412 {
414 }
415 
416 static int
418 {
419  if (e->mem_obj == NULL)
420  return 0;
421 
422  if (e->mem_obj->swapout.sio == NULL)
423  return 0;
424 
425  return 1;
426 }
427 
428 static void
430 {
432 }
433 
434 #if XMALLOC_STATISTICS
435 static void
436 info_get_mallstat(int size, int number, int oldnum, void *data)
437 {
438  StoreEntry *sentry = (StoreEntry *)data;
439 
440 // format: "%12s %15s %6s %12s\n","Alloc Size","Count","Delta","Alloc/sec"
441  if (number > 0)
442  storeAppendPrintf(sentry, "%12d %15d %6d %.1f\n", size, number, number - oldnum, xdiv((number - oldnum), xm_deltat));
443 }
444 
445 #endif
446 
447 void
449 {
450 
451  struct rusage rusage;
452  double cputime;
453  double runtime;
454 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
455  struct mstats ms;
456 #endif
457 
458  runtime = tvSubDsec(squid_start, current_time);
459 
460  if (runtime == 0.0)
461  runtime = 1.0;
462 
463  stats.squid_start = squid_start;
464 
465  stats.current_time = current_time;
466 
467  stats.client_http_clients = statCounter.client_http.clients;
468 
469  stats.client_http_requests = statCounter.client_http.requests;
470 
471  stats.icp_pkts_recv = statCounter.icp.pkts_recv;
472 
473  stats.icp_pkts_sent = statCounter.icp.pkts_sent;
474 
475  stats.icp_replies_queued = statCounter.icp.replies_queued;
476 
477 #if USE_HTCP
478 
479  stats.htcp_pkts_recv = statCounter.htcp.pkts_recv;
480 
481  stats.htcp_pkts_sent = statCounter.htcp.pkts_sent;
482 
483 #endif
484 
485  stats.request_failure_ratio = request_failure_ratio;
486 
487  stats.avg_client_http_requests = statCounter.client_http.requests / (runtime / 60.0);
488 
489  stats.avg_icp_messages = (statCounter.icp.pkts_sent + statCounter.icp.pkts_recv) / (runtime / 60.0);
490 
491  stats.select_loops = statCounter.select_loops;
492  stats.avg_loop_time = 1000.0 * runtime / statCounter.select_loops;
493 
494  stats.request_hit_ratio5 = statRequestHitRatio(5);
495  stats.request_hit_ratio60 = statRequestHitRatio(60);
496 
497  stats.byte_hit_ratio5 = statByteHitRatio(5);
498  stats.byte_hit_ratio60 = statByteHitRatio(60);
499 
500  stats.request_hit_mem_ratio5 = statRequestHitMemoryRatio(5);
501  stats.request_hit_mem_ratio60 = statRequestHitMemoryRatio(60);
502 
503  stats.request_hit_disk_ratio5 = statRequestHitDiskRatio(5);
504  stats.request_hit_disk_ratio60 = statRequestHitDiskRatio(60);
505 
506  Store::Root().getStats(stats.store);
507 
508  stats.unlink_requests = statCounter.unlink.requests;
509 
510  stats.http_requests5 = statPctileSvc(0.5, 5, PCTILE_HTTP);
511  stats.http_requests60 = statPctileSvc(0.5, 60, PCTILE_HTTP);
512 
513  stats.cache_misses5 = statPctileSvc(0.5, 5, PCTILE_MISS);
514  stats.cache_misses60 = statPctileSvc(0.5, 60, PCTILE_MISS);
515 
516  stats.cache_hits5 = statPctileSvc(0.5, 5, PCTILE_HIT);
517  stats.cache_hits60 = statPctileSvc(0.5, 60, PCTILE_HIT);
518 
519  stats.near_hits5 = statPctileSvc(0.5, 5, PCTILE_NH);
520  stats.near_hits60 = statPctileSvc(0.5, 60, PCTILE_NH);
521 
522  stats.not_modified_replies5 = statPctileSvc(0.5, 5, PCTILE_NM);
523  stats.not_modified_replies60 = statPctileSvc(0.5, 60, PCTILE_NM);
524 
525  stats.dns_lookups5 = statPctileSvc(0.5, 5, PCTILE_DNS);
526  stats.dns_lookups60 = statPctileSvc(0.5, 60, PCTILE_DNS);
527 
528  stats.icp_queries5 = statPctileSvc(0.5, 5, PCTILE_ICP_QUERY);
529  stats.icp_queries60 = statPctileSvc(0.5, 60, PCTILE_ICP_QUERY);
530 
532  cputime = rusage_cputime(&rusage);
533 
534  stats.up_time = runtime;
535  stats.cpu_time = cputime;
536  stats.cpu_usage = Math::doublePercent(cputime, runtime);
537  stats.cpu_usage5 = statCPUUsage(5);
538  stats.cpu_usage60 = statCPUUsage(60);
539 
540  stats.maxrss = rusage_maxrss(&rusage);
541 
542  stats.page_faults = rusage_pagefaults(&rusage);
543 
544 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
545 
546  ms = mstats();
547 
548  stats.ms_bytes_total = ms.bytes_total;
549 
550  stats.ms_bytes_free = ms.bytes_free;
551 
552 #endif
553 
554  stats.total_accounted = statMemoryAccounted();
555 
556  {
557  MemPoolGlobalStats mp_stats;
558  memPoolGetGlobalStats(&mp_stats);
559  stats.gb_saved_count = mp_stats.TheMeter->gb_saved.count;
560  stats.gb_freed_count = mp_stats.TheMeter->gb_freed.count;
561  }
562 
563  stats.max_fd = Squid_MaxFD;
564  stats.biggest_fd = Biggest_FD;
565  stats.number_fd = Number_FD;
566  stats.opening_fd = Opening_FD;
567  stats.num_fd_free = fdNFree();
568  stats.reserved_fd = RESERVED_FD;
569 }
570 
571 void
573 {
574  storeAppendPrintf(sentry, "Squid Object Cache: Version %s\n",
576 
577  storeAppendPrintf(sentry, "Build Info: " SQUID_BUILD_INFO "\n");
578 
579 #if _SQUID_WINDOWS_
580  if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
581  storeAppendPrintf(sentry,"\nRunning as " SQUIDSBUFPH " Windows System Service on %s\n",
582  SQUIDSBUFPRINT(service_name), WIN32_OS_string);
583  storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line);
584  } else
585  storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string);
586 #else
587  storeAppendPrintf(sentry,"Service Name: " SQUIDSBUFPH "\n", SQUIDSBUFPRINT(service_name));
588 #endif
589 
590  storeAppendPrintf(sentry, "Start Time:\t%s\n",
591  Time::FormatRfc1123(stats.squid_start.tv_sec));
592 
593  storeAppendPrintf(sentry, "Current Time:\t%s\n",
594  Time::FormatRfc1123(stats.current_time.tv_sec));
595 
596  storeAppendPrintf(sentry, "Connection information for %s:\n",APP_SHORTNAME);
597 
598  if (Config.onoff.client_db)
599  storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%.0f\n", stats.client_http_clients);
600  else
601  sentry->append("\tNumber of clients accessing cache:\t(client_db off)\n", 52);
602 
603  storeAppendPrintf(sentry, "\tNumber of HTTP requests received:\t%.0f\n",
604  stats.client_http_requests);
605 
606  storeAppendPrintf(sentry, "\tNumber of ICP messages received:\t%.0f\n",
607  stats.icp_pkts_recv);
608 
609  storeAppendPrintf(sentry, "\tNumber of ICP messages sent:\t%.0f\n",
610  stats.icp_pkts_sent);
611 
612  storeAppendPrintf(sentry, "\tNumber of queued ICP replies:\t%.0f\n",
613  stats.icp_replies_queued);
614 
615 #if USE_HTCP
616 
617  storeAppendPrintf(sentry, "\tNumber of HTCP messages received:\t%.0f\n",
618  stats.htcp_pkts_recv);
619 
620  storeAppendPrintf(sentry, "\tNumber of HTCP messages sent:\t%.0f\n",
621  stats.htcp_pkts_sent);
622 
623 #endif
624 
625  double fct = stats.count > 1 ? stats.count : 1.0;
626  storeAppendPrintf(sentry, "\tRequest failure ratio:\t%5.2f\n",
627  stats.request_failure_ratio / fct);
628 
629  storeAppendPrintf(sentry, "\tAverage HTTP requests per minute since start:\t%.1f\n",
630  stats.avg_client_http_requests);
631 
632  storeAppendPrintf(sentry, "\tAverage ICP messages per minute since start:\t%.1f\n",
633  stats.avg_icp_messages);
634 
635  storeAppendPrintf(sentry, "\tSelect loop called: %.0f times, %0.3f ms avg\n",
636  stats.select_loops, stats.avg_loop_time / fct);
637 
638  storeAppendPrintf(sentry, "Cache information for %s:\n",APP_SHORTNAME);
639 
640  storeAppendPrintf(sentry, "\tHits as %% of all requests:\t5min: %3.1f%%, 60min: %3.1f%%\n",
641  stats.request_hit_ratio5 / fct,
642  stats.request_hit_ratio60 / fct);
643 
644  storeAppendPrintf(sentry, "\tHits as %% of bytes sent:\t5min: %3.1f%%, 60min: %3.1f%%\n",
645  stats.byte_hit_ratio5 / fct,
646  stats.byte_hit_ratio60 / fct);
647 
648  storeAppendPrintf(sentry, "\tMemory hits as %% of hit requests:\t5min: %3.1f%%, 60min: %3.1f%%\n",
649  stats.request_hit_mem_ratio5 / fct,
650  stats.request_hit_mem_ratio60 / fct);
651 
652  storeAppendPrintf(sentry, "\tDisk hits as %% of hit requests:\t5min: %3.1f%%, 60min: %3.1f%%\n",
653  stats.request_hit_disk_ratio5 / fct,
654  stats.request_hit_disk_ratio60 / fct);
655 
656  storeAppendPrintf(sentry, "\tStorage Swap size:\t%.0f KB\n",
657  stats.store.swap.size / 1024);
658 
659  storeAppendPrintf(sentry, "\tStorage Swap capacity:\t%4.1f%% used, %4.1f%% free\n",
660  Math::doublePercent(stats.store.swap.size, stats.store.swap.capacity),
661  Math::doublePercent(stats.store.swap.available(), stats.store.swap.capacity));
662 
663  storeAppendPrintf(sentry, "\tStorage Mem size:\t%.0f KB\n",
664  stats.store.mem.size / 1024);
665 
666  storeAppendPrintf(sentry, "\tStorage Mem capacity:\t%4.1f%% used, %4.1f%% free\n",
667  Math::doublePercent(stats.store.mem.size, stats.store.mem.capacity),
668  Math::doublePercent(stats.store.mem.available(), stats.store.mem.capacity));
669 
670  storeAppendPrintf(sentry, "\tMean Object Size:\t%0.2f KB\n",
671  stats.store.swap.meanObjectSize() / 1024);
672 
673  storeAppendPrintf(sentry, "\tRequests given to unlinkd:\t%.0f\n",
674  stats.unlink_requests);
675 
676  storeAppendPrintf(sentry, "Median Service Times (seconds) 5 min 60 min:\n");
677 
678  fct = stats.count > 1 ? stats.count * 1000.0 : 1000.0;
679  storeAppendPrintf(sentry, "\tHTTP Requests (All): %8.5f %8.5f\n",
680  stats.http_requests5 / fct,
681  stats.http_requests60 / fct);
682 
683  storeAppendPrintf(sentry, "\tCache Misses: %8.5f %8.5f\n",
684  stats.cache_misses5 / fct,
685  stats.cache_misses60 / fct);
686 
687  storeAppendPrintf(sentry, "\tCache Hits: %8.5f %8.5f\n",
688  stats.cache_hits5 / fct,
689  stats.cache_hits60 / fct);
690 
691  storeAppendPrintf(sentry, "\tNear Hits: %8.5f %8.5f\n",
692  stats.near_hits5 / fct,
693  stats.near_hits60 / fct);
694 
695  storeAppendPrintf(sentry, "\tNot-Modified Replies: %8.5f %8.5f\n",
696  stats.not_modified_replies5 / fct,
697  stats.not_modified_replies60 / fct);
698 
699  storeAppendPrintf(sentry, "\tDNS Lookups: %8.5f %8.5f\n",
700  stats.dns_lookups5 / fct,
701  stats.dns_lookups60 / fct);
702 
703  fct = stats.count > 1 ? stats.count * 1000000.0 : 1000000.0;
704  storeAppendPrintf(sentry, "\tICP Queries: %8.5f %8.5f\n",
705  stats.icp_queries5 / fct,
706  stats.icp_queries60 / fct);
707 
708  storeAppendPrintf(sentry, "Resource usage for %s:\n", APP_SHORTNAME);
709 
710  storeAppendPrintf(sentry, "\tUP Time:\t%.3f seconds\n", stats.up_time);
711 
712  storeAppendPrintf(sentry, "\tCPU Time:\t%.3f seconds\n", stats.cpu_time);
713 
714  storeAppendPrintf(sentry, "\tCPU Usage:\t%.2f%%\n",
715  stats.cpu_usage);
716 
717  storeAppendPrintf(sentry, "\tCPU Usage, 5 minute avg:\t%.2f%%\n",
718  stats.cpu_usage5);
719 
720  storeAppendPrintf(sentry, "\tCPU Usage, 60 minute avg:\t%.2f%%\n",
721  stats.cpu_usage60);
722 
723  storeAppendPrintf(sentry, "\tMaximum Resident Size: %.0f KB\n",
724  stats.maxrss);
725 
726  storeAppendPrintf(sentry, "\tPage faults with physical i/o: %.0f\n",
727  stats.page_faults);
728 
729 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
730 
731  storeAppendPrintf(sentry, "Memory usage for %s via mstats():\n",APP_SHORTNAME);
732 
733  storeAppendPrintf(sentry, "\tTotal space in arena: %6.0f KB\n",
734  stats.ms_bytes_total / 1024);
735 
736  storeAppendPrintf(sentry, "\tTotal free: %6.0f KB %.0f%%\n",
737  stats.ms_bytes_free / 1024,
738  Math::doublePercent(stats.ms_bytes_free, stats.ms_bytes_total));
739 
740 #endif
741 
742  storeAppendPrintf(sentry, "Memory accounted for:\n");
743  storeAppendPrintf(sentry, "\tTotal accounted: %6.0f KB\n",
744  stats.total_accounted / 1024);
745  {
746  MemPoolGlobalStats mp_stats;
747  memPoolGetGlobalStats(&mp_stats);
748  storeAppendPrintf(sentry, "\tmemPoolAlloc calls: %9.0f\n",
749  stats.gb_saved_count);
750  storeAppendPrintf(sentry, "\tmemPoolFree calls: %9.0f\n",
751  stats.gb_freed_count);
752  }
753 
754  storeAppendPrintf(sentry, "File descriptor usage for %s:\n", APP_SHORTNAME);
755  storeAppendPrintf(sentry, "\tMaximum number of file descriptors: %4.0f\n",
756  stats.max_fd);
757  storeAppendPrintf(sentry, "\tLargest file desc currently in use: %4.0f\n",
758  stats.biggest_fd);
759  storeAppendPrintf(sentry, "\tNumber of file desc currently in use: %4.0f\n",
760  stats.number_fd);
761  storeAppendPrintf(sentry, "\tFiles queued for open: %4.0f\n",
762  stats.opening_fd);
763  storeAppendPrintf(sentry, "\tAvailable number of file descriptors: %4.0f\n",
764  stats.num_fd_free);
765  storeAppendPrintf(sentry, "\tReserved number of file descriptors: %4.0f\n",
766  stats.reserved_fd);
767  storeAppendPrintf(sentry, "\tStore Disk files open: %4.0f\n",
768  stats.store.swap.open_disk_fd);
769 
770  storeAppendPrintf(sentry, "Internal Data Structures:\n");
771  storeAppendPrintf(sentry, "\t%6.0f StoreEntries\n",
772  stats.store.store_entry_count);
773  storeAppendPrintf(sentry, "\t%6.0f StoreEntries with MemObjects\n",
774  stats.store.mem_object_count);
775  storeAppendPrintf(sentry, "\t%6.0f Hot Object Cache Items\n",
776  stats.store.mem.count);
777  storeAppendPrintf(sentry, "\t%6.0f on-disk objects\n",
778  stats.store.swap.count);
779 }
780 
781 void
783 {
784 #if XMALLOC_STATISTICS
787  storeAppendPrintf(sentry, "\nMemory allocation statistics\n");
788  storeAppendPrintf(sentry, "%12s %15s %6s %12s\n","Alloc Size","Count","Delta","Alloc/sec");
789  malloc_statistics(info_get_mallstat, sentry);
790 #else
791  (void)sentry;
792 #endif
793 }
794 
795 void
797 {
798  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
799  double p = (i + 1) * 5 / 100.0;
800  stats.http_requests5[i] = statPctileSvc(p, 5, PCTILE_HTTP);
801  stats.http_requests60[i] = statPctileSvc(p, 60, PCTILE_HTTP);
802 
803  stats.cache_misses5[i] = statPctileSvc(p, 5, PCTILE_MISS);
804  stats.cache_misses60[i] = statPctileSvc(p, 60, PCTILE_MISS);
805 
806  stats.cache_hits5[i] = statPctileSvc(p, 5, PCTILE_HIT);
807  stats.cache_hits60[i] = statPctileSvc(p, 60, PCTILE_HIT);
808 
809  stats.near_hits5[i] = statPctileSvc(p, 5, PCTILE_NH);
810  stats.near_hits60[i] = statPctileSvc(p, 60, PCTILE_NH);
811 
812  stats.not_modified_replies5[i] = statPctileSvc(p, 5, PCTILE_NM);
813  stats.not_modified_replies60[i] = statPctileSvc(p, 60, PCTILE_NM);
814 
815  stats.dns_lookups5[i] = statPctileSvc(p, 5, PCTILE_DNS);
816  stats.dns_lookups60[i] = statPctileSvc(p, 60, PCTILE_DNS);
817 
818  stats.icp_queries5[i] = statPctileSvc(p, 5, PCTILE_ICP_QUERY);
819  stats.icp_queries60[i] = statPctileSvc(p, 60, PCTILE_ICP_QUERY);
820  }
821 }
822 
823 void
825 {
826  storeAppendPrintf(sentry, "Service Time Percentiles 5 min 60 min:\n");
827  double fct = stats.count > 1 ? stats.count * 1000.0 : 1000.0;
828  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
829  storeAppendPrintf(sentry, "\tHTTP Requests (All): %2d%% %8.5f %8.5f\n",
830  (i + 1) * 5,
831  stats.http_requests5[i] / fct,
832  stats.http_requests60[i] / fct);
833  }
834  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
835  storeAppendPrintf(sentry, "\tCache Misses: %2d%% %8.5f %8.5f\n",
836  (i + 1) * 5,
837  stats.cache_misses5[i] / fct,
838  stats.cache_misses60[i] / fct);
839  }
840  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
841  storeAppendPrintf(sentry, "\tCache Hits: %2d%% %8.5f %8.5f\n",
842  (i + 1) * 5,
843  stats.cache_hits5[i] / fct,
844  stats.cache_hits60[i] / fct);
845  }
846  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
847  storeAppendPrintf(sentry, "\tNear Hits: %2d%% %8.5f %8.5f\n",
848  (i + 1) * 5,
849  stats.near_hits5[i] / fct,
850  stats.near_hits60[i] / fct);
851  }
852  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
853  storeAppendPrintf(sentry, "\tNot-Modified Replies: %2d%% %8.5f %8.5f\n",
854  (i + 1) * 5,
855  stats.not_modified_replies5[i] / fct,
856  stats.not_modified_replies60[i] / fct);
857  }
858  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
859  storeAppendPrintf(sentry, "\tDNS Lookups: %2d%% %8.5f %8.5f\n",
860  (i + 1) * 5,
861  stats.dns_lookups5[i] / fct,
862  stats.dns_lookups60[i] / fct);
863  }
864  fct = stats.count > 1 ? stats.count * 1000000.0 : 1000000.0;
865  for (int i = 0; i < Mgr::ServiceTimesActionData::seriesSize; ++i) {
866  storeAppendPrintf(sentry, "\tICP Queries: %2d%% %8.5f %8.5f\n",
867  (i + 1) * 5,
868  stats.icp_queries5[i] / fct,
869  stats.icp_queries60[i] / fct);
870  }
871 }
872 
873 static void
874 statAvgDump(StoreEntry * sentry, int minutes, int hours)
875 {
877  GetAvgStat(stats, minutes, hours);
878  DumpAvgStat(stats, sentry);
879 }
880 
881 #define XAVG(X) (dt ? (double) (f->X - l->X) / dt : 0.0)
882 void
883 GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours)
884 {
885  StatCounters *f;
886  StatCounters *l;
887  double dt;
888  double ct;
889  assert(N_COUNT_HIST > 1);
890  assert(minutes > 0 || hours > 0);
891  f = &CountHist[0];
892  l = f;
893 
894  if (minutes > 0 && hours == 0) {
895  /* checking minute readings ... */
896 
897  if (minutes > N_COUNT_HIST - 1)
898  minutes = N_COUNT_HIST - 1;
899 
900  l = &CountHist[minutes];
901  } else if (minutes == 0 && hours > 0) {
902  /* checking hour readings ... */
903 
904  if (hours > N_COUNT_HOUR_HIST - 1)
905  hours = N_COUNT_HOUR_HIST - 1;
906 
907  l = &CountHourHist[hours];
908  } else {
909  debugs(18, DBG_IMPORTANT, "ERROR: statAvgDump: Invalid args, minutes=" << minutes << ", hours=" << hours);
910  return;
911  }
912 
913  dt = tvSubDsec(l->timestamp, f->timestamp);
914  ct = f->cputime - l->cputime;
915 
916  stats.sample_start_time = l->timestamp;
917  stats.sample_end_time = f->timestamp;
918 
919  stats.client_http_requests = XAVG(client_http.requests);
920  stats.client_http_hits = XAVG(client_http.hits);
921  stats.client_http_errors = XAVG(client_http.errors);
922  stats.client_http_kbytes_in = XAVG(client_http.kbytes_in.kb);
923  stats.client_http_kbytes_out = XAVG(client_http.kbytes_out.kb);
924 
925  stats.client_http_all_median_svc_time = statHistDeltaMedian(l->client_http.allSvcTime,
926  f->client_http.allSvcTime) / 1000.0;
927  stats.client_http_miss_median_svc_time = statHistDeltaMedian(l->client_http.missSvcTime,
928  f->client_http.missSvcTime) / 1000.0;
929  stats.client_http_nm_median_svc_time = statHistDeltaMedian(l->client_http.nearMissSvcTime,
930  f->client_http.nearMissSvcTime) / 1000.0;
931  stats.client_http_nh_median_svc_time = statHistDeltaMedian(l->client_http.nearHitSvcTime,
932  f->client_http.nearHitSvcTime) / 1000.0;
933  stats.client_http_hit_median_svc_time = statHistDeltaMedian(l->client_http.hitSvcTime,
934  f->client_http.hitSvcTime) / 1000.0;
935 
936  stats.server_all_requests = XAVG(server.all.requests);
937  stats.server_all_errors = XAVG(server.all.errors);
938  stats.server_all_kbytes_in = XAVG(server.all.kbytes_in.kb);
939  stats.server_all_kbytes_out = XAVG(server.all.kbytes_out.kb);
940 
941  stats.server_http_requests = XAVG(server.http.requests);
942  stats.server_http_errors = XAVG(server.http.errors);
943  stats.server_http_kbytes_in = XAVG(server.http.kbytes_in.kb);
944  stats.server_http_kbytes_out = XAVG(server.http.kbytes_out.kb);
945 
946  stats.server_ftp_requests = XAVG(server.ftp.requests);
947  stats.server_ftp_errors = XAVG(server.ftp.errors);
948  stats.server_ftp_kbytes_in = XAVG(server.ftp.kbytes_in.kb);
949  stats.server_ftp_kbytes_out = XAVG(server.ftp.kbytes_out.kb);
950 
951  stats.server_other_requests = XAVG(server.other.requests);
952  stats.server_other_errors = XAVG(server.other.errors);
953  stats.server_other_kbytes_in = XAVG(server.other.kbytes_in.kb);
954  stats.server_other_kbytes_out = XAVG(server.other.kbytes_out.kb);
955 
956  stats.icp_pkts_sent = XAVG(icp.pkts_sent);
957  stats.icp_pkts_recv = XAVG(icp.pkts_recv);
958  stats.icp_queries_sent = XAVG(icp.queries_sent);
959  stats.icp_replies_sent = XAVG(icp.replies_sent);
960  stats.icp_queries_recv = XAVG(icp.queries_recv);
961  stats.icp_replies_recv = XAVG(icp.replies_recv);
962  stats.icp_replies_queued = XAVG(icp.replies_queued);
963  stats.icp_query_timeouts = XAVG(icp.query_timeouts);
964  stats.icp_kbytes_sent = XAVG(icp.kbytes_sent.kb);
965  stats.icp_kbytes_recv = XAVG(icp.kbytes_recv.kb);
966  stats.icp_q_kbytes_sent = XAVG(icp.q_kbytes_sent.kb);
967  stats.icp_r_kbytes_sent = XAVG(icp.r_kbytes_sent.kb);
968  stats.icp_q_kbytes_recv = XAVG(icp.q_kbytes_recv.kb);
969  stats.icp_r_kbytes_recv = XAVG(icp.r_kbytes_recv.kb);
970 
971  stats.icp_query_median_svc_time = statHistDeltaMedian(l->icp.querySvcTime,
972  f->icp.querySvcTime) / 1000000.0;
973  stats.icp_reply_median_svc_time = statHistDeltaMedian(l->icp.replySvcTime,
974  f->icp.replySvcTime) / 1000000.0;
975  stats.dns_median_svc_time = statHistDeltaMedian(l->dns.svcTime,
976  f->dns.svcTime) / 1000.0;
977 
978  stats.unlink_requests = XAVG(unlink.requests);
979  stats.page_faults = XAVG(page_faults);
980  stats.select_loops = XAVG(select_loops);
981  stats.select_fds = XAVG(select_fds);
982  stats.average_select_fd_period = f->select_fds > l->select_fds ?
983  (f->select_time - l->select_time) / (f->select_fds - l->select_fds) : 0.0;
984 
985  stats.median_select_fds = statHistDeltaMedian(l->select_fds_hist, f->select_fds_hist);
986  stats.swap_outs = XAVG(swap.outs);
987  stats.swap_ins = XAVG(swap.ins);
988  stats.swap_files_cleaned = XAVG(swap.files_cleaned);
989  stats.aborted_requests = XAVG(aborted_requests);
990 
991  stats.hitValidationAttempts = XAVG(hitValidation.attempts);
992  stats.hitValidationRefusalsDueToLocking = XAVG(hitValidation.refusalsDueToLocking);
993  stats.hitValidationRefusalsDueToZeroSize = XAVG(hitValidation.refusalsDueToZeroSize);
994  stats.hitValidationRefusalsDueToTimeLimit = XAVG(hitValidation.refusalsDueToTimeLimit);
995  stats.hitValidationFailures = XAVG(hitValidation.failures);
996 
997  stats.syscalls_disk_opens = XAVG(syscalls.disk.opens);
998  stats.syscalls_disk_closes = XAVG(syscalls.disk.closes);
999  stats.syscalls_disk_reads = XAVG(syscalls.disk.reads);
1000  stats.syscalls_disk_writes = XAVG(syscalls.disk.writes);
1001  stats.syscalls_disk_seeks = XAVG(syscalls.disk.seeks);
1002  stats.syscalls_disk_unlinks = XAVG(syscalls.disk.unlinks);
1003  stats.syscalls_sock_accepts = XAVG(syscalls.sock.accepts);
1004  stats.syscalls_sock_sockets = XAVG(syscalls.sock.sockets);
1005  stats.syscalls_sock_connects = XAVG(syscalls.sock.connects);
1006  stats.syscalls_sock_binds = XAVG(syscalls.sock.binds);
1007  stats.syscalls_sock_closes = XAVG(syscalls.sock.closes);
1008  stats.syscalls_sock_reads = XAVG(syscalls.sock.reads);
1009  stats.syscalls_sock_writes = XAVG(syscalls.sock.writes);
1010  stats.syscalls_sock_recvfroms = XAVG(syscalls.sock.recvfroms);
1011  stats.syscalls_sock_sendtos = XAVG(syscalls.sock.sendtos);
1012  stats.syscalls_selects = XAVG(syscalls.selects);
1013 
1014  stats.cpu_time = ct;
1015  stats.wall_time = dt;
1016 }
1017 
1018 void
1020 {
1021  storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n",
1022  (int)stats.sample_start_time.tv_sec,
1023  (int)stats.sample_start_time.tv_usec,
1024  Time::FormatRfc1123(stats.sample_start_time.tv_sec));
1025  storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n",
1026  (int)stats.sample_end_time.tv_sec,
1027  (int)stats.sample_end_time.tv_usec,
1028  Time::FormatRfc1123(stats.sample_end_time.tv_sec));
1029 
1030  storeAppendPrintf(sentry, "client_http.requests = %f/sec\n",
1031  stats.client_http_requests);
1032  storeAppendPrintf(sentry, "client_http.hits = %f/sec\n",
1033  stats.client_http_hits);
1034  storeAppendPrintf(sentry, "client_http.errors = %f/sec\n",
1035  stats.client_http_errors);
1036  storeAppendPrintf(sentry, "client_http.kbytes_in = %f/sec\n",
1037  stats.client_http_kbytes_in);
1038  storeAppendPrintf(sentry, "client_http.kbytes_out = %f/sec\n",
1039  stats.client_http_kbytes_out);
1040 
1041  double fct = stats.count > 1 ? stats.count : 1.0;
1042  storeAppendPrintf(sentry, "client_http.all_median_svc_time = %f seconds\n",
1043  stats.client_http_all_median_svc_time / fct);
1044  storeAppendPrintf(sentry, "client_http.miss_median_svc_time = %f seconds\n",
1045  stats.client_http_miss_median_svc_time / fct);
1046  storeAppendPrintf(sentry, "client_http.nm_median_svc_time = %f seconds\n",
1047  stats.client_http_nm_median_svc_time / fct);
1048  storeAppendPrintf(sentry, "client_http.nh_median_svc_time = %f seconds\n",
1049  stats.client_http_nh_median_svc_time / fct);
1050  storeAppendPrintf(sentry, "client_http.hit_median_svc_time = %f seconds\n",
1051  stats.client_http_hit_median_svc_time / fct);
1052 
1053  storeAppendPrintf(sentry, "server.all.requests = %f/sec\n",
1054  stats.server_all_requests);
1055  storeAppendPrintf(sentry, "server.all.errors = %f/sec\n",
1056  stats.server_all_errors);
1057  storeAppendPrintf(sentry, "server.all.kbytes_in = %f/sec\n",
1058  stats.server_all_kbytes_in);
1059  storeAppendPrintf(sentry, "server.all.kbytes_out = %f/sec\n",
1060  stats.server_all_kbytes_out);
1061 
1062  storeAppendPrintf(sentry, "server.http.requests = %f/sec\n",
1063  stats.server_http_requests);
1064  storeAppendPrintf(sentry, "server.http.errors = %f/sec\n",
1065  stats.server_http_errors);
1066  storeAppendPrintf(sentry, "server.http.kbytes_in = %f/sec\n",
1067  stats.server_http_kbytes_in);
1068  storeAppendPrintf(sentry, "server.http.kbytes_out = %f/sec\n",
1069  stats.server_http_kbytes_out);
1070 
1071  storeAppendPrintf(sentry, "server.ftp.requests = %f/sec\n",
1072  stats.server_ftp_requests);
1073  storeAppendPrintf(sentry, "server.ftp.errors = %f/sec\n",
1074  stats.server_ftp_errors);
1075  storeAppendPrintf(sentry, "server.ftp.kbytes_in = %f/sec\n",
1076  stats.server_ftp_kbytes_in);
1077  storeAppendPrintf(sentry, "server.ftp.kbytes_out = %f/sec\n",
1078  stats.server_ftp_kbytes_out);
1079 
1080  storeAppendPrintf(sentry, "server.other.requests = %f/sec\n",
1081  stats.server_other_requests);
1082  storeAppendPrintf(sentry, "server.other.errors = %f/sec\n",
1083  stats.server_other_errors);
1084  storeAppendPrintf(sentry, "server.other.kbytes_in = %f/sec\n",
1085  stats.server_other_kbytes_in);
1086  storeAppendPrintf(sentry, "server.other.kbytes_out = %f/sec\n",
1087  stats.server_other_kbytes_out);
1088 
1089  storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n",
1090  stats.icp_pkts_sent);
1091  storeAppendPrintf(sentry, "icp.pkts_recv = %f/sec\n",
1092  stats.icp_pkts_recv);
1093  storeAppendPrintf(sentry, "icp.queries_sent = %f/sec\n",
1094  stats.icp_queries_sent);
1095  storeAppendPrintf(sentry, "icp.replies_sent = %f/sec\n",
1096  stats.icp_replies_sent);
1097  storeAppendPrintf(sentry, "icp.queries_recv = %f/sec\n",
1098  stats.icp_queries_recv);
1099  storeAppendPrintf(sentry, "icp.replies_recv = %f/sec\n",
1100  stats.icp_replies_recv);
1101  storeAppendPrintf(sentry, "icp.replies_queued = %f/sec\n",
1102  stats.icp_replies_queued);
1103  storeAppendPrintf(sentry, "icp.query_timeouts = %f/sec\n",
1104  stats.icp_query_timeouts);
1105  storeAppendPrintf(sentry, "icp.kbytes_sent = %f/sec\n",
1106  stats.icp_kbytes_sent);
1107  storeAppendPrintf(sentry, "icp.kbytes_recv = %f/sec\n",
1108  stats.icp_kbytes_recv);
1109  storeAppendPrintf(sentry, "icp.q_kbytes_sent = %f/sec\n",
1110  stats.icp_q_kbytes_sent);
1111  storeAppendPrintf(sentry, "icp.r_kbytes_sent = %f/sec\n",
1112  stats.icp_r_kbytes_sent);
1113  storeAppendPrintf(sentry, "icp.q_kbytes_recv = %f/sec\n",
1114  stats.icp_q_kbytes_recv);
1115  storeAppendPrintf(sentry, "icp.r_kbytes_recv = %f/sec\n",
1116  stats.icp_r_kbytes_recv);
1117  storeAppendPrintf(sentry, "icp.query_median_svc_time = %f seconds\n",
1118  stats.icp_query_median_svc_time / fct);
1119  storeAppendPrintf(sentry, "icp.reply_median_svc_time = %f seconds\n",
1120  stats.icp_reply_median_svc_time / fct);
1121  storeAppendPrintf(sentry, "dns.median_svc_time = %f seconds\n",
1122  stats.dns_median_svc_time / fct);
1123  storeAppendPrintf(sentry, "unlink.requests = %f/sec\n",
1124  stats.unlink_requests);
1125  storeAppendPrintf(sentry, "page_faults = %f/sec\n",
1126  stats.page_faults);
1127  storeAppendPrintf(sentry, "select_loops = %f/sec\n",
1128  stats.select_loops);
1129  storeAppendPrintf(sentry, "select_fds = %f/sec\n",
1130  stats.select_fds);
1131  storeAppendPrintf(sentry, "average_select_fd_period = %f/fd\n",
1132  stats.average_select_fd_period / fct);
1133  storeAppendPrintf(sentry, "median_select_fds = %f\n",
1134  stats.median_select_fds / fct);
1135  storeAppendPrintf(sentry, "swap.outs = %f/sec\n",
1136  stats.swap_outs);
1137  storeAppendPrintf(sentry, "swap.ins = %f/sec\n",
1138  stats.swap_ins);
1139  storeAppendPrintf(sentry, "swap.files_cleaned = %f/sec\n",
1140  stats.swap_files_cleaned);
1141  storeAppendPrintf(sentry, "aborted_requests = %f/sec\n",
1142  stats.aborted_requests);
1143 
1144  storeAppendPrintf(sentry, "hit_validation.attempts = %f/sec\n",
1145  stats.hitValidationAttempts);
1146  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_locking = %f/sec\n",
1147  stats.hitValidationRefusalsDueToLocking);
1148  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_zeroSize = %f/sec\n",
1149  stats.hitValidationRefusalsDueToZeroSize);
1150  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_timeLimit = %f/sec\n",
1151  stats.hitValidationRefusalsDueToTimeLimit);
1152  storeAppendPrintf(sentry, "hit_validation.failures = %f/sec\n",
1153  stats.hitValidationFailures);
1154 
1155 #if USE_POLL
1156  storeAppendPrintf(sentry, "syscalls.polls = %f/sec\n", stats.syscalls_selects);
1157 #elif defined(USE_SELECT) || defined(USE_SELECT_WIN32)
1158  storeAppendPrintf(sentry, "syscalls.selects = %f/sec\n", stats.syscalls_selects);
1159 #endif
1160 
1161  storeAppendPrintf(sentry, "syscalls.disk.opens = %f/sec\n", stats.syscalls_disk_opens);
1162  storeAppendPrintf(sentry, "syscalls.disk.closes = %f/sec\n", stats.syscalls_disk_closes);
1163  storeAppendPrintf(sentry, "syscalls.disk.reads = %f/sec\n", stats.syscalls_disk_reads);
1164  storeAppendPrintf(sentry, "syscalls.disk.writes = %f/sec\n", stats.syscalls_disk_writes);
1165  storeAppendPrintf(sentry, "syscalls.disk.seeks = %f/sec\n", stats.syscalls_disk_seeks);
1166  storeAppendPrintf(sentry, "syscalls.disk.unlinks = %f/sec\n", stats.syscalls_disk_unlinks);
1167  storeAppendPrintf(sentry, "syscalls.sock.accepts = %f/sec\n", stats.syscalls_sock_accepts);
1168  storeAppendPrintf(sentry, "syscalls.sock.sockets = %f/sec\n", stats.syscalls_sock_sockets);
1169  storeAppendPrintf(sentry, "syscalls.sock.connects = %f/sec\n", stats.syscalls_sock_connects);
1170  storeAppendPrintf(sentry, "syscalls.sock.binds = %f/sec\n", stats.syscalls_sock_binds);
1171  storeAppendPrintf(sentry, "syscalls.sock.closes = %f/sec\n", stats.syscalls_sock_closes);
1172  storeAppendPrintf(sentry, "syscalls.sock.reads = %f/sec\n", stats.syscalls_sock_reads);
1173  storeAppendPrintf(sentry, "syscalls.sock.writes = %f/sec\n", stats.syscalls_sock_writes);
1174  storeAppendPrintf(sentry, "syscalls.sock.recvfroms = %f/sec\n", stats.syscalls_sock_recvfroms);
1175  storeAppendPrintf(sentry, "syscalls.sock.sendtos = %f/sec\n", stats.syscalls_sock_sendtos);
1176 
1177  storeAppendPrintf(sentry, "cpu_time = %f seconds\n", stats.cpu_time);
1178  storeAppendPrintf(sentry, "wall_time = %f seconds\n", stats.wall_time);
1179  storeAppendPrintf(sentry, "cpu_usage = %f%%\n", Math::doublePercent(stats.cpu_time, stats.wall_time));
1180 }
1181 
1182 static void
1184 {
1185  Mgr::RegisterAction("info", "General Runtime Information",
1186  &Mgr::InfoAction::Create, 0, 1);
1187  Mgr::RegisterAction("service_times", "Service Times (Percentiles)",
1189  Mgr::RegisterAction("filedescriptors", "Process Filedescriptor Allocation",
1190  fde::DumpStats, 0, 1);
1191  Mgr::RegisterAction("objects", "All Cache Objects", stat_objects_get, 0, 0);
1192  Mgr::RegisterAction("vm_objects", "In-Memory and In-Transit Objects",
1193  stat_vmobjects_get, 0, 0);
1194  Mgr::RegisterAction("io", "Server-side network read() size histograms",
1195  &Mgr::IoAction::Create, 0, 1);
1196  Mgr::RegisterAction("counters", "Traffic and Resource Counters",
1198  Mgr::RegisterAction("peer_select", "Peer Selection Algorithms",
1199  statPeerSelect, 0, 1);
1200  Mgr::RegisterAction("digest_stats", "Cache Digest and ICP blob",
1201  statDigestBlob, 0, 1);
1202  Mgr::RegisterAction("5min", "5 Minute Average of Counters",
1204  Mgr::RegisterAction("60min", "60 Minute Average of Counters",
1206  Mgr::RegisterAction("utilization", "Cache Utilization",
1207  statUtilization, 0, 1);
1208  Mgr::RegisterAction("histograms", "Full Histogram Counts",
1209  statCountersHistograms, 0, 1);
1210  Mgr::RegisterAction("active_requests",
1211  "Client-side Active Requests",
1212  statClientRequests, 0, 1);
1213 #if USE_AUTH
1214  Mgr::RegisterAction("username_cache",
1215  "Active Cached Usernames",
1217 #endif
1218  Mgr::RegisterAction("openfd_objects", "Objects with Swapout files open",
1219  statOpenfdObj, 0, 0);
1220 #if STAT_GRAPHS
1221  Mgr::RegisterAction("graph_variables", "Display cache metrics graphically",
1222  statGraphDump, 0, 1);
1223 #endif
1224 }
1225 
1226 /* add special cases here as they arrive */
1227 static void
1229 {
1230  /*
1231  * HTTP svc_time hist is kept in milli-seconds; max of 3 hours.
1232  */
1233  C->client_http.allSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
1234  C->client_http.missSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
1235  C->client_http.nearMissSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
1236  C->client_http.nearHitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
1237  C->client_http.hitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
1238  /*
1239  * ICP svc_time hist is kept in micro-seconds; max of 1 minute.
1240  */
1241  C->icp.querySvcTime.logInit(300, 0.0, 1000000.0 * 60.0);
1242  C->icp.replySvcTime.logInit(300, 0.0, 1000000.0 * 60.0);
1243  /*
1244  * DNS svc_time hist is kept in milli-seconds; max of 10 minutes.
1245  */
1246  C->dns.svcTime.logInit(300, 0.0, 60000.0 * 10.0);
1247  /*
1248  * Cache Digest Stuff
1249  */
1250  C->cd.on_xition_count.enumInit(CacheDigestHashFuncCount);
1251  C->comm_udp_incoming.enumInit(INCOMING_UDP_MAX);
1252  C->comm_dns_incoming.enumInit(INCOMING_DNS_MAX);
1253  C->comm_tcp_incoming.enumInit(INCOMING_TCP_MAX);
1254  C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
1255 }
1256 
1257 static void
1259 {
1260  assert(C);
1261  *C = StatCounters();
1263 }
1264 
1265 void
1267 {
1268  int i;
1269  debugs(18, 5, "statInit: Initializing...");
1270 
1271  for (i = 0; i < N_COUNT_HIST; ++i)
1273 
1274  for (i = 0; i < N_COUNT_HOUR_HIST; ++i)
1276 
1278 
1279  eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1);
1280 
1282 
1284 
1286 }
1287 
1288 static void
1290 {
1291  struct rusage rusage;
1292  eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1);
1297  // shift all elements right and prepend statCounter
1298  for(int i = N_COUNT_HIST-1; i > 0; --i)
1299  CountHist[i] = CountHist[i-1];
1300  CountHist[0] = statCounter;
1301  ++NCountHist;
1302 
1303  if ((NCountHist % COUNT_INTERVAL) == 0) {
1304  /* we have an hours worth of readings. store previous hour */
1305  // shift all elements right and prepend final CountHist element
1306  for(int i = N_COUNT_HOUR_HIST-1; i > 0; --i)
1307  CountHourHist[i] = CountHourHist[i-1];
1309  ++NCountHourHist;
1310  }
1311 
1312  if (Config.warnings.high_rptm > 0) {
1313  int i = (int) statPctileSvc(0.5, 20, PCTILE_HTTP);
1314 
1315  if (Config.warnings.high_rptm < i)
1316  debugs(18, DBG_CRITICAL, "WARNING: Median response time is " << i << " milliseconds");
1317  }
1318 
1319  if (Config.warnings.high_pf) {
1320  int i = (CountHist[0].page_faults - CountHist[1].page_faults);
1321  double dt = tvSubDsec(CountHist[0].timestamp, CountHist[1].timestamp);
1322 
1323  if (i > 0 && dt > 0.0) {
1324  i /= (int) dt;
1325 
1326  if (Config.warnings.high_pf < i)
1327  debugs(18, DBG_CRITICAL, "WARNING: Page faults occurring at " << i << "/sec");
1328  }
1329  }
1330 
1331  if (Config.warnings.high_memory) {
1332  size_t i = 0;
1333 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
1334  struct mstats ms = mstats();
1335  i = ms.bytes_total;
1336 #endif
1337  if (Config.warnings.high_memory < i)
1338  debugs(18, DBG_CRITICAL, "WARNING: Memory usage at " << ((unsigned long int)(i >> 20)) << " MB");
1339  }
1340 }
1341 
1342 static void
1344 {
1345  storeAppendPrintf(sentry, "client_http.allSvcTime histogram:\n");
1347  storeAppendPrintf(sentry, "client_http.missSvcTime histogram:\n");
1349  storeAppendPrintf(sentry, "client_http.nearMissSvcTime histogram:\n");
1351  storeAppendPrintf(sentry, "client_http.nearHitSvcTime histogram:\n");
1353  storeAppendPrintf(sentry, "client_http.hitSvcTime histogram:\n");
1355  storeAppendPrintf(sentry, "icp.querySvcTime histogram:\n");
1357  storeAppendPrintf(sentry, "icp.replySvcTime histogram:\n");
1359  storeAppendPrintf(sentry, "dns.svc_time histogram:\n");
1360  statCounter.dns.svcTime.dump(sentry, NULL);
1361  storeAppendPrintf(sentry, "select_fds_hist histogram:\n");
1363 }
1364 
1365 static void
1367 {
1370  DumpCountersStats(stats, sentry);
1371 }
1372 
1373 void
1375 {
1376  StatCounters *f = &statCounter;
1377 
1378  struct rusage rusage;
1381  f->cputime = rusage_cputime(&rusage);
1382 
1383  stats.sample_time = f->timestamp;
1384  stats.client_http_requests = f->client_http.requests;
1385  stats.client_http_hits = f->client_http.hits;
1386  stats.client_http_errors = f->client_http.errors;
1387  stats.client_http_kbytes_in = f->client_http.kbytes_in.kb;
1388  stats.client_http_kbytes_out = f->client_http.kbytes_out.kb;
1389  stats.client_http_hit_kbytes_out = f->client_http.hit_kbytes_out.kb;
1390 
1391  stats.server_all_requests = f->server.all.requests;
1392  stats.server_all_errors = f->server.all.errors;
1393  stats.server_all_kbytes_in = f->server.all.kbytes_in.kb;
1394  stats.server_all_kbytes_out = f->server.all.kbytes_out.kb;
1395 
1396  stats.server_http_requests = f->server.http.requests;
1397  stats.server_http_errors = f->server.http.errors;
1398  stats.server_http_kbytes_in = f->server.http.kbytes_in.kb;
1399  stats.server_http_kbytes_out = f->server.http.kbytes_out.kb;
1400 
1401  stats.server_ftp_requests = f->server.ftp.requests;
1402  stats.server_ftp_errors = f->server.ftp.errors;
1403  stats.server_ftp_kbytes_in = f->server.ftp.kbytes_in.kb;
1404  stats.server_ftp_kbytes_out = f->server.ftp.kbytes_out.kb;
1405 
1406  stats.server_other_requests = f->server.other.requests;
1407  stats.server_other_errors = f->server.other.errors;
1408  stats.server_other_kbytes_in = f->server.other.kbytes_in.kb;
1409  stats.server_other_kbytes_out = f->server.other.kbytes_out.kb;
1410 
1411  stats.icp_pkts_sent = f->icp.pkts_sent;
1412  stats.icp_pkts_recv = f->icp.pkts_recv;
1413  stats.icp_queries_sent = f->icp.queries_sent;
1414  stats.icp_replies_sent = f->icp.replies_sent;
1415  stats.icp_queries_recv = f->icp.queries_recv;
1416  stats.icp_replies_recv = f->icp.replies_recv;
1417  stats.icp_query_timeouts = f->icp.query_timeouts;
1418  stats.icp_replies_queued = f->icp.replies_queued;
1419  stats.icp_kbytes_sent = f->icp.kbytes_sent.kb;
1420  stats.icp_kbytes_recv = f->icp.kbytes_recv.kb;
1421  stats.icp_q_kbytes_sent = f->icp.q_kbytes_sent.kb;
1422  stats.icp_r_kbytes_sent = f->icp.r_kbytes_sent.kb;
1423  stats.icp_q_kbytes_recv = f->icp.q_kbytes_recv.kb;
1424  stats.icp_r_kbytes_recv = f->icp.r_kbytes_recv.kb;
1425 
1426 #if USE_CACHE_DIGESTS
1427 
1428  stats.icp_times_used = f->icp.times_used;
1429  stats.cd_times_used = f->cd.times_used;
1430  stats.cd_msgs_sent = f->cd.msgs_sent;
1431  stats.cd_msgs_recv = f->cd.msgs_recv;
1432  stats.cd_memory = f->cd.memory.kb;
1433  stats.cd_local_memory = store_digest ? store_digest->mask_size / 1024 : 0;
1434  stats.cd_kbytes_sent = f->cd.kbytes_sent.kb;
1435  stats.cd_kbytes_recv = f->cd.kbytes_recv.kb;
1436 #endif
1437 
1438  stats.unlink_requests = f->unlink.requests;
1439  stats.page_faults = f->page_faults;
1440  stats.select_loops = f->select_loops;
1441  stats.cpu_time = f->cputime;
1442  stats.wall_time = tvSubDsec(f->timestamp, current_time);
1443  stats.swap_outs = f->swap.outs;
1444  stats.swap_ins = f->swap.ins;
1445  stats.swap_files_cleaned = f->swap.files_cleaned;
1446  stats.aborted_requests = f->aborted_requests;
1447 
1448  stats.hitValidationAttempts = f->hitValidation.attempts;
1449  stats.hitValidationRefusalsDueToLocking = f->hitValidation.refusalsDueToLocking;
1450  stats.hitValidationRefusalsDueToZeroSize = f->hitValidation.refusalsDueToZeroSize;
1451  stats.hitValidationRefusalsDueToTimeLimit = f->hitValidation.refusalsDueToTimeLimit;
1452  stats.hitValidationFailures = f->hitValidation.failures;
1453 }
1454 
1455 void
1457 {
1458  storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n",
1459  (int) stats.sample_time.tv_sec,
1460  (int) stats.sample_time.tv_usec,
1461  Time::FormatRfc1123(stats.sample_time.tv_sec));
1462  storeAppendPrintf(sentry, "client_http.requests = %.0f\n",
1463  stats.client_http_requests);
1464  storeAppendPrintf(sentry, "client_http.hits = %.0f\n",
1465  stats.client_http_hits);
1466  storeAppendPrintf(sentry, "client_http.errors = %.0f\n",
1467  stats.client_http_errors);
1468  storeAppendPrintf(sentry, "client_http.kbytes_in = %.0f\n",
1469  stats.client_http_kbytes_in);
1470  storeAppendPrintf(sentry, "client_http.kbytes_out = %.0f\n",
1471  stats.client_http_kbytes_out);
1472  storeAppendPrintf(sentry, "client_http.hit_kbytes_out = %.0f\n",
1473  stats.client_http_hit_kbytes_out);
1474 
1475  storeAppendPrintf(sentry, "server.all.requests = %.0f\n",
1476  stats.server_all_requests);
1477  storeAppendPrintf(sentry, "server.all.errors = %.0f\n",
1478  stats.server_all_errors);
1479  storeAppendPrintf(sentry, "server.all.kbytes_in = %.0f\n",
1480  stats.server_all_kbytes_in);
1481  storeAppendPrintf(sentry, "server.all.kbytes_out = %.0f\n",
1482  stats.server_all_kbytes_out);
1483 
1484  storeAppendPrintf(sentry, "server.http.requests = %.0f\n",
1485  stats.server_http_requests);
1486  storeAppendPrintf(sentry, "server.http.errors = %.0f\n",
1487  stats.server_http_errors);
1488  storeAppendPrintf(sentry, "server.http.kbytes_in = %.0f\n",
1489  stats.server_http_kbytes_in);
1490  storeAppendPrintf(sentry, "server.http.kbytes_out = %.0f\n",
1491  stats.server_http_kbytes_out);
1492 
1493  storeAppendPrintf(sentry, "server.ftp.requests = %.0f\n",
1494  stats.server_ftp_requests);
1495  storeAppendPrintf(sentry, "server.ftp.errors = %.0f\n",
1496  stats.server_ftp_errors);
1497  storeAppendPrintf(sentry, "server.ftp.kbytes_in = %.0f\n",
1498  stats.server_ftp_kbytes_in);
1499  storeAppendPrintf(sentry, "server.ftp.kbytes_out = %.0f\n",
1500  stats.server_ftp_kbytes_out);
1501 
1502  storeAppendPrintf(sentry, "server.other.requests = %.0f\n",
1503  stats.server_other_requests);
1504  storeAppendPrintf(sentry, "server.other.errors = %.0f\n",
1505  stats.server_other_errors);
1506  storeAppendPrintf(sentry, "server.other.kbytes_in = %.0f\n",
1507  stats.server_other_kbytes_in);
1508  storeAppendPrintf(sentry, "server.other.kbytes_out = %.0f\n",
1509  stats.server_other_kbytes_out);
1510 
1511  storeAppendPrintf(sentry, "icp.pkts_sent = %.0f\n",
1512  stats.icp_pkts_sent);
1513  storeAppendPrintf(sentry, "icp.pkts_recv = %.0f\n",
1514  stats.icp_pkts_recv);
1515  storeAppendPrintf(sentry, "icp.queries_sent = %.0f\n",
1516  stats.icp_queries_sent);
1517  storeAppendPrintf(sentry, "icp.replies_sent = %.0f\n",
1518  stats.icp_replies_sent);
1519  storeAppendPrintf(sentry, "icp.queries_recv = %.0f\n",
1520  stats.icp_queries_recv);
1521  storeAppendPrintf(sentry, "icp.replies_recv = %.0f\n",
1522  stats.icp_replies_recv);
1523  storeAppendPrintf(sentry, "icp.query_timeouts = %.0f\n",
1524  stats.icp_query_timeouts);
1525  storeAppendPrintf(sentry, "icp.replies_queued = %.0f\n",
1526  stats.icp_replies_queued);
1527  storeAppendPrintf(sentry, "icp.kbytes_sent = %.0f\n",
1528  stats.icp_kbytes_sent);
1529  storeAppendPrintf(sentry, "icp.kbytes_recv = %.0f\n",
1530  stats.icp_kbytes_recv);
1531  storeAppendPrintf(sentry, "icp.q_kbytes_sent = %.0f\n",
1532  stats.icp_q_kbytes_sent);
1533  storeAppendPrintf(sentry, "icp.r_kbytes_sent = %.0f\n",
1534  stats.icp_r_kbytes_sent);
1535  storeAppendPrintf(sentry, "icp.q_kbytes_recv = %.0f\n",
1536  stats.icp_q_kbytes_recv);
1537  storeAppendPrintf(sentry, "icp.r_kbytes_recv = %.0f\n",
1538  stats.icp_r_kbytes_recv);
1539 
1540 #if USE_CACHE_DIGESTS
1541 
1542  storeAppendPrintf(sentry, "icp.times_used = %.0f\n",
1543  stats.icp_times_used);
1544  storeAppendPrintf(sentry, "cd.times_used = %.0f\n",
1545  stats.cd_times_used);
1546  storeAppendPrintf(sentry, "cd.msgs_sent = %.0f\n",
1547  stats.cd_msgs_sent);
1548  storeAppendPrintf(sentry, "cd.msgs_recv = %.0f\n",
1549  stats.cd_msgs_recv);
1550  storeAppendPrintf(sentry, "cd.memory = %.0f\n",
1551  stats.cd_memory);
1552  storeAppendPrintf(sentry, "cd.local_memory = %.0f\n",
1553  stats.cd_local_memory);
1554  storeAppendPrintf(sentry, "cd.kbytes_sent = %.0f\n",
1555  stats.cd_kbytes_sent);
1556  storeAppendPrintf(sentry, "cd.kbytes_recv = %.0f\n",
1557  stats.cd_kbytes_recv);
1558 #endif
1559 
1560  storeAppendPrintf(sentry, "unlink.requests = %.0f\n",
1561  stats.unlink_requests);
1562  storeAppendPrintf(sentry, "page_faults = %.0f\n",
1563  stats.page_faults);
1564  storeAppendPrintf(sentry, "select_loops = %.0f\n",
1565  stats.select_loops);
1566  storeAppendPrintf(sentry, "cpu_time = %f\n",
1567  stats.cpu_time);
1568  storeAppendPrintf(sentry, "wall_time = %f\n",
1569  stats.wall_time);
1570  storeAppendPrintf(sentry, "swap.outs = %.0f\n",
1571  stats.swap_outs);
1572  storeAppendPrintf(sentry, "swap.ins = %.0f\n",
1573  stats.swap_ins);
1574  storeAppendPrintf(sentry, "swap.files_cleaned = %.0f\n",
1575  stats.swap_files_cleaned);
1576  storeAppendPrintf(sentry, "aborted_requests = %.0f\n",
1577  stats.aborted_requests);
1578 
1579  storeAppendPrintf(sentry, "hit_validation.attempts = %.0f\n",
1580  stats.hitValidationAttempts);
1581  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_locking = %.0f\n",
1582  stats.hitValidationRefusalsDueToLocking);
1583  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_zeroSize = %.0f\n",
1584  stats.hitValidationRefusalsDueToZeroSize);
1585  storeAppendPrintf(sentry, "hit_validation.refusals.due_to_timeLimit = %.0f\n",
1586  stats.hitValidationRefusalsDueToTimeLimit);
1587  storeAppendPrintf(sentry, "hit_validation.failures = %.0f\n",
1588  stats.hitValidationFailures);
1589 }
1590 
1591 void
1593 {
1594  // TODO: replace with delete[]
1595  for (int i = 0; i < N_COUNT_HIST; ++i)
1596  CountHist[i] = StatCounters();
1597 
1598  for (int i = 0; i < N_COUNT_HOUR_HIST; ++i)
1599  CountHourHist[i] = StatCounters();
1600 }
1601 
1602 static void
1604 {
1605 #if USE_CACHE_DIGESTS
1606  StatCounters *f = &statCounter;
1607  CachePeer *peer;
1608  const int tot_used = f->cd.times_used + f->icp.times_used;
1609 
1610  /* totals */
1611  static const SBuf label("all peers");
1612  cacheDigestGuessStatsReport(&f->cd.guess, sentry, label);
1613  /* per-peer */
1614  storeAppendPrintf(sentry, "\nPer-peer statistics:\n");
1615 
1616  for (peer = getFirstPeer(); peer; peer = getNextPeer(peer)) {
1617  if (peer->digest)
1618  peerDigestStatsReport(peer->digest, sentry);
1619  else
1620  storeAppendPrintf(sentry, "\nNo peer digest from %s\n", peer->host);
1621 
1622  storeAppendPrintf(sentry, "\n");
1623  }
1624 
1625  storeAppendPrintf(sentry, "\nAlgorithm usage:\n");
1626  storeAppendPrintf(sentry, "Cache Digest: %7d (%3d%%)\n",
1627  f->cd.times_used, xpercentInt(f->cd.times_used, tot_used));
1628  storeAppendPrintf(sentry, "Icp: %7d (%3d%%)\n",
1629  f->icp.times_used, xpercentInt(f->icp.times_used, tot_used));
1630  storeAppendPrintf(sentry, "Total: %7d (%3d%%)\n",
1631  tot_used, xpercentInt(tot_used, tot_used));
1632 #else
1633 
1634  storeAppendPrintf(sentry, "peer digests are disabled; no stats is available.\n");
1635 #endif
1636 }
1637 
1638 static void
1640 {
1641  storeAppendPrintf(sentry, "\nCounters:\n");
1642  statCountersDump(sentry);
1643  storeAppendPrintf(sentry, "\n5 Min Averages:\n");
1644  statAvgDump(sentry, 5, 0);
1645  storeAppendPrintf(sentry, "\nHistograms:\n");
1646  statCountersHistograms(sentry);
1647  storeAppendPrintf(sentry, "\nPeer Digests:\n");
1648  statPeerSelect(sentry);
1649  storeAppendPrintf(sentry, "\nLocal Digest:\n");
1650  storeDigestReport(sentry);
1651 }
1652 
1653 static double
1654 statPctileSvc(double pctile, int interval, int which)
1655 {
1656  StatCounters *f;
1657  StatCounters *l;
1658  double x;
1659  assert(interval > 0);
1660 
1661  if (interval > N_COUNT_HIST - 1)
1662  interval = N_COUNT_HIST - 1;
1663 
1664  f = &CountHist[0];
1665 
1666  l = &CountHist[interval];
1667 
1668  assert(f);
1669 
1670  assert(l);
1671 
1672  switch (which) {
1673 
1674  case PCTILE_HTTP:
1676  break;
1677 
1678  case PCTILE_HIT:
1680  break;
1681 
1682  case PCTILE_MISS:
1684  break;
1685 
1686  case PCTILE_NM:
1688  break;
1689 
1690  case PCTILE_NH:
1692  break;
1693 
1694  case PCTILE_ICP_QUERY:
1696  break;
1697 
1698  case PCTILE_DNS:
1699  x = statHistDeltaPctile(l->dns.svcTime,f->dns.svcTime, pctile);
1700  break;
1701 
1702  default:
1703  debugs(49, 5, "statPctileSvc: unknown type.");
1704  x = 0;
1705  }
1706 
1707  return x;
1708 }
1709 
1710 StatCounters *
1711 snmpStatGet(int minutes)
1712 {
1713  return &CountHist[minutes];
1714 }
1715 
1716 int
1718 {
1719  assert(N_COUNT_HIST > 5);
1721 }
1722 
1723 static double
1724 statCPUUsage(int minutes)
1725 {
1726  assert(minutes < N_COUNT_HIST);
1727  return Math::doublePercent(CountHist[0].cputime - CountHist[minutes].cputime,
1728  tvSubDsec(CountHist[minutes].timestamp, CountHist[0].timestamp));
1729 }
1730 
1731 double
1733 {
1734  assert(minutes < N_COUNT_HIST);
1735  return Math::doublePercent(CountHist[0].client_http.hits -
1736  CountHist[minutes].client_http.hits,
1738  CountHist[minutes].client_http.requests);
1739 }
1740 
1741 double
1743 {
1744  assert(minutes < N_COUNT_HIST);
1745  return Math::doublePercent(CountHist[0].client_http.mem_hits -
1746  CountHist[minutes].client_http.mem_hits,
1748  CountHist[minutes].client_http.hits);
1749 }
1750 
1751 double
1753 {
1754  assert(minutes < N_COUNT_HIST);
1755  return Math::doublePercent(CountHist[0].client_http.disk_hits -
1756  CountHist[minutes].client_http.disk_hits,
1758  CountHist[minutes].client_http.hits);
1759 }
1760 
1761 double
1762 statByteHitRatio(int minutes)
1763 {
1764  size_t s;
1765  size_t c;
1766 #if USE_CACHE_DIGESTS
1767 
1768  size_t cd;
1769 #endif
1770  /* size_t might be unsigned */
1771  assert(minutes < N_COUNT_HIST);
1773  s = CountHist[0].server.all.kbytes_in.kb - CountHist[minutes].server.all.kbytes_in.kb;
1774 #if USE_CACHE_DIGESTS
1775  /*
1776  * This ugly hack is here to prevent the user from seeing a
1777  * negative byte hit ratio. When we fetch a cache digest from
1778  * a neighbor, it gets treated like a cache miss because the
1779  * object is consumed internally. Thus, we subtract cache
1780  * digest bytes out before calculating the byte hit ratio.
1781  */
1782  cd = CountHist[0].cd.kbytes_recv.kb - CountHist[minutes].cd.kbytes_recv.kb;
1783 
1784  if (s < cd)
1785  debugs(18, DBG_IMPORTANT, "STRANGE: srv_kbytes=" << s << ", cd_kbytes=" << cd);
1786 
1787  s -= cd;
1788 
1789 #endif
1790 
1791  if (c > s)
1792  return Math::doublePercent(c - s, c);
1793  else
1794  return (-1.0 * Math::doublePercent(s - c, c));
1795 }
1796 
1797 static void
1799 {
1800  dlink_node *i;
1801  ClientHttpRequest *http;
1802  StoreEntry *e;
1803  char buf[MAX_IPSTRLEN];
1804 
1805  for (i = ClientActiveRequests.head; i; i = i->next) {
1806  const char *p = NULL;
1807  http = static_cast<ClientHttpRequest *>(i->data);
1808  assert(http);
1809  ConnStateData * conn = http->getConn();
1810  storeAppendPrintf(s, "Connection: %p\n", conn);
1811 
1812  if (conn != NULL) {
1813  const int fd = conn->clientConnection->fd;
1814  storeAppendPrintf(s, "\tFD %d, read %" PRId64 ", wrote %" PRId64 "\n", fd,
1815  fd_table[fd].bytes_read, fd_table[fd].bytes_written);
1816  storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc);
1817  storeAppendPrintf(s, "\tin: buf %p, used %ld, free %ld\n",
1818  conn->inBuf.rawContent(), (long int) conn->inBuf.length(), (long int) conn->inBuf.spaceSize());
1819  storeAppendPrintf(s, "\tremote: %s\n",
1820  conn->clientConnection->remote.toUrl(buf,MAX_IPSTRLEN));
1821  storeAppendPrintf(s, "\tlocal: %s\n",
1822  conn->clientConnection->local.toUrl(buf,MAX_IPSTRLEN));
1823  storeAppendPrintf(s, "\tnrequests: %u\n", conn->pipeline.nrequests);
1824  }
1825 
1826  storeAppendPrintf(s, "uri %s\n", http->uri);
1827  storeAppendPrintf(s, "logType %s\n", http->loggingTags().c_str());
1828  storeAppendPrintf(s, "out.offset %ld, out.size %lu\n",
1829  (long int) http->out.offset, (unsigned long int) http->out.size);
1830  storeAppendPrintf(s, "req_sz %ld\n", (long int) http->req_sz);
1831  e = http->storeEntry();
1832  storeAppendPrintf(s, "entry %p/%s\n", e, e ? e->getMD5Text() : "N/A");
1833  storeAppendPrintf(s, "start %ld.%06d (%f seconds ago)\n",
1834  (long int) http->al->cache.start_time.tv_sec,
1835  (int) http->al->cache.start_time.tv_usec,
1836  tvSubDsec(http->al->cache.start_time, current_time));
1837 #if USE_AUTH
1838  if (http->request->auth_user_request != NULL)
1839  p = http->request->auth_user_request->username();
1840  else
1841 #endif
1842  if (http->request->extacl_user.size() > 0) {
1843  p = http->request->extacl_user.termedBuf();
1844  }
1845 
1846  if (!p && conn != NULL && conn->clientConnection->rfc931[0])
1847  p = conn->clientConnection->rfc931;
1848 
1849 #if USE_OPENSSL
1850  if (!p && conn != NULL && Comm::IsConnOpen(conn->clientConnection))
1851  p = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl.get());
1852 #endif
1853 
1854  if (!p)
1855  p = dash_str;
1856 
1857  storeAppendPrintf(s, "username %s\n", p);
1858 
1859 #if USE_DELAY_POOLS
1860  storeAppendPrintf(s, "delay_pool %d\n", DelayId::DelayClient(http).pool());
1861 #endif
1862 
1863  storeAppendPrintf(s, "\n");
1864  }
1865 }
1866 
1867 #if STAT_GRAPHS
1868 /*
1869  * urgh, i don't like these, but they do cut the amount of code down immensely
1870  */
1871 
1872 #define GRAPH_PER_MIN(Y) \
1873  for (i=0;i<(N_COUNT_HIST-2);++i) { \
1874  dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \
1875  if (dt <= 0.0) \
1876  break; \
1877  storeAppendPrintf(e, "%lu,%0.2f:", \
1878  CountHist[i].timestamp.tv_sec, \
1879  ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \
1880  }
1881 
1882 #define GRAPH_PER_HOUR(Y) \
1883  for (i=0;i<(N_COUNT_HOUR_HIST-2);++i) { \
1884  dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \
1885  if (dt <= 0.0) \
1886  break; \
1887  storeAppendPrintf(e, "%lu,%0.2f:", \
1888  CountHourHist[i].timestamp.tv_sec, \
1889  ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \
1890  }
1891 
1892 #define GRAPH_TITLE(X,Y) storeAppendPrintf(e,"%s\t%s\t",X,Y);
1893 #define GRAPH_END storeAppendPrintf(e,"\n");
1894 
1895 #define GENGRAPH(X,Y,Z) \
1896  GRAPH_TITLE(Y,Z) \
1897  GRAPH_PER_MIN(X) \
1898  GRAPH_PER_HOUR(X) \
1899  GRAPH_END
1900 
1901 static void
1902 statGraphDump(StoreEntry * e)
1903 {
1904  int i;
1905  double dt;
1906 
1907  GENGRAPH(client_http.requests, "client_http.requests", "Client HTTP requests/sec");
1908  GENGRAPH(client_http.hits, "client_http.hits", "Client HTTP hits/sec");
1909  GENGRAPH(client_http.errors, "client_http.errors", "Client HTTP errors/sec");
1910  GENGRAPH(client_http.kbytes_in.kb, "client_http.kbytes_in", "Client HTTP kbytes_in/sec");
1911  GENGRAPH(client_http.kbytes_out.kb, "client_http.kbytes_out", "Client HTTP kbytes_out/sec");
1912 
1913  // TODO: http median service times
1914 
1915  GENGRAPH(server.all.requests, "server.all.requests", "Server requests/sec");
1916  GENGRAPH(server.all.errors, "server.all.errors", "Server errors/sec");
1917  GENGRAPH(server.all.kbytes_in.kb, "server.all.kbytes_in", "Server total kbytes_in/sec");
1918  GENGRAPH(server.all.kbytes_out.kb, "server.all.kbytes_out", "Server total kbytes_out/sec");
1919 
1920  GENGRAPH(server.http.requests, "server.http.requests", "Server HTTP requests/sec");
1921  GENGRAPH(server.http.errors, "server.http.errors", "Server HTTP errors/sec");
1922  GENGRAPH(server.http.kbytes_in.kb, "server.http.kbytes_in", "Server HTTP kbytes_in/sec");
1923  GENGRAPH(server.http.kbytes_out.kb, "server.http.kbytes_out", "Server HTTP kbytes_out/sec");
1924 
1925  GENGRAPH(server.ftp.requests, "server.ftp.requests", "Server FTP requests/sec");
1926  GENGRAPH(server.ftp.errors, "server.ftp.errors", "Server FTP errors/sec");
1927  GENGRAPH(server.ftp.kbytes_in.kb, "server.ftp.kbytes_in", "Server FTP kbytes_in/sec");
1928  GENGRAPH(server.ftp.kbytes_out.kb, "server.ftp.kbytes_out", "Server FTP kbytes_out/sec");
1929 
1930  GENGRAPH(server.other.requests, "server.other.requests", "Server other requests/sec");
1931  GENGRAPH(server.other.errors, "server.other.errors", "Server other errors/sec");
1932  GENGRAPH(server.other.kbytes_in.kb, "server.other.kbytes_in", "Server other kbytes_in/sec");
1933  GENGRAPH(server.other.kbytes_out.kb, "server.other.kbytes_out", "Server other kbytes_out/sec");
1934 
1935  GENGRAPH(icp.pkts_sent, "icp.pkts_sent", "ICP packets sent/sec");
1936  GENGRAPH(icp.pkts_recv, "icp.pkts_recv", "ICP packets received/sec");
1937  GENGRAPH(icp.kbytes_sent.kb, "icp.kbytes_sent", "ICP kbytes_sent/sec");
1938  GENGRAPH(icp.kbytes_recv.kb, "icp.kbytes_recv", "ICP kbytes_received/sec");
1939 
1940  // TODO: icp median service times
1941  // TODO: dns median service times
1942 
1943  GENGRAPH(unlink.requests, "unlink.requests", "Cache File unlink requests/sec");
1944  GENGRAPH(page_faults, "page_faults", "System Page Faults/sec");
1945  GENGRAPH(select_loops, "select_loops", "System Select Loop calls/sec");
1946  GENGRAPH(cputime, "cputime", "CPU utilisation");
1947 }
1948 
1949 #endif /* STAT_GRAPHS */
1950 
1951 int
1953 {
1954  return memPoolsTotalAllocated();
1955 }
1956 
double current_dtime
the current UNIX time in seconds (with microsecond precision)
Definition: stub_libtime.cc:19
double tvSubDsec(struct timeval t1, struct timeval t2)
Definition: gadgets.cc:44
static DelayId DelayClient(ClientHttpRequest *, HttpReply *reply=nullptr)
Definition: DelayId.cc:67
struct timeval squid_start
char * buf
Definition: MemBuf.h:134
class Ping::pingStats_ stats
virtual void buffer()
Definition: store.cc:1579
static Pointer Create(const CommandPointer &cmd)
PeerDigest * digest
Definition: CachePeer.h:142
static int statObjectsOpenfdFilter(const StoreEntry *e)
Definition: stat.cc:417
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
#define DBG_CRITICAL
Definition: Stream.h:40
static OBJH statClientRequests
Definition: stat.cc:95
#define INCOMING_TCP_MAX
Definition: Loops.h:69
static const int histSize
Definition: IoStats.h:16
uint64_t refusalsDueToZeroSize
Definition: StatCounters.h:163
struct IoStats::@78 Http
uint64_t refusalsDueToLocking
Definition: StatCounters.h:162
double statByteHitRatio(int minutes)
Definition: stat.cc:1762
StatCounters CountHist[N_COUNT_HIST]
Definition: stat.cc:114
struct StatCounters::@137 hitValidation
#define LOCAL_ARRAY(type, name, size)
Definition: squid.h:75
ByteCounter r_kbytes_recv
Definition: StatCounters.h:81
mb_size_t size
Definition: MemBuf.h:135
struct StatCounters::@128::@138 ftp
int reads
Definition: IoStats.h:19
@ PCTILE_ICP_QUERY
Definition: enums.h:165
ByteCounter hit_kbytes_out
Definition: StatCounters.h:47
virtual void flush()
Definition: store.cc:1590
MemObject * mem_obj
Definition: Store.h:219
StatHist nearHitSvcTime
Definition: StatCounters.h:50
static void statCountersInitSpecial(StatCounters *C)
Definition: stat.cc:1228
CacheDigestGuessStats guess
Definition: StatCounters.h:109
ConnStateData * getConn() const
int KidIdentifier
ByteCounter memory
Definition: StatCounters.h:105
@ KEY_PRIVATE
Definition: enums.h:102
@ ENTRY_FWD_HDR_WAIT
Definition: enums.h:111
struct StatCounters::@133 cd
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:830
void lock(const char *context)
Definition: store.cc:420
store size histograms of network read() from peer server
Definition: IoAction.h:22
static void DumpStats(StoreEntry *)
Definition: fde.cc:96
StatHist replySvcTime
Definition: StatCounters.h:83
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
int replies_queued
Definition: StatCounters.h:74
void init(mb_size_t szInit, mb_size_t szMax)
Definition: MemBuf.cc:93
store service times for 5 and 60 min
Definition: SBuf.h:87
StoreIOState::Pointer sio
Definition: MemObject.h:152
@ PCTILE_HTTP
Definition: enums.h:164
void DumpInfo(Mgr::InfoActionData &stats, StoreEntry *sentry)
Definition: stat.cc:572
int Opening_FD
int objectsPerBucket
Definition: SquidConfig.h:269
int memPoolGetGlobalStats(MemPoolGlobalStats *stats)
Definition: Pool.cc:249
double request_failure_ratio
void DumpCountersStats(Mgr::CountersActionData &stats, StoreEntry *sentry)
Definition: stat.cc:1456
SBuf service_name(APP_SHORTNAME)
int aborted_requests
Definition: StatCounters.h:152
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
const char * pingStatusStr[]
Definition: store.cc:78
CachePeer * getNextPeer(CachePeer *p)
Definition: neighbors.cc:501
struct ClientHttpRequest::Out out
virtual void append(const char *c, int sz)
Definition: MemBuf.cc:209
uint16_t flags
Definition: Store.h:230
struct StatCounters::@130 htcp
void cacheDigestGuessStatsReport(const CacheDigestGuessStats *stats, StoreEntry *sentry, const SBuf &label)
Definition: CacheDigest.cc:209
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:27
IoStats IOStats
const char * sslGetUserEmail(SSL *ssl)
Definition: support.cc:876
int locks() const
returns a local concurrent use counter, for debugging
Definition: Store.h:267
static int NCountHist
Definition: stat.cc:115
struct IoStats::@78 Gopher
MemPoolMeter * TheMeter
Definition: Pool.h:304
struct StatCounters::@131 unlink
#define XAVG(X)
Definition: stat.cc:881
String extacl_user
Definition: HttpRequest.h:178
static double statPctileSvc(double, int, int)
Definition: stat.cc:1654
int stat5minClientRequests(void)
Definition: stat.cc:1717
double statHistDeltaMedian(const StatHist &A, const StatHist &B)
Definition: StatHist.cc:91
double select_time
Definition: StatCounters.h:120
uint64_t failures
Definition: StatCounters.h:165
mgb_t gb_freed
Definition: Pool.h:110
static void statCountersInit(StatCounters *C)
Definition: stat.cc:1258
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:66
struct StatCounters::@128 server
static void statAvgDump(StoreEntry *, int minutes, int hours)
Definition: stat.cc:874
number
Definition: testStatHist.cc:16
size_t kb
Definition: ByteCounter.h:25
ByteCounter kbytes_sent
Definition: StatCounters.h:76
const char * swapStatusStr[]
Definition: store.cc:89
void peerDigestStatsReport(const PeerDigest *pd, StoreEntry *e)
static Pointer Create(const CommandPointer &cmd)
#define APP_SHORTNAME
Definition: version.h:22
@ PCTILE_DNS
Definition: enums.h:166
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
@ ENTRY_ABORTED
Definition: enums.h:115
static void statStoreEntry(MemBuf *mb, StoreEntry *e)
Definition: stat.cc:323
@ ENTRY_BAD_LENGTH
Definition: enums.h:114
const char * version_string
const char * FormatRfc1123(time_t)
Definition: rfc1123.cc:202
double doublePercent(const double, const double)
Definition: SquidMath.cc:25
static StatCounters CountHourHist[N_COUNT_HOUR_HIST]
Definition: stat.cc:116
#define INCOMING_UDP_MAX
Definition: Loops.h:50
static Pointer Create5min(const CommandPointer &cmd)
ByteCounter kbytes_in
Definition: StatCounters.h:45
StatHist nearMissSvcTime
Definition: StatCounters.h:49
int size
Definition: ModDevPoll.cc:75
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:17
StatHist svcTime
Definition: StatCounters.h:98
void OBJH(StoreEntry *)
Definition: forward.h:44
#define NULL
Definition: types.h:166
static void CredentialsCacheStats(StoreEntry *output)
Definition: User.cc:243
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:32
store traffic and resource counters
struct StatCounters::@127 client_http
int rusage_pagefaults(struct rusage *r)
Definition: tools.cc:271
double cputime
Definition: StatCounters.h:121
@ PCTILE_NM
Definition: enums.h:169
@ ENTRY_VALIDATED
Definition: enums.h:113
void dump(StoreEntry *sentry, StatHistBinDumper *bd) const
Definition: StatHist.cc:171
uint16_t refcount
Definition: Store.h:229
sdirno swap_dirn
Definition: Store.h:236
Definition: MemBuf.h:24
static double xm_time
Definition: old_api.cc:41
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
@ RELEASE_REQUEST
prohibits making the key public
Definition: enums.h:98
unsigned int mem_pool_free_calls
void clean()
Definition: MemBuf.cc:110
StatHist hitSvcTime
Definition: StatCounters.h:51
ping_status_t ping_status
Definition: Store.h:240
static OBJH statCountersHistograms
Definition: stat.cc:94
#define N_COUNT_HIST
Definition: defines.h:121
int unlock(const char *context)
Definition: store.cc:444
CachePeer * getFirstPeer(void)
Definition: neighbors.cc:507
const char * storeEntryFlags(const StoreEntry *entry)
Definition: stat.cc:270
store_status_t store_status
Definition: Store.h:242
double statHistDeltaPctile(const StatHist &A, const StatHist &B, double pctile)
Definition: StatHist.cc:97
static Pointer Create(const CommandPointer &cmd)
Definition: IoAction.cc:46
int conn
the current server connection FD
Definition: Transport.cc:26
const char * dash_str
#define assert(EX)
Definition: assert.h:19
char const * termedBuf() const
Definition: SquidString.h:92
@ DELAY_SENDING
Definition: enums.h:97
StatHist missSvcTime
Definition: StatCounters.h:48
#define INCOMING_DNS_MAX
Definition: Loops.h:59
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Controller.cc:111
size_t high_memory
Definition: SquidConfig.h:514
void DumpAvgStat(Mgr::IntervalActionData &stats, StoreEntry *sentry)
Definition: stat.cc:1019
int memPoolsTotalAllocated(void)
Definition: Pool.cc:298
static uint32 C
Definition: md4.c:43
unsigned int mem_pool_alloc_calls
void GetCountersStats(Mgr::CountersActionData &stats)
Definition: stat.cc:1374
virtual bool isDone() const =0
virtual StoreEntry * currentItem()=0
static void statObjectsStart(StoreEntry *sentry, STOBJFLT *filter)
Definition: stat.cc:386
void squid_getrusage(struct rusage *r)
Definition: tools.cc:177
@ ENTRY_SPECIAL
Definition: enums.h:84
static double xm_deltat
Definition: old_api.cc:42
mem_status_t mem_status
Definition: Store.h:238
static OBJH statCountersDump
Definition: stat.cc:90
int STOBJFLT(const StoreEntry *)
Definition: stat.cc:64
StoreSearch * search()
Definition: Controller.cc:211
#define CBDATA_CLASS_INIT(type)
Definition: cbdata.h:318
uint64_t attempts
Definition: StatCounters.h:161
static OBJH statDigestBlob
Definition: stat.cc:92
uint64_t size
Response header and body bytes written to the client connection.
static void statRegisterWithCacheManager(void)
Definition: stat.cc:1183
int Squid_MaxFD
void storeDigestReport(StoreEntry *e)
void EVH(void *)
Definition: event.h:18
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
@ PCTILE_MISS
Definition: enums.h:168
swap_status_t swap_status
Definition: Store.h:244
static EVH statObjects
Definition: stat.cc:89
struct SquidConfig::@120 warnings
int rusage_maxrss(struct rusage *r)
Definition: tools.cc:250
#define fd_table
Definition: fde.h:189
void complete()
Definition: store.cc:1006
StatHist select_fds_hist
Definition: StatCounters.h:127
void DumpServiceTimesStats(Mgr::ServiceTimesActionData &stats, StoreEntry *sentry)
Definition: stat.cc:824
StoreEntry * sentry
Definition: stat.cc:68
double rusage_cputime(struct rusage *r)
Definition: tools.cc:235
struct IoStats::@78 Ftp
void DumpIoStats(Mgr::IoActionData &stats, StoreEntry *sentry)
Definition: stat.cc:212
static OBJH stat_vmobjects_get
Definition: stat.cc:87
StoreSearchPointer theSearch
Definition: stat.cc:73
struct StatCounters::@129 icp
char * host
Definition: CachePeer.h:40
StatHist allSvcTime
Definition: StatCounters.h:52
unsigned long int select_loops
Definition: StatCounters.h:118
bool checkDeferRead(int fd) const
Definition: store.cc:228
struct StatCounters::@128::@138 http
uint64_t refusalsDueToTimeLimit
Definition: StatCounters.h:164
struct SquidConfig::@110 onoff
ByteCounter q_kbytes_sent
Definition: StatCounters.h:77
void GetIoStats(Mgr::IoActionData &stats)
Definition: stat.cc:188
static char server[MAXLINE]
size_type size() const
Definition: SquidString.h:73
void GetAvgStat(Mgr::IntervalActionData &stats, int minutes, int hours)
Definition: stat.cc:883
const char * memStatusStr[]
Definition: store.cc:73
void DumpMallocStatistics(StoreEntry *sentry)
Definition: stat.cc:782
@ PCTILE_NH
Definition: enums.h:170
char const * username() const
Definition: UserRequest.cc:32
int fdNFree(void)
Definition: fd.cc:265
struct StatCounters::@128::@138 all
double statRequestHitMemoryRatio(int minutes)
Definition: stat.cc:1742
int RESERVED_FD
static Pointer Create(const CommandPointer &cmd)
Definition: InfoAction.cc:105
ByteCounter q_kbytes_recv
Definition: StatCounters.h:80
size_t req_sz
raw request size on input, not current request size
#define DBG_IMPORTANT
Definition: Stream.h:41
StatHist querySvcTime
Definition: StatCounters.h:82
@ REFRESH_REQUEST
Definition: enums.h:99
CacheDigest * store_digest
StatCounters * snmpStatGet(int minutes)
Definition: stat.cc:1711
const AccessLogEntry::Pointer al
access.log entry
SQUIDCEXTERN double xdiv(double nom, double denom)
Definition: util.c:53
#define PRId64
Definition: types.h:110
struct StatCounters::@136 swap
virtual void append(char const *, int)
Appends a c-string to existing packed data.
Definition: store.cc:778
double statRequestHitRatio(int minutes)
Definition: stat.cc:1732
#define N_COUNT_HOUR_HIST
Definition: defines.h:125
@ ENTRY_DISPATCHED
Definition: enums.h:101
int query_timeouts
Definition: StatCounters.h:84
@ ENTRY_REVALIDATE_STALE
Definition: enums.h:100
static OBJH statPeerSelect
Definition: stat.cc:91
@ ENTRY_NEGCACHED
Definition: enums.h:112
StoreEntry * storeEntry() const
@ PCTILE_HIT
Definition: enums.h:167
uint32_t mask_size
Definition: CacheDigest.h:59
@ ENTRY_REVALIDATE_ALWAYS
Definition: enums.h:85
const char * storeStatusStr[]
Definition: store.cc:84
#define COUNT_INTERVAL
Definition: defines.h:117
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:693
static int statObjectsVmFilter(const StoreEntry *e)
Definition: stat.cc:405
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
static int NCountHourHist
Definition: stat.cc:117
static Pointer Create60min(const CommandPointer &cmd)
static void statAvgTick(void *notused)
Definition: stat.cc:1289
mgb_t gb_saved
Definition: Pool.h:107
void GetServiceTimesStats(Mgr::ServiceTimesActionData &stats)
Definition: stat.cc:796
static OBJH statOpenfdObj
Definition: stat.cc:88
int read_hist[histSize]
Definition: IoStats.h:21
ByteCounter kbytes_out
Definition: StatCounters.h:46
void statFreeMemory(void)
Definition: stat.cc:1592
double statRequestHitDiskRatio(int minutes)
Definition: stat.cc:1752
SQUIDCEXTERN int xpercentInt(double part, double whole)
Definition: util.c:46
struct StatCounters::@132 dns
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
ByteCounter kbytes_recv
Definition: StatCounters.h:79
STOBJFLT * filter
Definition: stat.cc:72
void stat(MemBuf *mb) const
Definition: MemObject.cc:191
const char * describeTimestamps() const
Definition: store.cc:1963
int CacheDigestHashFuncCount
int Number_FD
void GetInfo(Mgr::InfoActionData &stats)
Definition: stat.cc:448
int statMemoryAccounted(void)
Definition: stat.cc:1952
static OBJH stat_objects_get
Definition: stat.cc:86
const char * getMD5Text() const
Definition: store.cc:204
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:107
int Biggest_FD
struct timeval timestamp
Definition: StatCounters.h:123
#define SQUIDSBUFPH
Definition: SBuf.h:31
double count
Definition: Pool.h:84
struct StatCounters::@128::@138 other
class SquidConfig Config
Definition: SquidConfig.cc:12
static const char * describeStatuses(const StoreEntry *)
Definition: stat.cc:258
int unsigned int
Definition: stub_fd.cc:19
int storePendingNClients(const StoreEntry *e)
HttpRequest *const request
struct SquidConfig::@108 Store
StatCounters statCounter
Definition: StatCounters.cc:12
static double statCPUUsage(int minutes)
Definition: stat.cc:1724
ByteCounter r_kbytes_sent
Definition: StatCounters.h:78
void statInit(void)
Definition: stat.cc:1266
static OBJH statUtilization
Definition: stat.cc:93
SwapOut swapout
Definition: MemObject.h:159
sfileno swap_filen
unique ID inside a cache_dir for swapped out entries; -1 for others
Definition: Store.h:234
Controller & Root()
safely access controller singleton
Definition: Controller.cc:934

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors