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