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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors