/*
- * DEBUG: section 18 Cache Manager Statistics
- * AUTHOR: Harvest Derived
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 18 Cache Manager Statistics */
+
#include "squid.h"
#include "CacheDigest.h"
#include "CachePeer.h"
#include "fde.h"
#include "format/Token.h"
#include "globals.h"
+#include "http/Stream.h"
#include "HttpRequest.h"
#include "IoStats.h"
+#include "mem/Pool.h"
#include "mem_node.h"
#include "MemBuf.h"
#include "MemObject.h"
#include "store_digest.h"
#include "StoreClient.h"
#include "tools.h"
+// for tvSubDsec() which should be in SquidTime.h
+#include "util.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#endif
#if USE_DELAY_POOLS
#include "DelayId.h"
#endif
-#if USE_SSL
+#if USE_OPENSSL
#include "ssl/support.h"
#endif
class StatObjectsState
{
+ CBDATA_CLASS(StatObjectsState);
public:
StoreEntry *sentry;
STOBJFLT *filter;
StoreSearchPointer theSearch;
-
-private:
- CBDATA_CLASS2(StatObjectsState);
};
/* LOCALS */
static const char *describeStatuses(const StoreEntry *);
-static const char *describeTimestamps(const StoreEntry *);
static void statAvgTick(void *notused);
static void statAvgDump(StoreEntry *, int minutes, int hours);
#if STAT_GRAPHS
if (EBIT_TEST(flags, ENTRY_SPECIAL))
strcat(buf, "SPECIAL,");
- if (EBIT_TEST(flags, ENTRY_REVALIDATE))
- strcat(buf, "REVALIDATE,");
+ if (EBIT_TEST(flags, ENTRY_REVALIDATE_ALWAYS))
+ strcat(buf, "REVALIDATE_ALWAYS,");
if (EBIT_TEST(flags, DELAY_SENDING))
strcat(buf, "DELAY_SENDING,");
if (EBIT_TEST(flags, REFRESH_REQUEST))
strcat(buf, "REFRESH_REQUEST,");
+ if (EBIT_TEST(flags, ENTRY_REVALIDATE_STALE))
+ strcat(buf, "REVALIDATE_STALE,");
+
if (EBIT_TEST(flags, ENTRY_DISPATCHED))
strcat(buf, "DISPATCHED,");
return buf;
}
-static const char *
-describeTimestamps(const StoreEntry * entry)
-{
- LOCAL_ARRAY(char, buf, 256);
- snprintf(buf, 256, "LV:%-9d LU:%-9d LM:%-9d EX:%-9d",
- (int) entry->timestamp,
- (int) entry->lastref,
- (int) entry->lastmod,
- (int) entry->expires);
- return buf;
-}
-
static void
statStoreEntry(MemBuf * mb, StoreEntry * e)
{
MemObject *mem = e->mem_obj;
- mb->Printf("KEY %s\n", e->getMD5Text());
- mb->Printf("\t%s\n", describeStatuses(e));
- mb->Printf("\t%s\n", storeEntryFlags(e));
- mb->Printf("\t%s\n", describeTimestamps(e));
- mb->Printf("\t%d locks, %d clients, %d refs\n",
- (int) e->locks(),
- storePendingNClients(e),
- (int) e->refcount);
- mb->Printf("\tSwap Dir %d, File %#08X\n",
- e->swap_dirn, e->swap_filen);
+ mb->appendf("KEY %s\n", e->getMD5Text());
+ mb->appendf("\t%s\n", describeStatuses(e));
+ mb->appendf("\t%s\n", storeEntryFlags(e));
+ mb->appendf("\t%s\n", e->describeTimestamps());
+ mb->appendf("\t%d locks, %d clients, %d refs\n", (int) e->locks(), storePendingNClients(e), (int) e->refcount);
+ mb->appendf("\tSwap Dir %d, File %#08X\n", e->swap_dirn, e->swap_filen);
if (mem != NULL)
mem->stat (mb);
- mb->Printf("\n");
+ mb->append("\n", 1);
}
/* process objects list */
storeAppendPrintf(state->sentry, "} by kid%d\n\n", KidIdentifier);
state->sentry->complete();
state->sentry->unlock("statObjects+isDone");
- cbdataFree(state);
+ delete state;
return;
} else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) {
state->sentry->unlock("statObjects+aborted");
- cbdataFree(state);
+ delete state;
return;
} else if (state->sentry->checkDeferRead(-1)) {
state->sentry->flush();
state->filter = filter;
sentry->lock("statObjects");
- state->theSearch = Store::Root().search(NULL, NULL);
+ state->theSearch = Store::Root().search();
eventAdd("statObjects", statObjects, state, 0.0, 1);
}
double cputime;
double runtime;
#if HAVE_MSTATS && HAVE_GNUMALLOC_H
-
struct mstats ms;
-#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- struct mallinfo mp;
#endif
runtime = tvSubDsec(squid_start, current_time);
stats.cpu_usage5 = statCPUUsage(5);
stats.cpu_usage60 = statCPUUsage(60);
-#if HAVE_SBRK
-
- stats.proc_data_seg = ((char *) sbrk(0) - (char *) sbrk_start);
-
-#endif
-
stats.maxrss = rusage_maxrss(&rusage);
stats.page_faults = rusage_pagefaults(&rusage);
stats.ms_bytes_free = ms.bytes_free;
-#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- mp = mallinfo();
-
- stats.mp_arena = mp.arena;
-
- stats.mp_uordblks = mp.uordblks;
- stats.mp_ordblks = mp.ordblks;
-
- stats.mp_usmblks = mp.usmblks;
- stats.mp_smblks = mp.smblks;
-
- stats.mp_hblkhd = mp.hblkhd;
- stats.mp_hblks = mp.hblks;
-
- stats.mp_fsmblks = mp.fsmblks;
-
- stats.mp_fordblks = mp.fordblks;
-
-#if HAVE_STRUCT_MALLINFO_MXFAST
-
- stats.mp_mxfast = mp.mxfast;
-
- stats.mp_nlblks = mp.nlblks;
-
- stats.mp_grain = mp.grain;
-
- stats.mp_uordbytes = mp.uordbytes;
-
- stats.mp_allocated = mp.allocated;
-
- stats.mp_treeoverhead = mp.treeoverhead;
-
-#endif /* HAVE_STRUCT_MALLINFO_MXFAST */
-#endif /* HAVE_MALLINFO */
+#endif
stats.total_accounted = statMemoryAccounted();
{
MemPoolGlobalStats mp_stats;
memPoolGetGlobalStats(&mp_stats);
-#if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- stats.mem_pool_allocated = mp_stats.TheMeter->alloc.level;
-#endif
-
stats.gb_saved_count = mp_stats.TheMeter->gb_saved.count;
stats.gb_freed_count = mp_stats.TheMeter->gb_freed.count;
}
#if _SQUID_WINDOWS_
if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
- storeAppendPrintf(sentry,"\nRunning as %s Windows System Service on %s\n",
- Service_name, WIN32_OS_string);
+ storeAppendPrintf(sentry,"\nRunning as " SQUIDSBUFPH " Windows System Service on %s\n",
+ SQUIDSBUFPRINT(service_name), WIN32_OS_string);
storeAppendPrintf(sentry,"Service command line is: %s\n", WIN32_Service_Command_Line);
} else
storeAppendPrintf(sentry,"Running on %s\n",WIN32_OS_string);
#else
- storeAppendPrintf(sentry,"Service Name: %s\n", service_name);
+ storeAppendPrintf(sentry,"Service Name: " SQUIDSBUFPH "\n", SQUIDSBUFPRINT(service_name));
#endif
storeAppendPrintf(sentry, "Start Time:\t%s\n",
storeAppendPrintf(sentry, "Connection information for %s:\n",APP_SHORTNAME);
- storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%.0f\n",
- stats.client_http_clients);
+ if (Config.onoff.client_db)
+ storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%.0f\n", stats.client_http_clients);
+ else
+ sentry->append("\tNumber of clients accessing cache:\t(client_db off)\n", 52);
storeAppendPrintf(sentry, "\tNumber of HTTP requests received:\t%.0f\n",
stats.client_http_requests);
storeAppendPrintf(sentry, "\tCPU Usage, 60 minute avg:\t%.2f%%\n",
stats.cpu_usage60);
-#if HAVE_SBRK
-
- storeAppendPrintf(sentry, "\tProcess Data Segment Size via sbrk(): %.0f KB\n",
- stats.proc_data_seg / 1024);
-
-#endif
-
storeAppendPrintf(sentry, "\tMaximum Resident Size: %.0f KB\n",
stats.maxrss);
stats.ms_bytes_free / 1024,
Math::doublePercent(stats.ms_bytes_free, stats.ms_bytes_total));
-#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- storeAppendPrintf(sentry, "Memory usage for %s via mallinfo():\n",APP_SHORTNAME);
-
- storeAppendPrintf(sentry, "\tTotal space in arena: %6.0f KB\n",
- stats.mp_arena / 1024);
-
- storeAppendPrintf(sentry, "\tOrdinary blocks: %6.0f KB %6.0f blks\n",
- stats.mp_uordblks / 1024, stats.mp_ordblks);
-
- storeAppendPrintf(sentry, "\tSmall blocks: %6.0f KB %6.0f blks\n",
- stats.mp_usmblks / 1024, stats.mp_smblks);
-
- storeAppendPrintf(sentry, "\tHolding blocks: %6.0f KB %6.0f blks\n",
- stats.mp_hblkhd / 1024, stats.mp_hblks);
-
- storeAppendPrintf(sentry, "\tFree Small blocks: %6.0f KB\n",
- stats.mp_fsmblks / 1024);
-
- storeAppendPrintf(sentry, "\tFree Ordinary blocks: %6.0f KB\n",
- stats.mp_fordblks / 1024);
-
- double t = stats.mp_fsmblks + stats.mp_fordblks;
-
- storeAppendPrintf(sentry, "\tTotal in use: %6.0f KB %.0f%%\n",
- t / 1024, Math::doublePercent(t, stats.mp_arena + stats.mp_hblkhd));
-
- t = stats.mp_fsmblks + stats.mp_fordblks;
-
- storeAppendPrintf(sentry, "\tTotal free: %6.0f KB %.0f%%\n",
- t / 1024, Math::doublePercent(t, stats.mp_arena + stats.mp_hblkhd));
-
- t = stats.mp_arena + stats.mp_hblkhd;
-
- storeAppendPrintf(sentry, "\tTotal size: %6.0f KB\n",
- t / 1024);
-
-#if HAVE_STRUCT_MALLINFO_MXFAST
-
- storeAppendPrintf(sentry, "\tmax size of small blocks:\t%.0f\n", stats.mp_mxfast);
-
- storeAppendPrintf(sentry, "\tnumber of small blocks in a holding block:\t%.0f\n",
- stats.mp_nlblks);
-
- storeAppendPrintf(sentry, "\tsmall block rounding factor:\t%.0f\n", stats.mp_grain);
-
- storeAppendPrintf(sentry, "\tspace (including overhead) allocated in ord. blks:\t%.0f\n"
- ,stats.mp_uordbytes);
-
- storeAppendPrintf(sentry, "\tnumber of ordinary blocks allocated:\t%.0f\n",
- stats.mp_allocated);
-
- storeAppendPrintf(sentry, "\tbytes used in maintaining the free tree:\t%.0f\n",
- stats.mp_treeoverhead);
-
-#endif /* HAVE_STRUCT_MALLINFO_MXFAST */
-#endif /* HAVE_MALLINFO */
+#endif
storeAppendPrintf(sentry, "Memory accounted for:\n");
-
-#if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- storeAppendPrintf(sentry, "\tTotal accounted: %6.0f KB %3.0f%%\n",
- stats.total_accounted / 1024, Math::doublePercent(stats.total_accounted, t));
-
-#else
-
storeAppendPrintf(sentry, "\tTotal accounted: %6.0f KB\n",
stats.total_accounted / 1024);
-
-#endif
{
MemPoolGlobalStats mp_stats;
memPoolGetGlobalStats(&mp_stats);
-#if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- storeAppendPrintf(sentry, "\tmemPool accounted: %6.0f KB %3.0f%%\n",
- stats.mem_pool_allocated / 1024,
- Math::doublePercent(stats.mem_pool_allocated, t));
-
- const double iFree = max(0.0, t - stats.mem_pool_allocated);
- storeAppendPrintf(sentry, "\tmemPool unaccounted: %6.0f KB %3.0f%%\n",
- (t - stats.mem_pool_allocated) / 1024,
- Math::doublePercent(iFree, t));
-#endif
-
storeAppendPrintf(sentry, "\tmemPoolAlloc calls: %9.0f\n",
stats.gb_saved_count);
storeAppendPrintf(sentry, "\tmemPoolFree calls: %9.0f\n",
DumpMallocStatistics(StoreEntry* sentry)
{
#if XMALLOC_STATISTICS
-
xm_deltat = current_dtime - xm_time;
xm_time = current_dtime;
storeAppendPrintf(sentry, "\nMemory allocation statistics\n");
#if USE_AUTH
Mgr::RegisterAction("username_cache",
"Active Cached Usernames",
- Auth::User::UsernameCacheStats, 0, 1);
+ Auth::User::CredentialsCacheStats, 0, 1);
#endif
#if DEBUG_OPENFD
Mgr::RegisterAction("openfd_objects", "Objects with Swapout files open",
}
static void
-statAvgTick(void *notused)
+statAvgTick(void *)
{
StatCounters *t = &CountHist[0];
StatCounters *p = &CountHist[1];
if (Config.warnings.high_memory) {
size_t i = 0;
#if HAVE_MSTATS && HAVE_GNUMALLOC_H
-
struct mstats ms = mstats();
i = ms.bytes_total;
-#elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO
-
- struct mallinfo mp = mallinfo();
- i = mp.arena;
-#elif HAVE_SBRK
-
- i = (size_t) ((char *) sbrk(0) - (char *) sbrk_start);
#endif
-
if (Config.warnings.high_memory < i)
debugs(18, DBG_CRITICAL, "WARNING: Memory usage at " << ((unsigned long int)(i >> 20)) << " MB");
}
C->comm_udp_incoming.enumInit(INCOMING_UDP_MAX);
C->comm_dns_incoming.enumInit(INCOMING_DNS_MAX);
C->comm_tcp_incoming.enumInit(INCOMING_TCP_MAX);
- C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
+ C->select_fds_hist.enumInit(256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
}
/* add special cases here as they arrive */
storeAppendPrintf(s, "\tFD %d, read %" PRId64 ", wrote %" PRId64 "\n", fd,
fd_table[fd].bytes_read, fd_table[fd].bytes_written);
storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc);
- storeAppendPrintf(s, "\tin: buf %p, offset %ld, size %ld\n",
- conn->in.buf, (long int) conn->in.notYetUsed, (long int) conn->in.allocatedSize);
+ storeAppendPrintf(s, "\tin: buf %p, used %ld, free %ld\n",
+ conn->inBuf.rawContent(), (long int) conn->inBuf.length(), (long int) conn->inBuf.spaceSize());
storeAppendPrintf(s, "\tremote: %s\n",
conn->clientConnection->remote.toUrl(buf,MAX_IPSTRLEN));
storeAppendPrintf(s, "\tlocal: %s\n",
conn->clientConnection->local.toUrl(buf,MAX_IPSTRLEN));
- storeAppendPrintf(s, "\tnrequests: %d\n",
- conn->nrequests);
+ storeAppendPrintf(s, "\tnrequests: %u\n", conn->pipeline.nrequests);
}
storeAppendPrintf(s, "uri %s\n", http->uri);
- storeAppendPrintf(s, "logType %s\n", LogTags_str[http->logType]);
+ storeAppendPrintf(s, "logType %s\n", http->logType.c_str());
storeAppendPrintf(s, "out.offset %ld, out.size %lu\n",
(long int) http->out.offset, (unsigned long int) http->out.size);
storeAppendPrintf(s, "req_sz %ld\n", (long int) http->req_sz);
if (!p && conn != NULL && conn->clientConnection->rfc931[0])
p = conn->clientConnection->rfc931;
-#if USE_SSL
-
+#if USE_OPENSSL
if (!p && conn != NULL && Comm::IsConnOpen(conn->clientConnection))
- p = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl);
-
+ p = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl.get());
#endif
if (!p)
#define GRAPH_PER_MIN(Y) \
for (i=0;i<(N_COUNT_HIST-2);++i) { \
- dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \
- if (dt <= 0.0) \
- break; \
- storeAppendPrintf(e, "%lu,%0.2f:", \
- CountHist[i].timestamp.tv_sec, \
- ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \
+ dt = tvSubDsec(CountHist[i+1].timestamp, CountHist[i].timestamp); \
+ if (dt <= 0.0) \
+ break; \
+ storeAppendPrintf(e, "%lu,%0.2f:", \
+ CountHist[i].timestamp.tv_sec, \
+ ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \
}
#define GRAPH_PER_HOUR(Y) \
for (i=0;i<(N_COUNT_HOUR_HIST-2);++i) { \
- dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \
- if (dt <= 0.0) \
- break; \
- storeAppendPrintf(e, "%lu,%0.2f:", \
- CountHourHist[i].timestamp.tv_sec, \
- ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \
+ dt = tvSubDsec(CountHourHist[i+1].timestamp, CountHourHist[i].timestamp); \
+ if (dt <= 0.0) \
+ break; \
+ storeAppendPrintf(e, "%lu,%0.2f:", \
+ CountHourHist[i].timestamp.tv_sec, \
+ ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \
}
#define GRAPH_TITLE(X,Y) storeAppendPrintf(e,"%s\t%s\t",X,Y);
{
return memPoolsTotalAllocated();
}
+