*/
#include "squid-old.h"
+#include "StatCounters.h"
#include "Store.h"
#if USE_CACHE_DIGESTS
on_xition_cnt++;
}
- statHistCount(&statCounter.cd.on_xition_count, on_xition_cnt);
+ statCounter.cd.on_xition_count.count(on_xition_cnt);
}
#endif
cd->count++;
}
void
-cacheDigestGuessStatsUpdate(cd_guess_stats * stats, int real_hit, int guess_hit)
+cacheDigestGuessStatsUpdate(CacheDigestGuessStats * stats, int real_hit, int guess_hit)
{
assert(stats);
if (real_hit) {
if (guess_hit)
- stats->true_hits++;
+ ++stats->trueHits;
else
- stats->false_misses++;
+ ++stats->falseMisses;
} else {
if (guess_hit)
- stats->false_hits++;
+ ++stats->falseHits;
else
- stats->true_misses++;
+ ++stats->trueMisses;
}
}
void
-cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, const char *label)
+cacheDigestGuessStatsReport(const CacheDigestGuessStats * stats, StoreEntry * sentry, const char *label)
{
- const int true_count = stats->true_hits + stats->true_misses;
- const int false_count = stats->false_hits + stats->false_misses;
- const int hit_count = stats->true_hits + stats->false_hits;
- const int miss_count = stats->true_misses + stats->false_misses;
+ const int true_count = stats->trueHits + stats->trueMisses;
+ const int false_count = stats->falseHits + stats->falseMisses;
+ const int hit_count = stats->trueHits + stats->falseHits;
+ const int miss_count = stats->trueMisses + stats->falseMisses;
const int tot_count = true_count + false_count;
assert(label);
storeAppendPrintf(sentry, "guess\t hit\t\t miss\t\t total\t\t\n");
storeAppendPrintf(sentry, " \t #\t %%\t #\t %%\t #\t %%\t\n");
storeAppendPrintf(sentry, "true\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n",
- stats->true_hits, xpercent(stats->true_hits, tot_count),
- stats->true_misses, xpercent(stats->true_misses, tot_count),
+ stats->trueHits, xpercent(stats->trueHits, tot_count),
+ stats->trueMisses, xpercent(stats->trueMisses, tot_count),
true_count, xpercent(true_count, tot_count));
storeAppendPrintf(sentry, "false\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n",
- stats->false_hits, xpercent(stats->false_hits, tot_count),
- stats->false_misses, xpercent(stats->false_misses, tot_count),
+ stats->falseHits, xpercent(stats->falseHits, tot_count),
+ stats->falseMisses, xpercent(stats->falseMisses, tot_count),
false_count, xpercent(false_count, tot_count));
storeAppendPrintf(sentry, "all\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n",
hit_count, xpercent(hit_count, tot_count),
miss_count, xpercent(miss_count, tot_count),
tot_count, xpercent(tot_count, tot_count));
storeAppendPrintf(sentry, "\tclose_hits: %d ( %d%%) /* cd said hit, doc was in the peer cache, but we got a miss */\n",
- stats->close_hits, xpercentInt(stats->close_hits, stats->false_hits));
+ stats->closeHits, xpercentInt(stats->closeHits, stats->falseHits));
}
void
#include "DiskIO/IORequestor.h"
#include "DiskIO/ReadRequest.h"
#include "DiskIO/WriteRequest.h"
+#include "StatCounters.h"
CBDATA_CLASS_INIT(DiskdFile);
void *
void
DiskdFile::openDone(diomsg *M)
{
- statCounter.syscalls.disk.opens++;
+ ++statCounter.syscalls.disk.opens;
debugs(79, 3, "storeDiskdOpenDone: status " << M->status);
if (M->status < 0) {
void
DiskdFile::createDone(diomsg *M)
{
- statCounter.syscalls.disk.opens++;
+ ++statCounter.syscalls.disk.opens;
debugs(79, 3, "storeDiskdCreateDone: status " << M->status);
if (M->status < 0) {
void
DiskdFile::closeDone(diomsg * M)
{
- statCounter.syscalls.disk.closes++;
+ ++statCounter.syscalls.disk.closes;
debugs(79, 3, "DiskdFile::closeDone: status " << M->status);
if (M->status < 0) {
void
DiskdFile::readDone(diomsg * M)
{
- statCounter.syscalls.disk.reads++;
+ ++statCounter.syscalls.disk.reads;
debugs(79, 3, "DiskdFile::readDone: status " << M->status);
assert (M->requestor);
ReadRequest::Pointer readRequest = dynamic_cast<ReadRequest *>(M->requestor);
void
DiskdFile::writeDone(diomsg *M)
{
- statCounter.syscalls.disk.writes++;
+ ++statCounter.syscalls.disk.writes;
debugs(79, 3, "storeDiskdWriteDone: status " << M->status);
assert (M->requestor);
WriteRequest::Pointer writeRequest = dynamic_cast<WriteRequest *>(M->requestor);
#include "diomsg.h"
/* for statfs */
#include "Store.h"
+#include "StatCounters.h"
#include "SquidTime.h"
diskd_stats_t diskd_stats;
DiskdIOStrategy::unlinkDone(diomsg * M)
{
debugs(79, 3, "storeDiskdUnlinkDone: file " << shm.buf + M->shm_offset << " status " << M->status);
- statCounter.syscalls.disk.unlinks++;
+ ++statCounter.syscalls.disk.unlinks;
if (M->status < 0)
diskd_stats.unlink.fail++;
#include "DiskIO/IORequestor.h"
#include "DiskIO/ReadRequest.h"
#include "DiskIO/WriteRequest.h"
+#include "StatCounters.h"
/* === PUBLIC =========================================================== */
void
DiskThreadsDiskFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
{
- statCounter.syscalls.disk.opens++;
+ ++statCounter.syscalls.disk.opens;
#if !ASYNC_OPEN
fd = file_open(path_, flags);
debugs(79, 3, "DiskThreadsDiskFile::read: " << this << ", size " << request->len);
assert (fd > -1);
assert (ioRequestor.getRaw());
- statCounter.syscalls.disk.reads++;
+ ++statCounter.syscalls.disk.reads;
++inProgressIOs;
#if ASYNC_READ
void
DiskThreadsDiskFile::create(int flags, mode_t mode, RefCount<IORequestor> callback)
{
- statCounter.syscalls.disk.opens++;
+ ++statCounter.syscalls.disk.opens;
#if !ASYNC_CREATE
int fd = file_open(path_, flags);
void DiskThreadsDiskFile::doClose()
{
if (fd > -1) {
- statCounter.syscalls.disk.closes++;
+ ++statCounter.syscalls.disk.closes;
#if ASYNC_CLOSE
aioClose(fd);
DiskThreadsDiskFile::write(WriteRequest * writeRequest)
{
debugs(79, 3, "DiskThreadsDiskFile::write: FD " << fd);
- statCounter.syscalls.disk.writes++;
+ ++statCounter.syscalls.disk.writes;
++inProgressIOs;
#if ASYNC_WRITE
#include "DiskThreadsIOStrategy.h"
#include "fde.h"
#include "mgr/Registration.h"
+#include "StatCounters.h"
/* for statfs */
#include "Store.h"
void
DiskThreadsIOStrategy::unlinkFile(char const *path)
{
- statCounter.syscalls.disk.unlinks++;
+ ++statCounter.syscalls.disk.unlinks;
aioUnlink(path, NULL, NULL);
}
#include "ipc/StrandSearch.h"
#include "ipc/UdsOp.h"
#include "ipc/mem/Pages.h"
+#include "StatCounters.h"
#include "SquidTime.h"
CBDATA_CLASS_INIT(IpcIoFile);
char *const buf = Ipc::Mem::PagePointer(ipcIo.page);
const ssize_t read = pread(TheFile, buf, min(ipcIo.len, Ipc::Mem::PageSize()), ipcIo.offset);
- statCounter.syscalls.disk.reads++;
+ ++statCounter.syscalls.disk.reads;
fd_bytes(TheFile, read, FD_READ);
if (read >= 0) {
{
const char *const buf = Ipc::Mem::PagePointer(ipcIo.page);
const ssize_t wrote = pwrite(TheFile, buf, min(ipcIo.len, Ipc::Mem::PageSize()), ipcIo.offset);
- statCounter.syscalls.disk.writes++;
+ ++statCounter.syscalls.disk.writes;
fd_bytes(TheFile, wrote, FD_WRITE);
if (wrote >= 0) {
#include "squid-old.h"
#include "base/StringArea.h"
-#include "Store.h"
#include "HttpHeader.h"
+#include "HttpHeaderStat.h"
#include "HttpHdrCc.h"
+#include "StatHist.h"
+#include "Store.h"
#if HAVE_MAP
#include <map>
for (c = CC_PUBLIC; c < CC_ENUM_END; ++c)
if (cc->isSet(c))
- statHistCount(hist, c);
+ hist->count(c);
}
void
#include "squid-old.h"
#include "Store.h"
#include "HttpHeader.h"
+#include "HttpHeaderStat.h"
#include "HttpHdrSc.h"
#if HAVE_MAP
#include "squid-old.h"
#include "HttpHdrSc.h"
+#include "StatHist.h"
extern http_hdr_sc_type &operator++ (http_hdr_sc_type &aHeader);
/* copies non-extant fields from new_sc to this sc */
for (c = SC_NO_STORE; c < SC_ENUM_END; ++c)
if (isSet(c))
- statHistCount(hist, c);
+ hist->count(c);
}
#include "HttpHdrCc.h"
#include "HttpHdrSc.h"
#include "HttpHeader.h"
+#include "HttpHeaderStat.h"
#include "MemBuf.h"
#include "mgr/Registration.h"
#include "rfc1123.h"
+#include "StatHist.h"
#include "Store.h"
#include "TimeOrTag.h"
assert(label);
memset(hs, 0, sizeof(HttpHeaderStat));
hs->label = label;
- statHistEnumInit(&hs->hdrUCountDistr, 32); /* not a real enum */
- statHistEnumInit(&hs->fieldTypeDistr, HDR_ENUM_END);
- statHistEnumInit(&hs->ccTypeDistr, CC_ENUM_END);
- statHistEnumInit(&hs->scTypeDistr, SC_ENUM_END);
+ hs->hdrUCountDistr.enumInit(32); /* not a real enum */
+ hs->fieldTypeDistr.enumInit(HDR_ENUM_END);
+ hs->ccTypeDistr.enumInit(CC_ENUM_END);
+ hs->scTypeDistr.enumInit(SC_ENUM_END);
}
/*
if (owner <= hoReply) {
if (0 != entries.count)
- statHistCount(&HttpHeaderStats[owner].hdrUCountDistr, entries.count);
+ HttpHeaderStats[owner].hdrUCountDistr.count(entries.count);
HttpHeaderStats[owner].destroyedCount++;
if (e->id < 0 || e->id >= HDR_ENUM_END) {
debugs(55, 0, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << e->id << "). Ignored.");
} else {
- statHistCount(&HttpHeaderStats[owner].fieldTypeDistr, e->id);
+ HttpHeaderStats[owner].fieldTypeDistr.count(e->id);
/* yes, this deletion leaves us in an inconsistent state */
delete e;
}
storeAppendPrintf(e, "\nField type distribution\n");
storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n",
"id", "name", "count", "#/header");
- statHistDump(&hs->fieldTypeDistr, e, httpHeaderFieldStatDumper);
+ hs->fieldTypeDistr.dump(e, httpHeaderFieldStatDumper);
storeAppendPrintf(e, "\nCache-control directives distribution\n");
storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n",
"id", "name", "count", "#/cc_field");
- statHistDump(&hs->ccTypeDistr, e, httpHdrCcStatDumper);
+ hs->ccTypeDistr.dump(e, httpHdrCcStatDumper);
storeAppendPrintf(e, "\nSurrogate-control directives distribution\n");
storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n",
"id", "name", "count", "#/sc_field");
- statHistDump(&hs->scTypeDistr, e, httpHdrScStatDumper);
+ hs->scTypeDistr.dump(e, httpHdrScStatDumper);
storeAppendPrintf(e, "\nNumber of fields per header distribution\n");
storeAppendPrintf(e, "%2s\t %-5s\t %5s\t %6s\n",
"id", "#flds", "count", "%total");
- statHistDump(&hs->hdrUCountDistr, e, httpHeaderFldsPerHdrDumper);
+ hs->hdrUCountDistr.dump(e, httpHeaderFldsPerHdrDumper);
dump_stat = NULL;
}
--- /dev/null
+/*
+ * HttpHeaderStat.h
+ *
+ * Created on: Dec 9, 2011
+ * Author: kinkie
+ */
+
+#ifndef HTTPHEADERSTAT_H_
+#define HTTPHEADERSTAT_H_
+
+/* per header statistics */
+
+#include "StatHist.h"
+class HttpHeaderStat
+{
+public:
+ const char *label;
+ HttpHeaderMask *owner_mask;
+
+ StatHist hdrUCountDistr;
+ StatHist fieldTypeDistr;
+ StatHist ccTypeDistr;
+ StatHist scTypeDistr;
+
+ int parsedCount;
+ int ccParsedCount;
+ int scParsedCount;
+ int destroyedCount;
+ int busyDestroyedCount;
+};
+
+
+#endif /* HTTPHEADERSTAT_H_ */
HttpHdrScTarget.h \
HttpHdrContRange.cc \
HttpHdrContRange.h \
+ HttpHeaderStat.h \
HttpHeader.cc \
HttpHeader.h \
HttpHeaderMask.h \
SquidMath.cc \
SquidNew.cc \
stat.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
String.cc \
stmem.cc \
tests/testString \
tests/testURL \
tests/testConfigParser \
+ tests/testStatHist \
$(STORE_TESTS)
## NP: required to run the above list. check_PROGRAMS only builds the binaries...
tests/stub_cache_manager.cc \
tests/stub_debug.cc \
tests/stub_HelperChildConfig.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
tests/stub_StatHist.cc \
tests/stub_store.cc \
tests/stub_store_stats.cc \
$(XTRA_LIBS)
tests_testHttpReply_DEPENDENCIES= $(SQUID_CPPUNIT_LA)
-## Tests for the ACLMaxUserIP class
-## acl needs wordlist. wordlist needs MemBug
-## MemBuf needs mem, MemBuf needs event,
-## event needs cbdata.
-## ACLMaxUserUP needs $(AUTH_LIBS)
-## ACLMaxUserIP needs ACLChecklist
-## AuthUser request needs HttpHeader, which brings in
-## ETag.cc \
-## HttpHeader.cc \
-## HttpHeaderTools.cc \
-## HttpHdrContRange.cc \
-## HttpHdrCc.cc \
-## HttpHdrRange.cc \
-## HttpHdrSc.cc \
-## HttpHdrScTarget.cc \
-## Packer.cc \
-## StatHist.cc \
-## String.cc \
-##
-## disk.cc \
-## fs/libfs.la \
+
tests_testACLMaxUserIP_SOURCES= \
cbdata.cc \
ClientInfo.h \
Packer.cc \
Parsing.cc \
SquidMath.cc \
- StatHist.cc \
+ StatCounters.h \
+ StatHist.h \
+ tests/stub_StatHist.cc \
stmem.cc \
String.cc \
store_dir.cc \
SquidMath.h \
SquidMath.cc \
stat.cc \
- StatHist.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
stmem.cc \
store.cc \
store_client.cc \
Parsing.cc \
refresh.cc \
RemovalPolicy.cc \
- StatHist.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
stmem.cc \
StoreFileSystem.cc \
StoreIOState.cc \
SquidMath.cc \
SquidMath.h \
stat.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
stmem.cc \
store.cc \
SquidMath.h \
SquidMath.cc \
stat.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
stmem.cc \
store.cc \
SquidMath.h \
SquidMath.cc \
stat.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
stmem.cc \
store.cc \
SquidMath.h \
SquidMath.cc \
stat.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
stmem.cc \
store.cc \
Parsing.cc \
RemovalPolicy.cc \
refresh.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
stmem.cc \
store.cc \
HttpHdrSc.cc \
HttpHdrScTarget.cc \
url.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
StatHist.cc \
HttpHdrRange.cc \
ETag.cc \
Packer.cc \
Parsing.cc \
RemovalPolicy.cc \
- StatHist.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
stmem.cc \
store.cc \
StoreFileSystem.cc \
HttpHdrSc.cc \
HttpHdrScTarget.cc \
url.cc \
- StatHist.cc \
- HttpHdrRange.cc \
- ETag.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
tests/stub_errorpage.cc \
tests/stub_HttpRequest.cc \
tests/stub_access_log.cc \
HttpHdrSc.cc \
HttpHdrScTarget.cc \
url.cc \
- StatHist.cc \
- HttpHdrRange.cc \
- ETag.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
tests/stub_errorpage.cc \
tests/stub_HttpRequest.cc \
tests/stub_access_log.cc \
SquidMath.h \
SquidMath.cc \
stat.cc \
- StatHist.cc \
+ StatCounters.h \
+ StatCounters.cc \
+ StatHist.h \
+ tests/stub_StatHist.cc \
stmem.cc \
store.cc \
store_client.cc \
tests_testConfigParser_LDFLAGS = $(LIBADD_DL)
tests_testConfigParser_DEPENDENCIES = \
$(SQUID_CPPUNIT_LA)
+
+tests_testStatHist_SOURCES = \
+ cbdata.cc \
+ MemBuf.cc \
+ StatHist.cc \
+ StatHist.h \
+ String.cc \
+ tests/stub_cache_manager.cc \
+ tests/stub_comm.cc \
+ tests/stub_debug.cc \
+ tests/stub_DelayId.cc \
+ tests/stub_HelperChildConfig.cc \
+ tests/stub_mem.cc \
+ tests/stub_MemObject.cc \
+ tests/stub_mime.cc \
+ tests/stub_pconn.cc \
+ tests/stub_stmem.cc \
+ tests/stub_store.cc \
+ tests/stub_store_stats.cc \
+ tests/stub_tools.cc \
+ tests/testMain.cc \
+ tests/testStatHist.cc \
+ tests/testStatHist.h \
+ time.cc
+nodist_tests_testStatHist_SOURCES = \
+ $(TESTSOURCES)
+tests_testStatHist_LDFLAGS = $(LIBADD_DL)
+tests_testStatHist_LDADD = \
+ base/libbase.la \
+ $(top_builddir)/lib/libmiscutil.la \
+ $(SQUID_CPPUNIT_LIBS) \
+ $(SQUID_CPPUNIT_LA) \
+ $(COMPAT_LIB)
+tests_testStatHist_DEPENDENCIES = $(SQUID_CPPUNIT_LA)
+
TESTS += testHeaders
#include "cbdata.h"
+/* for CacheDigestGuessStats */
+#include "StatCounters.h"
+
struct _Version {
short int current; /* current version */
short int required; /* minimal version that can safely handle current version */
} times;
struct {
- cd_guess_stats guess;
+ CacheDigestGuessStats guess;
int used_count;
struct {
#include "HttpReply.h"
#include "errorpage.h"
#include "err_detail_type.h"
+#include "StatCounters.h"
#include "SquidTime.h"
#if USE_ADAPTATION
if (io.size > 0) {
fd_bytes(io.fd, io.size, FD_WRITE);
- kb_incr(&statCounter.server.all.kbytes_out, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_out), io.size);
// kids should increment their counters
}
--- /dev/null
+/*
+ * 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.
+ *
+ * AUTHOR: Francesco Chemolli (Harvest-derived)
+ *
+ */
+
+#include "squid.h"
+#include "StatCounters.h"
+
+StatCounters statCounter;
--- /dev/null
+/*
+ * AUTHOR: Francesco Chemolli (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.
+ *
+ *
+ */
+#ifndef STATCOUNTERS_H_
+#define STATCOUNTERS_H_
+
+#include "StatHist.h"
+
+#if USE_CACHE_DIGESTS
+/** statistics for cache digests and other hit "predictors" */
+class CacheDigestGuessStats
+{
+public:
+ int trueHits;
+ int falseHits;
+ int trueMisses;
+ int falseMisses;
+ int closeHits; /// \todo: temporary remove it later
+};
+#endif
+
+
+/** General collection of process-wide statistics.
+ *
+ * \note if you add a field to StatCounters,
+ * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
+ */
+class StatCounters
+{
+public:
+ struct {
+ int clients;
+ int requests;
+ int hits;
+ int mem_hits;
+ int disk_hits;
+ int errors;
+ kb_t kbytes_in;
+ kb_t kbytes_out;
+ kb_t hit_kbytes_out;
+ StatHist missSvcTime;
+ StatHist nearMissSvcTime;
+ StatHist nearHitSvcTime;
+ StatHist hitSvcTime;
+ StatHist allSvcTime;
+ } client_http;
+
+ struct {
+
+ struct {
+ int requests;
+ int errors;
+ kb_t kbytes_in;
+ kb_t kbytes_out;
+ } all , http, ftp, other;
+ } server;
+
+ struct {
+ int pkts_sent;
+ int queries_sent;
+ int replies_sent;
+ int pkts_recv;
+ int queries_recv;
+ int replies_recv;
+ int hits_sent;
+ int hits_recv;
+ int replies_queued;
+ int replies_dropped;
+ kb_t kbytes_sent;
+ kb_t q_kbytes_sent;
+ kb_t r_kbytes_sent;
+ kb_t kbytes_recv;
+ kb_t q_kbytes_recv;
+ kb_t r_kbytes_recv;
+ StatHist querySvcTime;
+ StatHist replySvcTime;
+ int query_timeouts;
+ int times_used;
+ } icp;
+
+ struct {
+ int pkts_sent;
+ int pkts_recv;
+ } htcp;
+
+ struct {
+ int requests;
+ } unlink;
+
+ struct {
+ StatHist svcTime;
+ } dns;
+
+ struct {
+ int times_used;
+ kb_t kbytes_sent;
+ kb_t kbytes_recv;
+ kb_t memory;
+ int msgs_sent;
+ int msgs_recv;
+#if USE_CACHE_DIGESTS
+
+ CacheDigestGuessStats guess;
+#endif
+
+ StatHist on_xition_count;
+ } cd;
+
+ struct {
+ int times_used;
+ } netdb;
+ int page_faults;
+ unsigned long int select_loops;
+ int select_fds;
+ double select_time;
+ double cputime;
+
+ struct timeval timestamp;
+ StatHist comm_icp_incoming;
+ StatHist comm_dns_incoming;
+ StatHist comm_http_incoming;
+ StatHist select_fds_hist;
+
+ struct {
+ struct {
+ int opens;
+ int closes;
+ int reads;
+ int writes;
+ int seeks;
+ int unlinks;
+ } disk;
+
+ struct {
+ int accepts;
+ int sockets;
+ int connects;
+ int binds;
+ int closes;
+ int reads;
+ int writes;
+ int recvfroms;
+ int sendtos;
+ } sock;
+ int selects;
+ } syscalls;
+ int aborted_requests;
+
+ struct {
+ int files_cleaned;
+ int outs;
+ int ins;
+ } swap;
+
+private:
+};
+
+extern StatCounters statCounter;
+
+#endif /* STATCOUNTERS_H_ */
/*
- * $Id$
- *
* DEBUG: section 62 Generic Histogram
* AUTHOR: Duane Wessels
*
*
*/
-/*
- * Important restrictions on val_in and val_out functions:
- *
- * - val_in: ascending, defined on [0, oo), val_in(0) == 0;
- * - val_out: x == val_out(val_in(x)) where val_in(x) is defined
- *
- * In practice, the requirements are less strict,
- * but then it gets hard to define them without math notation.
- * val_in is applied after offseting the value but before scaling
- * See log and linear based histograms for examples
- */
-
#include "squid.h"
-#include "Store.h"
+#include "StatHist.h"
/* Local functions */
-static void statHistInit(StatHist * H, int capacity, hbase_f * val_in, hbase_f * val_out, double min, double max);
-static int statHistBin(const StatHist * H, double v);
-static double statHistVal(const StatHist * H, int bin);
static StatHistBinDumper statHistBinDumper;
namespace Math
};
/* low level init, higher level functions has less params */
-static void
-statHistInit(StatHist * H, int capacity, hbase_f * val_in, hbase_f * val_out, double min, double max)
-{
- assert(H);
- assert(capacity > 0);
- assert(val_in && val_out);
- /* check before we divide to get scale */
- assert(val_in(max - min) > 0);
- H->bins = (int *)xcalloc(capacity, sizeof(int));
- H->min = min;
- H->max = max;
- H->capacity = capacity;
- H->scale = capacity / val_in(max - min);
- H->val_in = val_in;
- H->val_out = val_out;
-
- /* HPUX users: If you get one of the assertions below, please send
- * [at least] the values of all variables involved in the assertions
- * when reporting a bug!
- */
-
- /* check that functions are valid */
- /* a min value should go into bin[0] */
- assert(statHistBin(H, min) == 0);
- /* a max value should go into the last bin */
- assert(statHistBin(H, max) == H->capacity - 1);
- /* it is hard to test val_out, here is a crude test */
- assert(((int) floor(0.99 + statHistVal(H, 0) - min)) == 0);
-}
-
void
-statHistClean(StatHist * H)
+StatHist::init(unsigned int newCapacity, hbase_f * val_in_, hbase_f * val_out_, double newMin, double newMax)
{
- xfree(H->bins);
- H->bins = NULL;
+ /* check before we divide to get scale_ */
+ assert(val_in_(newMax - newMin) > 0);
+ min_ = newMin;
+ max_ = newMax;
+ capacity_ = newCapacity;
+ val_in = val_in_;
+ val_out = val_out_;
+ bins = static_cast<bins_type *>(xcalloc(capacity_, sizeof(bins_type)));
+ scale_ = capacity_ / val_in(max_ - min_);
}
-/* assumes that somebody already called init for Dest */
void
-statHistCopy(StatHist * Dest, const StatHist * Orig)
+StatHist::clear()
{
- assert(Dest);
- assert(Orig);
- debugs(62, 3, "statHistCopy: Dest=" << Dest << ", Orig=" << Orig);
- assert(Dest->bins);
- /* better be safe than sorry */
- debugs(62, 3, "statHistCopy: capacity " << Dest->capacity << " " << Orig->capacity);
- assert(Dest->capacity == Orig->capacity);
- debugs(62, 3, "statHistCopy: min " << Dest->min << " " << Orig->min );
- assert(Dest->min == Orig->min);
- debugs(62, 3, "statHistCopy: max " << Dest->max << " " << Orig->max );
- assert(Dest->max == Orig->max);
- debugs(62, 3, "statHistCopy: scale " << Dest->scale << " " << Orig->scale );
- assert(fabs(Dest->scale - Orig->scale) < 0.0000001);
- assert(Dest->val_in == Orig->val_in);
- assert(Dest->val_out == Orig->val_out);
- /* actual copy */
- debugs(62, 3, "statHistCopy: copying " <<
- (long int) (Dest->capacity * sizeof(*Dest->bins)) << " bytes to " <<
- Dest->bins << " from " << Orig->bins);
-
- memcpy(Dest->bins, Orig->bins, Dest->capacity * sizeof(*Dest->bins));
+ for (unsigned int i=0; i<capacity_; ++i)
+ bins[i]=0;
}
-/*
- * same as statHistCopy but will do nothing if capacities do not match; the
- * latter happens, for example, when #peers changes during reconfiguration;
- * if it happens too often we should think about more general solution..
- */
-void
-statHistSafeCopy(StatHist * Dest, const StatHist * Orig)
+StatHist::StatHist(const StatHist &src) :
+ capacity_(src.capacity_), min_(src.min_), max_(src.max_),
+ scale_(src.scale_), val_in(src.val_in), val_out(src.val_out)
{
- assert(Dest && Orig);
- assert(Dest->bins);
-
- if (Dest->capacity == Orig->capacity)
- statHistCopy(Dest, Orig);
+ if (src.bins!=NULL) {
+ bins = static_cast<bins_type *>(xcalloc(src.capacity_, sizeof(int)));
+ memcpy(bins,src.bins,capacity_*sizeof(*bins));
+ }
}
void
-statHistCount(StatHist * H, double val)
+StatHist::count(double val)
{
- const int bin = statHistBin(H, val);
- assert(H->bins); /* make sure it got initialized */
- assert(0 <= bin && bin < H->capacity);
- H->bins[bin]++;
+ if (bins==NULL) //do not count before initialization or after destruction
+ return;
+ const unsigned int bin = findBin(val);
+ ++bins[bin];
}
-static int
-statHistBin(const StatHist * H, double v)
+unsigned int
+StatHist::findBin(double v)
{
- int bin;
-#if BROKEN_STAT_HIST_BIN
-
- return 0;
- /* NOTREACHED */
-#endif
- v -= H->min; /* offset */
+ v -= min_; /* offset */
if (v <= 0.0) /* too small */
return 0;
- bin = (int) floor(H->scale * H->val_in(v) + 0.5);
+ unsigned int bin;
+ double tmp_bin=floor(scale_ * val_in(v) + 0.5);
- if (bin < 0) /* should not happen */
- bin = 0;
+ if (tmp_bin < 0.0) // should not happen
+ return 0;
+ bin = static_cast <unsigned int>(tmp_bin);
- if (bin >= H->capacity) /* too big */
- bin = H->capacity - 1;
+ if (bin >= capacity_) /* too big */
+ bin = capacity_ - 1;
return bin;
}
-static double
-statHistVal(const StatHist * H, int bin)
+double
+StatHist::val(unsigned int bin) const
{
- return H->val_out((double) bin / H->scale) + H->min;
+ return val_out((double) bin / scale_) + min_;
}
double
-statHistDeltaMedian(const StatHist * A, const StatHist * B)
+statHistDeltaMedian(const StatHist & A, const StatHist & B)
{
return statHistDeltaPctile(A, B, 0.5);
}
double
-statHistDeltaPctile(const StatHist * A, const StatHist * B, double pctile)
+statHistDeltaPctile(const StatHist & A, const StatHist & B, double pctile)
+{
+ return A.deltaPctile(B, pctile);
+}
+
+double
+StatHist::deltaPctile(const StatHist & B, double pctile) const
{
- int i;
- int s1 = 0;
- int h = 0;
- int a = 0;
- int b = 0;
- int I = 0;
- int J = A->capacity;
- int K;
+ unsigned int i;
+ bins_type s1 = 0;
+ bins_type h = 0;
+ bins_type a = 0;
+ bins_type b = 0;
+ unsigned int I = 0;
+ unsigned int J = capacity_;
+ unsigned int K;
double f;
- int *D = (int *)xcalloc(A->capacity, sizeof(int));
- assert(A->capacity == B->capacity);
- for (i = 0; i < A->capacity; i++) {
- D[i] = B->bins[i] - A->bins[i];
+ assert(capacity_ == B.capacity_);
+
+ int *D = static_cast<int *>(xcalloc(capacity_, sizeof(int)));
+
+ for (i = 0; i < capacity_; ++i) {
+ D[i] = B.bins[i] - bins[i];
assert(D[i] >= 0);
}
- for (i = 0; i < A->capacity; i++)
+ for (i = 0; i < capacity_; ++i)
s1 += D[i];
h = int(s1 * pctile);
- for (i = 0; i < A->capacity; i++) {
+ for (i = 0; i < capacity_; ++i) {
J = i;
b += D[J];
f = (h - a) / (b - a);
- K = (int) floor(f * (double) (J - I) + I);
+ K = (unsigned int) floor(f * (double) (J - I) + I);
- return statHistVal(A, K);
+ return val(K);
}
static void
}
void
-statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd)
+StatHist::dump(StoreEntry * sentry, StatHistBinDumper * bd) const
{
- int i;
- double left_border = H->min;
+ double left_border = min_;
if (!bd)
bd = statHistBinDumper;
- for (i = 0; i < H->capacity; i++) {
- const double right_border = statHistVal(H, i + 1);
+ for (unsigned int i = 0; i < capacity_; ++i) {
+ const double right_border = val(i + 1);
assert(right_border - left_border > 0.0);
- bd(sentry, i, left_border, right_border - left_border, H->bins[i]);
+ bd(sentry, i, left_border, right_border - left_border, bins[i]);
left_border = right_border;
}
}
}
void
-statHistLogInit(StatHist * H, int capacity, double min, double max)
+StatHist::logInit(unsigned int capacity, double min, double max)
{
- statHistInit(H, capacity, Math::Log, Math::Exp, min, max);
+ init(capacity, Math::Log, Math::Exp, min, max);
}
/* linear histogram for enums */
}
void
-statHistEnumInit(StatHist * H, int last_enum)
+StatHist::enumInit(unsigned int last_enum)
{
- statHistInit(H, last_enum + 3, Math::Null, Math::Null, (double) -1, (double) (last_enum + 1 + 1));
+ init(last_enum + 3, Math::Null, Math::Null, -1.0, (2.0 + last_enum));
}
void
idx, (int) val, count);
}
-void
-statHistIntInit(StatHist * H, int n)
-{
- statHistInit(H, n, Math::Null, Math::Null, (double) 0, (double) n - 1);
-}
-
void
statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count)
{
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef STATHIST_H_
+#define STATHIST_H_
+
+/* for StoreEntry */
+#include "Store.h"
+
+
+/// function signature for in/out StatHist adaptation
+typedef double hbase_f(double);
+
+/// function signature for StatHist dumping functions
+typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count);
+
+/** Generic histogram class
+ *
+ * see important comments on hbase_f restrictions in StatHist.cc
+ */
+class StatHist
+{
+public:
+ /**
+ * \note the default constructor doesn't fully initialize.
+ * you have to call one of the *init functions to specialize the
+ * histogram
+ * \todo merge functionality from the *init functions to the constructor and
+ * drop these
+ * \todo specialize the class in a small hierarchy so that all
+ * relevant initializations are done at build-time
+ */
+ StatHist();
+ StatHist(const StatHist&); //not needed
+ ~StatHist();
+
+ typedef uint64_t bins_type;
+
+ StatHist &operator=(const StatHist &);
+
+ /** clear the contents of the histograms
+ *
+ * \todo remove: this function has been replaced in its purpose
+ * by the destructor
+ */
+ void clear();
+
+ /** Calculate the percentile for value pctile for the difference between
+ * this and the supplied histogram.
+ */
+ double deltaPctile(const StatHist &B, double pctile) const;
+ /** obtain the output-transformed value from the specified bin
+ *
+ */
+ double val(unsigned int bin) const;
+ /** increment the counter for the histogram entry
+ * associated to the supplied value
+ */
+ void count(double val);
+ /** iterate the supplied bd function over the histogram values
+ */
+ void dump(StoreEntry *sentry, StatHistBinDumper * bd) const;
+ /** Initialize the Histogram using a logarithmic values distribution
+ */
+ void logInit(unsigned int capacity, double min, double max);
+ /** initialize the histogram to count occurrences in an enum-represented set
+ */
+ void enumInit(unsigned int last_enum);
+protected:
+ /** low-level initialize function. called by *Init high-level functions
+ * \note Important restrictions on val_in and val_out functions:
+ *
+ * - val_in: ascending, defined on [0, oo), val_in(0) == 0;
+ * - val_out: x == val_out(val_in(x)) where val_in(x) is defined
+ *
+ * In practice, the requirements are less strict,
+ * but then it gets hard to define them without math notation.
+ * val_in is applied after offseting the value but before scaling
+ * See log and linear based histograms for examples
+ */
+ void init(unsigned int capacity, hbase_f * val_in, hbase_f * val_out, double min, double max);
+ /// find what entry in the histogram corresponds to v, by applying
+ /// the preset input transformation function
+ unsigned int findBin(double v);
+ /// the histogram counters
+ bins_type *bins;
+ unsigned int capacity_;
+ /// minimum value to be stored, corresponding to the first bin
+ double min_;
+ /// value of the maximum counter in the histogram
+ double max_;
+ /// scaling factor when looking for a bin
+ double scale_;
+ hbase_f *val_in; /* e.g., log() for log-based histogram */
+ hbase_f *val_out; /* e.g., exp() for log based histogram */
+};
+
+double statHistDeltaMedian(const StatHist & A, const StatHist & B);
+double statHistDeltaPctile(const StatHist & A, const StatHist & B, double pctile);
+StatHistBinDumper statHistEnumDumper;
+StatHistBinDumper statHistIntDumper;
+
+inline StatHist&
+StatHist::operator =(const StatHist & src)
+{
+ if (this==&src) //handle self-assignment
+ return *this;
+ xfree(bins); // xfree can handle NULL pointers, no need to check
+ capacity_=src.capacity_;
+ bins = static_cast<bins_type *>(xcalloc(src.capacity_, sizeof(bins_type)));
+ min_=src.min_;
+ max_=src.max_;
+ scale_=src.scale_;
+ val_in=src.val_in;
+ val_out=src.val_out;
+ memcpy(bins,src.bins,capacity_*sizeof(*bins));
+ return *this;
+}
+
+inline
+StatHist::StatHist() :
+ bins(NULL), capacity_(0), min_(0), max_(0),
+ scale_(1.0), val_in(NULL), val_out(NULL)
+{}
+
+inline
+StatHist::~StatHist()
+{
+ xfree(bins); //can handle case of bins being NULL
+ bins=NULL;
+ capacity_=0; //mark as destructed, may be needed for troubleshooting
+}
+
+#endif /* STATHIST_H_ */
#include "mgr/Registration.h"
#include "SquidMath.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
c->prevTime=current_dtime;/* put current time to have something sensible here */
#endif
hash_join(client_table, &c->hash);
- statCounter.client_http.clients++;
+ ++statCounter.client_http.clients;
if ((statCounter.client_http.clients > max_clients) && !cleanup_running && cleanup_scheduled < 2) {
cleanup_scheduled++;
clientdbFreeItem(c);
- statCounter.client_http.clients--;
+ --statCounter.client_http.clients;
cleanup_removed++;
}
#include "MemObject.h"
#include "ProtoPort.h"
#include "rfc1738.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "SquidTime.h"
#if USE_SSL
#include "ssl/context_storage.h"
void
clientUpdateStatCounters(log_type logType)
{
- statCounter.client_http.requests++;
+ ++statCounter.client_http.requests;
if (logTypeIsATcpHit(logType))
- statCounter.client_http.hits++;
+ ++statCounter.client_http.hits;
if (logType == LOG_TCP_HIT)
- statCounter.client_http.disk_hits++;
+ ++statCounter.client_http.disk_hits;
else if (logType == LOG_TCP_MEM_HIT)
- statCounter.client_http.mem_hits++;
+ ++statCounter.client_http.mem_hits;
}
void
clientUpdateStatHistCounters(log_type logType, int svc_time)
{
- statHistCount(&statCounter.client_http.all_svc_time, svc_time);
+ statCounter.client_http.allSvcTime.count(svc_time);
/**
* The idea here is not to be complete, but to get service times
* for only well-defined types. For example, we don't include
switch (logType) {
case LOG_TCP_REFRESH_UNMODIFIED:
- statHistCount(&statCounter.client_http.nh_svc_time, svc_time);
+ statCounter.client_http.nearHitSvcTime.count(svc_time);
break;
case LOG_TCP_IMS_HIT:
- statHistCount(&statCounter.client_http.nm_svc_time, svc_time);
+ statCounter.client_http.nearMissSvcTime.count(svc_time);
break;
case LOG_TCP_HIT:
case LOG_TCP_MEM_HIT:
case LOG_TCP_OFFLINE_HIT:
- statHistCount(&statCounter.client_http.hit_svc_time, svc_time);
+ statCounter.client_http.hitSvcTime.count(svc_time);
break;
case LOG_TCP_MISS:
case LOG_TCP_CLIENT_REFRESH_MISS:
- statHistCount(&statCounter.client_http.miss_svc_time, svc_time);
+ statCounter.client_http.missSvcTime.count(svc_time);
break;
default:
i = &someEntry->ping;
if (clientPingHasFinished(i))
- statHistCount(&statCounter.icp.query_svc_time,
- tvSubUsec(i->start, i->stop));
+ statCounter.icp.querySvcTime.count(tvSubUsec(i->start, i->stop));
if (i->timeout)
statCounter.icp.query_timeouts++;
if (io.flag == COMM_OK) {
if (io.size > 0) {
- kb_incr(&statCounter.client_http.kbytes_in, io.size);
+ kb_incr(&(statCounter.client_http.kbytes_in), io.size);
// may comm_close or setReplyToError
if (!handleReadData(io.buf, io.size))
#include "ip/QosConfig.h"
#include "ip/tools.h"
#include "ClientInfo.h"
+#include "StatCounters.h"
#if USE_SSL
#include "ssl/support.h"
#endif
#include "fde.h"
#include "mgr/Registration.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "Store.h"
#if HAVE_SYS_DEVPOLL_H
static void commIncomingStats(StoreEntry *sentry)
{
- StatCounters *f = &statCounter;
storeAppendPrintf(sentry, "Total number of devpoll loops: %ld\n", statCounter.select_loops);
storeAppendPrintf(sentry, "Histogram of returned filedescriptors\n");
- statHistDump(&f->select_fds_hist, sentry, statHistIntDumper);
+ statCounter.select_fds_hist.dump(sentry, statHistIntDumper);
}
PROF_stop(comm_check_incoming);
getCurrentTime();
- statHistCount(&statCounter.select_fds_hist, num);
+ statCounter.select_fds_hist.count(num);
if (num == 0)
return COMM_TIMEOUT; /* no error */
#include "fde.h"
#include "mgr/Registration.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "Store.h"
#define DEBUG_EPOLL 0
StatCounters *f = &statCounter;
storeAppendPrintf(sentry, "Total number of epoll(2) loops: %ld\n", statCounter.select_loops);
storeAppendPrintf(sentry, "Histogram of returned filedescriptors\n");
- statHistDump(&f->select_fds_hist, sentry, statHistIntDumper);
+ f->select_fds_hist.dump(sentry, statHistIntDumper);
}
/**
PROF_stop(comm_check_incoming);
getCurrentTime();
- statHistCount(&statCounter.select_fds_hist, num);
+ statCounter.select_fds_hist.count(num);
if (num == 0)
return COMM_TIMEOUT; /* No error.. */
#include "ICP.h"
#include "mgr/Registration.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
#if HAVE_POLL_H
if (nevents > INCOMING_ICP_MAX)
nevents = INCOMING_ICP_MAX;
- statHistCount(&statCounter.comm_icp_incoming, nevents);
+ statCounter.comm_icp_incoming.count(nevents);
}
static void
if (nevents > INCOMING_HTTP_MAX)
nevents = INCOMING_HTTP_MAX;
- statHistCount(&statCounter.comm_http_incoming, nevents);
+ statCounter.comm_http_incoming.count(nevents);
}
/* poll all sockets; call handlers for those that are ready. */
getCurrentTime();
debugs(5, num ? 5 : 8, "comm_poll: " << num << "+" << npending << " FDs ready");
- statHistCount(&statCounter.select_fds_hist, num);
+ statCounter.select_fds_hist.count(num);
if (num == 0 && npending == 0)
continue;
if (nevents > INCOMING_DNS_MAX)
nevents = INCOMING_DNS_MAX;
- statHistCount(&statCounter.comm_dns_incoming, nevents);
+ statCounter.comm_dns_incoming.count(nevents);
}
static void
commIncomingStats(StoreEntry * sentry)
{
- StatCounters *f = &statCounter;
storeAppendPrintf(sentry, "Current incoming_icp_interval: %d\n",
incoming_icp_interval >> INCOMING_FACTOR);
storeAppendPrintf(sentry, "Current incoming_dns_interval: %d\n",
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "Histogram of events per incoming socket type\n");
storeAppendPrintf(sentry, "ICP Messages handled per comm_poll_icp_incoming() call:\n");
- statHistDump(&f->comm_icp_incoming, sentry, statHistIntDumper);
+ statCounter.comm_icp_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "DNS Messages handled per comm_poll_dns_incoming() call:\n");
- statHistDump(&f->comm_dns_incoming, sentry, statHistIntDumper);
+ statCounter.comm_dns_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "HTTP Messages handled per comm_poll_http_incoming() call:\n");
- statHistDump(&f->comm_http_incoming, sentry, statHistIntDumper);
+ statCounter.comm_http_incoming.dump(sentry, statHistIntDumper);
}
/* Called by async-io or diskd to speed up the polling */
#include "ICP.h"
#include "mgr/Registration.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "Store.h"
#include "fde.h"
if (nevents > INCOMING_ICP_MAX)
nevents = INCOMING_ICP_MAX;
- statHistCount(&statCounter.comm_icp_incoming, nevents);
+ statCounter.comm_icp_incoming.count(nevents);
}
static void
if (nevents > INCOMING_HTTP_MAX)
nevents = INCOMING_HTTP_MAX;
- statHistCount(&statCounter.comm_http_incoming, nevents);
+ statCounter.comm_http_incoming.count(nevents);
}
#define DEBUG_FDBITS 0
debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready");
- statHistCount(&statCounter.select_fds_hist, num);
+ statCounter.select_fds_hist.count(num);
if (num == 0 && pending == 0)
continue;
if (nevents > INCOMING_DNS_MAX)
nevents = INCOMING_DNS_MAX;
- statHistCount(&statCounter.comm_dns_incoming, nevents);
+ statCounter.comm_dns_incoming.count(nevents);
}
void
static void
commIncomingStats(StoreEntry * sentry)
{
- StatCounters *f = &statCounter;
storeAppendPrintf(sentry, "Current incoming_icp_interval: %d\n",
incoming_icp_interval >> INCOMING_FACTOR);
storeAppendPrintf(sentry, "Current incoming_dns_interval: %d\n",
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "Histogram of events per incoming socket type\n");
storeAppendPrintf(sentry, "ICP Messages handled per comm_select_icp_incoming() call:\n");
- statHistDump(&f->comm_icp_incoming, sentry, statHistIntDumper);
+ statCounter.comm_icp_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "DNS Messages handled per comm_select_dns_incoming() call:\n");
- statHistDump(&f->comm_dns_incoming, sentry, statHistIntDumper);
+ statCounter.comm_dns_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "HTTP Messages handled per comm_select_http_incoming() call:\n");
- statHistDump(&f->comm_http_incoming, sentry, statHistIntDumper);
+ statCounter.comm_http_incoming.dump(sentry, statHistIntDumper);
}
void
#include "fde.h"
#include "mgr/Registration.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "Store.h"
static int MAX_POLL_TIME = 1000; /* see also Comm::QuickPollRequired() */
if (nevents > INCOMING_ICP_MAX)
nevents = INCOMING_ICP_MAX;
- statHistCount(&statCounter.comm_icp_incoming, nevents);
+ statCounter.comm_icp_incoming.count(nevents);
}
static void
if (nevents > INCOMING_HTTP_MAX)
nevents = INCOMING_HTTP_MAX;
- statHistCount(&statCounter.comm_http_incoming, nevents);
+ statCounter.comm_http_incoming.count(nevents);
}
#define DEBUG_FDBITS 0
debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready");
- statHistCount(&statCounter.select_fds_hist, num);
+ statCounter.select_fds_hist.count(num);
if (num == 0 && pending == 0)
continue;
if (nevents > INCOMING_DNS_MAX)
nevents = INCOMING_DNS_MAX;
- statHistCount(&statCounter.comm_dns_incoming, nevents);
+ statCounter.comm_dns_incoming.count(nevents);
}
void
static void
commIncomingStats(StoreEntry * sentry)
{
- StatCounters *f = &statCounter;
storeAppendPrintf(sentry, "Current incoming_icp_interval: %d\n",
incoming_icp_interval >> INCOMING_FACTOR);
storeAppendPrintf(sentry, "Current incoming_dns_interval: %d\n",
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "Histogram of events per incoming socket type\n");
storeAppendPrintf(sentry, "ICP Messages handled per comm_select_icp_incoming() call:\n");
- statHistDump(&f->comm_icp_incoming, sentry, statHistIntDumper);
+ statCounter.comm_icp_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "DNS Messages handled per comm_select_dns_incoming() call:\n");
- statHistDump(&f->comm_dns_incoming, sentry, statHistIntDumper);
+ statCounter.comm_dns_incoming.dump(sentry, statHistIntDumper);
storeAppendPrintf(sentry, "HTTP Messages handled per comm_select_http_incoming() call:\n");
- statHistDump(&f->comm_http_incoming, sentry, statHistIntDumper);
+ statCounter.comm_http_incoming.dump(sentry, statHistIntDumper);
}
void
#include "ip/Intercept.h"
#include "protos.h"
#include "SquidTime.h"
+#include "StatCounters.h"
namespace Comm
{
Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details)
{
PROF_start(comm_accept);
- statCounter.syscalls.sock.accepts++;
+ ++statCounter.syscalls.sock.accepts;
int sock;
struct addrinfo *gai = NULL;
details->local.InitAddrInfo(gai);
#include "comm/IoCallback.h"
#include "comm/Write.h"
#include "fde.h"
+#include "StatCounters.h"
#include "SquidTime.h"
#include "MemBuf.h"
#endif /* USE_DELAY_POOLS */
fd_bytes(fd, len, FD_WRITE);
- statCounter.syscalls.sock.writes++;
+ ++statCounter.syscalls.sock.writes;
// After each successful partial write,
// reset fde::writeStart to the current time.
fd_table[fd].writeStart = squid_curtime;
#include "comm/Loops.h"
#include "fde.h"
#include "MemBuf.h"
+#include "StatCounters.h"
static PF diskHandleRead;
static PF diskHandleWrite;
#endif
debugs(6, 3, "diskHandleRead: FD " << fd << " seeking to offset " << ctrl_dat->offset);
lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */
- statCounter.syscalls.disk.seeks++;
+ ++statCounter.syscalls.disk.seeks;
F->disk.offset = ctrl_dat->offset;
}
#include "mgr/Registration.h"
#include "SquidDns.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
#include "wordlist.h"
static_cast<generic_cbdata *>(data)->unwrap(&f);
++FqdncacheStats.replies;
const int age = f->age();
- statHistCount(&statCounter.dns.svc_time, age);
+ statCounter.dns.svcTime.count(age);
#if USE_DNSHELPER
fqdncacheParse(f, reply);
#include "Parsing.h"
#include "SquidMath.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "SwapDir.h"
#include "swap_log_op.h"
debugs(36, 3, "storeDirClean: Cleaning file "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << files[n]);
snprintf(p2, MAXPATHLEN + 1, "%s/%08X", p1, files[n]);
safeunlink(p2, 0);
- statCounter.swap.files_cleaned++;
+ ++statCounter.swap.files_cleaned;
}
debugs(36, 3, "Cleaned " << k << " unused files from " << p1);
#include "Server.h"
#include "SquidString.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
#include "URLScheme.h"
#include "wordlist.h"
debugs(9, 3, HERE << "ftpDataRead: FD " << io.fd << " Read " << io.size << " bytes");
if (io.size > 0) {
- kb_incr(&statCounter.server.all.kbytes_in, io.size);
- kb_incr(&statCounter.server.ftp.kbytes_in, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_in), io.size);
+ kb_incr(&(statCounter.server.ftp.kbytes_in), io.size);
}
if (io.flag == COMM_ERR_CLOSING)
if (io.size > 0) {
fd_bytes(io.fd, io.size, FD_WRITE);
- kb_incr(&statCounter.server.all.kbytes_out, io.size);
- kb_incr(&statCounter.server.ftp.kbytes_out, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_out), io.size);
+ kb_incr(&(statCounter.server.ftp.kbytes_out), io.size);
}
if (io.flag == COMM_ERR_CLOSING)
debugs(9, 3, "ftpReadControlReply: FD " << io.fd << ", Read " << io.size << " bytes");
if (io.size > 0) {
- kb_incr(&statCounter.server.all.kbytes_in, io.size);
- kb_incr(&statCounter.server.ftp.kbytes_in, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_in), io.size);
+ kb_incr(&(statCounter.server.ftp.kbytes_in), io.size);
}
if (io.flag == COMM_ERR_CLOSING)
FtpStateData::sentRequestBody(const CommIoCbParams &io)
{
if (io.size > 0)
- kb_incr(&statCounter.server.ftp.kbytes_out, io.size);
+ kb_incr(&(statCounter.server.ftp.kbytes_out), io.size);
ServerStateData::sentRequestBody(io);
}
/* for ERROR_BUF_SZ, BUFSIZ, MAXHTTPPORTS */
#include "defines.h"
-/* for iostats, StatCounters */
+/* for iostats */
#include "structs.h"
extern int shutting_down; /* 0 */
extern int reconfiguring; /* 0 */
extern time_t hit_only_mode_until; /* 0 */
- extern StatCounters statCounter;
extern double request_failure_ratio; /* 0.0 */
extern int store_hash_buckets; /* 0 */
extern hash_table *store_table; /* NULL */
#include "MemBuf.h"
#include "forward.h"
#include "rfc1738.h"
+#include "StatCounters.h"
#include "SquidTime.h"
/**
delayId.bytesIn(len);
#endif
- kb_incr(&statCounter.server.all.kbytes_in, len);
- kb_incr(&statCounter.server.other.kbytes_in, len);
+ kb_incr(&(statCounter.server.all.kbytes_in), len);
+ kb_incr(&(statCounter.server.other.kbytes_in), len);
}
debugs(10, 5, HERE << conn << " read len=" << len);
if (size > 0) {
fd_bytes(conn->fd, size, FD_WRITE);
- kb_incr(&statCounter.server.all.kbytes_out, size);
- kb_incr(&statCounter.server.other.kbytes_out, size);
+ kb_incr(&(statCounter.server.all.kbytes_out), size);
+ kb_incr(&(statCounter.server.other.kbytes_out), size);
}
if (errflag) {
#include "ip/tools.h"
#include "MemBuf.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
#include "StoreClient.h"
#include "compat/xalloc.h"
#include "protos.h"
#include "rfc1738.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
delayId.bytesIn(len);
#endif
- kb_incr(&statCounter.server.all.kbytes_in, len);
- kb_incr(&statCounter.server.http.kbytes_in, len);
+ kb_incr(&(statCounter.server.all.kbytes_in), len);
+ kb_incr(&(statCounter.server.http.kbytes_in), len);
IOStats.Http.reads++;
for (clen = len - 1, bin = 0; clen; bin++)
if (io.size > 0) {
fd_bytes(io.fd, io.size, FD_WRITE);
- kb_incr(&statCounter.server.all.kbytes_out, io.size);
- kb_incr(&statCounter.server.http.kbytes_out, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_out), io.size);
+ kb_incr(&(statCounter.server.http.kbytes_out), io.size);
}
if (io.flag == COMM_ERR_CLOSING)
#include "acl/Acl.h"
#include "AccessLogEntry.h"
#include "wordlist.h"
+#include "StatCounters.h"
#include "SquidTime.h"
#include "SwapDir.h"
#include "icmp/net_db.h"
statCounter.icp.replies_sent++;
kb_incr(&statCounter.icp.r_kbytes_sent, len);
/* this is the sent-reply service time */
- statHistCount(&statCounter.icp.reply_svc_time, delay);
+ statCounter.icp.replySvcTime.count(delay);
}
if (ICP_HIT == icp->opcode)
} else {
statCounter.icp.replies_recv++;
kb_incr(&statCounter.icp.r_kbytes_recv, len);
- /* statCounter.icp.query_svc_time set in clientUpdateCounters */
+ /* statCounter.icp.querySvcTime set in clientUpdateCounters */
}
if (ICP_HIT == icp->opcode)
#include "mgr/Registration.h"
#include "SquidDns.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "Store.h"
#include "wordlist.h"
static_cast<generic_cbdata *>(data)->unwrap(&i);
IpcacheStats.replies++;
const int age = i->age();
- statHistCount(&statCounter.dns.svc_time, age);
+ statCounter.dns.svcTime.count(age);
#if USE_DNSHELPER
ipcacheParse(i, reply);
#include "ipc/Strand.h"
#include "ip/tools.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "SwapDir.h"
#include "forward.h"
#include "MemPool.h"
#include "HttpStatusCode.h"
SQUIDCEXTERN const char *httpStatusString(http_status status);
+class StatHist;
+
/* Http Cache Control Header Field */
SQUIDCEXTERN void httpHdrCcInitModule(void);
SQUIDCEXTERN void httpHdrCcCleanModule(void);
SQUIDCEXTERN double statRequestHitDiskRatio(int minutes);
SQUIDCEXTERN double statByteHitRatio(int minutes);
-/* StatHist */
-SQUIDCEXTERN void statHistClean(StatHist * H);
-SQUIDCEXTERN void statHistCount(StatHist * H, double val);
-SQUIDCEXTERN void statHistCopy(StatHist * Dest, const StatHist * Orig);
-SQUIDCEXTERN void statHistSafeCopy(StatHist * Dest, const StatHist * Orig);
-SQUIDCEXTERN double statHistDeltaMedian(const StatHist * A, const StatHist * B);
-SQUIDCEXTERN double statHistDeltaPctile(const StatHist * A, const StatHist * B, double pctile);
-SQUIDCEXTERN void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd);
-SQUIDCEXTERN void statHistLogInit(StatHist * H, int capacity, double min, double max);
-SQUIDCEXTERN void statHistEnumInit(StatHist * H, int last_enum);
-SQUIDCEXTERN void statHistIntInit(StatHist * H, int n);
-SQUIDCEXTERN StatHistBinDumper statHistEnumDumper;
-SQUIDCEXTERN StatHistBinDumper statHistIntDumper;
-
-
/* mem */
SQUIDCEXTERN void memClean(void);
SQUIDCEXTERN void memInitModule(void);
int *wfd,
void **hIpc);
-
+class CacheDigestGuessStats;
/* CacheDigest */
SQUIDCEXTERN CacheDigest *cacheDigestCreate(int capacity, int bpe);
SQUIDCEXTERN void cacheDigestDestroy(CacheDigest * cd);
SQUIDCEXTERN void cacheDigestDel(CacheDigest * cd, const cache_key * key);
SQUIDCEXTERN size_t cacheDigestCalcMaskSize(int cap, int bpe);
SQUIDCEXTERN int cacheDigestBitUtil(const CacheDigest * cd);
-SQUIDCEXTERN void cacheDigestGuessStatsUpdate(cd_guess_stats * stats, int real_hit, int guess_hit);
-SQUIDCEXTERN void cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, const char *label);
+SQUIDCEXTERN void cacheDigestGuessStatsUpdate(CacheDigestGuessStats * stats, int real_hit, int guess_hit);
+SQUIDCEXTERN void cacheDigestGuessStatsReport(const CacheDigestGuessStats * stats, StoreEntry * sentry, const char *label);
SQUIDCEXTERN void cacheDigestReport(CacheDigest * cd, const char *label, StoreEntry * e);
SQUIDCEXTERN void internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest *, StoreEntry *);
/*
* hack to allow snmp access to the statistics counters
*/
-SQUIDCEXTERN StatCounters *snmpStatGet(int);
+class StatCounters;
+ SQUIDCEXTERN StatCounters *snmpStatGet(int);
-/* Vary support functions */
-SQUIDCEXTERN int varyEvaluateMatch(StoreEntry * entry, HttpRequest * req);
+ /* Vary support functions */
+ SQUIDCEXTERN int varyEvaluateMatch(StoreEntry * entry, HttpRequest * req);
-/* CygWin & Windows NT Port */
-/* win32.c */
+ /* CygWin & Windows NT Port */
+ /* win32.c */
#if _SQUID_WINDOWS_
-SQUIDCEXTERN int WIN32_Subsystem_Init(int *, char ***);
-SQUIDCEXTERN void WIN32_sendSignal(int);
-SQUIDCEXTERN void WIN32_Abort(int);
-SQUIDCEXTERN void WIN32_Exit(void);
-SQUIDCEXTERN void WIN32_SetServiceCommandLine(void);
-SQUIDCEXTERN void WIN32_InstallService(void);
-SQUIDCEXTERN void WIN32_RemoveService(void);
-SQUIDCEXTERN int SquidMain(int, char **);
+ SQUIDCEXTERN int WIN32_Subsystem_Init(int *, char ***);
+ SQUIDCEXTERN void WIN32_sendSignal(int);
+ SQUIDCEXTERN void WIN32_Abort(int);
+ SQUIDCEXTERN void WIN32_Exit(void);
+ SQUIDCEXTERN void WIN32_SetServiceCommandLine(void);
+ SQUIDCEXTERN void WIN32_InstallService(void);
+ SQUIDCEXTERN void WIN32_RemoveService(void);
+ SQUIDCEXTERN int SquidMain(int, char **);
#endif /* _SQUID_WINDOWS_ */
#if _SQUID_MSWIN_
-SQUIDCEXTERN int WIN32_pipe(int[2]);
+ SQUIDCEXTERN int WIN32_pipe(int[2]);
-SQUIDCEXTERN int WIN32_getrusage(int, struct rusage *);
-SQUIDCEXTERN void WIN32_ExceptionHandlerInit(void);
+ SQUIDCEXTERN int WIN32_getrusage(int, struct rusage *);
+ SQUIDCEXTERN void WIN32_ExceptionHandlerInit(void);
-SQUIDCEXTERN int Win32__WSAFDIsSet(int fd, fd_set* set);
-SQUIDCEXTERN DWORD WIN32_IpAddrChangeMonitorInit();
+ SQUIDCEXTERN int Win32__WSAFDIsSet(int fd, fd_set* set);
+ SQUIDCEXTERN DWORD WIN32_IpAddrChangeMonitorInit();
#endif
-/* external_acl.c */
-class external_acl;
- SQUIDCEXTERN void parse_externalAclHelper(external_acl **);
+ /* external_acl.c */
+ class external_acl;
+ SQUIDCEXTERN void parse_externalAclHelper(external_acl **);
- SQUIDCEXTERN void dump_externalAclHelper(StoreEntry * sentry, const char *name, const external_acl *);
+ SQUIDCEXTERN void dump_externalAclHelper(StoreEntry * sentry, const char *name, const external_acl *);
- SQUIDCEXTERN void free_externalAclHelper(external_acl **);
+ SQUIDCEXTERN void free_externalAclHelper(external_acl **);
- typedef void EAH(void *data, void *result);
- class ACLChecklist;
- SQUIDCEXTERN void externalAclLookup(ACLChecklist * ch, void *acl_data, EAH * handler, void *data);
+ typedef void EAH(void *data, void *result);
+ class ACLChecklist;
+ SQUIDCEXTERN void externalAclLookup(ACLChecklist * ch, void *acl_data, EAH * handler, void *data);
- SQUIDCEXTERN void externalAclInit(void);
+ SQUIDCEXTERN void externalAclInit(void);
- SQUIDCEXTERN void externalAclShutdown(void);
+ SQUIDCEXTERN void externalAclShutdown(void);
- SQUIDCEXTERN char *strtokFile(void);
+ SQUIDCEXTERN char *strtokFile(void);
#if USE_WCCPv2
- SQUIDCEXTERN void parse_wccp2_method(int *v);
- SQUIDCEXTERN void free_wccp2_method(int *v);
- SQUIDCEXTERN void dump_wccp2_method(StoreEntry * e, const char *label, int v);
- SQUIDCEXTERN void parse_wccp2_amethod(int *v);
- SQUIDCEXTERN void free_wccp2_amethod(int *v);
- SQUIDCEXTERN void dump_wccp2_amethod(StoreEntry * e, const char *label, int v);
+ SQUIDCEXTERN void parse_wccp2_method(int *v);
+ SQUIDCEXTERN void free_wccp2_method(int *v);
+ SQUIDCEXTERN void dump_wccp2_method(StoreEntry * e, const char *label, int v);
+ SQUIDCEXTERN void parse_wccp2_amethod(int *v);
+ SQUIDCEXTERN void free_wccp2_amethod(int *v);
+ SQUIDCEXTERN void dump_wccp2_amethod(StoreEntry * e, const char *label, int v);
- SQUIDCEXTERN void parse_wccp2_service(void *v);
- SQUIDCEXTERN void free_wccp2_service(void *v);
- SQUIDCEXTERN void dump_wccp2_service(StoreEntry * e, const char *label, void *v);
+ SQUIDCEXTERN void parse_wccp2_service(void *v);
+ SQUIDCEXTERN void free_wccp2_service(void *v);
+ SQUIDCEXTERN void dump_wccp2_service(StoreEntry * e, const char *label, void *v);
- SQUIDCEXTERN int check_null_wccp2_service(void *v);
+ SQUIDCEXTERN int check_null_wccp2_service(void *v);
- SQUIDCEXTERN void parse_wccp2_service_info(void *v);
+ SQUIDCEXTERN void parse_wccp2_service_info(void *v);
- SQUIDCEXTERN void free_wccp2_service_info(void *v);
+ SQUIDCEXTERN void free_wccp2_service_info(void *v);
- SQUIDCEXTERN void dump_wccp2_service_info(StoreEntry * e, const char *label, void *v);
+ SQUIDCEXTERN void dump_wccp2_service_info(StoreEntry * e, const char *label, void *v);
#endif
#if USE_AUTH
#if HAVE_AUTH_MODULE_NEGOTIATE && HAVE_KRB5 && HAVE_GSSAPI
- /* upstream proxy authentication */
- SQUIDCEXTERN char *peer_proxy_negotiate_auth(char *principal_name, char *proxy);
+ /* upstream proxy authentication */
+ SQUIDCEXTERN char *peer_proxy_negotiate_auth(char *principal_name, char *proxy);
#endif
- namespace Auth {
- /* call to ensure the auth component schemes exist. */
- extern void Init(void);
- } // namespace Auth
+ namespace Auth {
+ /* call to ensure the auth component schemes exist. */
+ extern void Init(void);
+ } // namespace Auth
#endif /* USE_AUTH */
#include "cache_snmp.h"
#include "Store.h"
#include "mem_node.h"
+#include "StatCounters.h"
+#include "StatHist.h"
#include "SquidMath.h"
#include "SquidTime.h"
break;
case PERF_MEDIAN_HTTP_ALL:
- x = statHistDeltaMedian(&l->client_http.all_svc_time,
- &f->client_http.all_svc_time);
+ x = statHistDeltaMedian(l->client_http.allSvcTime,
+ f->client_http.allSvcTime);
break;
case PERF_MEDIAN_HTTP_MISS:
- x = statHistDeltaMedian(&l->client_http.miss_svc_time,
- &f->client_http.miss_svc_time);
+ x = statHistDeltaMedian(l->client_http.missSvcTime,
+ f->client_http.missSvcTime);
break;
case PERF_MEDIAN_HTTP_NM:
- x = statHistDeltaMedian(&l->client_http.nm_svc_time,
- &f->client_http.nm_svc_time);
+ x = statHistDeltaMedian(l->client_http.nearMissSvcTime,
+ f->client_http.nearMissSvcTime);
break;
case PERF_MEDIAN_HTTP_HIT:
- x = statHistDeltaMedian(&l->client_http.hit_svc_time,
- &f->client_http.hit_svc_time);
+ x = statHistDeltaMedian(l->client_http.hitSvcTime,
+ f->client_http.hitSvcTime);
break;
case PERF_MEDIAN_ICP_QUERY:
- x = statHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time);
+ x = statHistDeltaMedian(l->icp.querySvcTime, f->icp.querySvcTime);
break;
case PERF_MEDIAN_ICP_REPLY:
- x = statHistDeltaMedian(&l->icp.reply_svc_time, &f->icp.reply_svc_time);
+ x = statHistDeltaMedian(l->icp.replySvcTime, f->icp.replySvcTime);
break;
case PERF_MEDIAN_DNS:
- x = statHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);
+ x = statHistDeltaMedian(l->dns.svcTime, f->dns.svcTime);
break;
case PERF_MEDIAN_RHR:
break;
case PERF_MEDIAN_HTTP_NH:
- x = statHistDeltaMedian(&l->client_http.nh_svc_time,
- &f->client_http.nh_svc_time);
+ x = statHistDeltaMedian(l->client_http.nearHitSvcTime,
+ f->client_http.nearHitSvcTime);
break;
default:
#include "MemBuf.h"
#include "SquidMath.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "mgr/CountersAction.h"
#include "mgr/FunAction.h"
#include "mgr/InfoAction.h"
stats.client_http_kbytes_in = XAVG(client_http.kbytes_in.kb);
stats.client_http_kbytes_out = XAVG(client_http.kbytes_out.kb);
- stats.client_http_all_median_svc_time = statHistDeltaMedian(&l->client_http.all_svc_time,
- &f->client_http.all_svc_time) / 1000.0;
- stats.client_http_miss_median_svc_time = statHistDeltaMedian(&l->client_http.miss_svc_time,
- &f->client_http.miss_svc_time) / 1000.0;
- stats.client_http_nm_median_svc_time = statHistDeltaMedian(&l->client_http.nm_svc_time,
- &f->client_http.nm_svc_time) / 1000.0;
- stats.client_http_nh_median_svc_time = statHistDeltaMedian(&l->client_http.nh_svc_time,
- &f->client_http.nh_svc_time) / 1000.0;
- stats.client_http_hit_median_svc_time = statHistDeltaMedian(&l->client_http.hit_svc_time,
- &f->client_http.hit_svc_time) / 1000.0;
+ stats.client_http_all_median_svc_time = statHistDeltaMedian(l->client_http.allSvcTime,
+ f->client_http.allSvcTime) / 1000.0;
+ stats.client_http_miss_median_svc_time = statHistDeltaMedian(l->client_http.missSvcTime,
+ f->client_http.missSvcTime) / 1000.0;
+ stats.client_http_nm_median_svc_time = statHistDeltaMedian(l->client_http.nearMissSvcTime,
+ f->client_http.nearMissSvcTime) / 1000.0;
+ stats.client_http_nh_median_svc_time = statHistDeltaMedian(l->client_http.nearHitSvcTime,
+ f->client_http.nearHitSvcTime) / 1000.0;
+ stats.client_http_hit_median_svc_time = statHistDeltaMedian(l->client_http.hitSvcTime,
+ f->client_http.hitSvcTime) / 1000.0;
stats.server_all_requests = XAVG(server.all.requests);
stats.server_all_errors = XAVG(server.all.errors);
stats.icp_q_kbytes_recv = XAVG(icp.q_kbytes_recv.kb);
stats.icp_r_kbytes_recv = XAVG(icp.r_kbytes_recv.kb);
- stats.icp_query_median_svc_time = statHistDeltaMedian(&l->icp.query_svc_time,
- &f->icp.query_svc_time) / 1000000.0;
- stats.icp_reply_median_svc_time = statHistDeltaMedian(&l->icp.reply_svc_time,
- &f->icp.reply_svc_time) / 1000000.0;
- stats.dns_median_svc_time = statHistDeltaMedian(&l->dns.svc_time,
- &f->dns.svc_time) / 1000.0;
+ stats.icp_query_median_svc_time = statHistDeltaMedian(l->icp.querySvcTime,
+ f->icp.querySvcTime) / 1000000.0;
+ stats.icp_reply_median_svc_time = statHistDeltaMedian(l->icp.replySvcTime,
+ f->icp.replySvcTime) / 1000000.0;
+ stats.dns_median_svc_time = statHistDeltaMedian(l->dns.svcTime,
+ f->dns.svcTime) / 1000.0;
stats.unlink_requests = XAVG(unlink.requests);
stats.page_faults = XAVG(page_faults);
stats.average_select_fd_period = f->select_fds > l->select_fds ?
(f->select_time - l->select_time) / (f->select_fds - l->select_fds) : 0.0;
- stats.median_select_fds = statHistDeltaMedian(&l->select_fds_hist, &f->select_fds_hist);
+ stats.median_select_fds = statHistDeltaMedian(l->select_fds_hist, f->select_fds_hist);
stats.swap_outs = XAVG(swap.outs);
stats.swap_ins = XAVG(swap.ins);
stats.swap_files_cleaned = XAVG(swap.files_cleaned);
/*
* HTTP svc_time hist is kept in milli-seconds; max of 3 hours.
*/
- statHistLogInit(&C->client_http.all_svc_time, 300, 0.0, 3600000.0 * 3.0);
- statHistLogInit(&C->client_http.miss_svc_time, 300, 0.0, 3600000.0 * 3.0);
- statHistLogInit(&C->client_http.nm_svc_time, 300, 0.0, 3600000.0 * 3.0);
- statHistLogInit(&C->client_http.nh_svc_time, 300, 0.0, 3600000.0 * 3.0);
- statHistLogInit(&C->client_http.hit_svc_time, 300, 0.0, 3600000.0 * 3.0);
+ C->client_http.allSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
+ C->client_http.missSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
+ C->client_http.nearMissSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
+ C->client_http.nearHitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
+ C->client_http.hitSvcTime.logInit(300, 0.0, 3600000.0 * 3.0);
/*
* ICP svc_time hist is kept in micro-seconds; max of 1 minute.
*/
- statHistLogInit(&C->icp.query_svc_time, 300, 0.0, 1000000.0 * 60.0);
- statHistLogInit(&C->icp.reply_svc_time, 300, 0.0, 1000000.0 * 60.0);
+ C->icp.querySvcTime.logInit(300, 0.0, 1000000.0 * 60.0);
+ C->icp.replySvcTime.logInit(300, 0.0, 1000000.0 * 60.0);
/*
* DNS svc_time hist is kept in milli-seconds; max of 10 minutes.
*/
- statHistLogInit(&C->dns.svc_time, 300, 0.0, 60000.0 * 10.0);
+ C->dns.svcTime.logInit(300, 0.0, 60000.0 * 10.0);
/*
* Cache Digest Stuff
*/
- statHistEnumInit(&C->cd.on_xition_count, CacheDigestHashFuncCount);
- statHistEnumInit(&C->comm_icp_incoming, INCOMING_ICP_MAX);
- statHistEnumInit(&C->comm_dns_incoming, INCOMING_DNS_MAX);
- statHistEnumInit(&C->comm_http_incoming, INCOMING_HTTP_MAX);
- statHistIntInit(&C->select_fds_hist, 256); /* was SQUID_MAXFD, but it is way too much. It is OK to crop this statistics */
+ C->cd.on_xition_count.enumInit(CacheDigestHashFuncCount);
+ C->comm_icp_incoming.enumInit(INCOMING_ICP_MAX);
+ C->comm_dns_incoming.enumInit(INCOMING_DNS_MAX);
+ C->comm_http_incoming.enumInit(INCOMING_HTTP_MAX);
+ 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 */
statCountersClean(StatCounters * C)
{
assert(C);
- statHistClean(&C->client_http.all_svc_time);
- statHistClean(&C->client_http.miss_svc_time);
- statHistClean(&C->client_http.nm_svc_time);
- statHistClean(&C->client_http.nh_svc_time);
- statHistClean(&C->client_http.hit_svc_time);
- statHistClean(&C->icp.query_svc_time);
- statHistClean(&C->icp.reply_svc_time);
- statHistClean(&C->dns.svc_time);
- statHistClean(&C->cd.on_xition_count);
- statHistClean(&C->comm_icp_incoming);
- statHistClean(&C->comm_dns_incoming);
- statHistClean(&C->comm_http_incoming);
- statHistClean(&C->select_fds_hist);
+ C->client_http.allSvcTime.clear();
+ C->client_http.missSvcTime.clear();
+ C->client_http.nearMissSvcTime.clear();
+ C->client_http.nearHitSvcTime.clear();
+ C->client_http.hitSvcTime.clear();
+ C->icp.querySvcTime.clear();
+ C->icp.replySvcTime.clear();
+ C->dns.svcTime.clear();
+ C->cd.on_xition_count.clear();
+ C->comm_icp_incoming.clear();
+ C->comm_dns_incoming.clear();
+ C->comm_http_incoming.clear();
+ C->select_fds_hist.clear();
}
/* add special cases here as they arrive */
statCountersInitSpecial(dest);
/* now handle special cases */
/* note: we assert that histogram capacities do not change */
- statHistCopy(&dest->client_http.all_svc_time, &orig->client_http.all_svc_time);
- statHistCopy(&dest->client_http.miss_svc_time, &orig->client_http.miss_svc_time);
- statHistCopy(&dest->client_http.nm_svc_time, &orig->client_http.nm_svc_time);
- statHistCopy(&dest->client_http.nh_svc_time, &orig->client_http.nh_svc_time);
- statHistCopy(&dest->client_http.hit_svc_time, &orig->client_http.hit_svc_time);
- statHistCopy(&dest->icp.query_svc_time, &orig->icp.query_svc_time);
- statHistCopy(&dest->icp.reply_svc_time, &orig->icp.reply_svc_time);
- statHistCopy(&dest->dns.svc_time, &orig->dns.svc_time);
- statHistCopy(&dest->cd.on_xition_count, &orig->cd.on_xition_count);
- statHistCopy(&dest->comm_icp_incoming, &orig->comm_icp_incoming);
- statHistCopy(&dest->comm_http_incoming, &orig->comm_http_incoming);
- statHistCopy(&dest->select_fds_hist, &orig->select_fds_hist);
+ dest->client_http.allSvcTime=orig->client_http.allSvcTime;
+ dest->client_http.missSvcTime=orig->client_http.missSvcTime;
+ dest->client_http.nearMissSvcTime=orig->client_http.nearMissSvcTime;
+ dest->client_http.nearHitSvcTime=orig->client_http.nearHitSvcTime;
+
+ dest->client_http.hitSvcTime=orig->client_http.hitSvcTime;
+ dest->icp.querySvcTime=orig->icp.querySvcTime;
+ dest->icp.replySvcTime=orig->icp.replySvcTime;
+ dest->dns.svcTime=orig->dns.svcTime;
+ dest->cd.on_xition_count=orig->cd.on_xition_count;
+ dest->comm_icp_incoming=orig->comm_icp_incoming;
+ dest->comm_http_incoming=orig->comm_http_incoming;
+ dest->select_fds_hist=orig->select_fds_hist;
}
static void
statCountersHistograms(StoreEntry * sentry)
{
- StatCounters *f = &statCounter;
- storeAppendPrintf(sentry, "client_http.all_svc_time histogram:\n");
- statHistDump(&f->client_http.all_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "client_http.miss_svc_time histogram:\n");
- statHistDump(&f->client_http.miss_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "client_http.nm_svc_time histogram:\n");
- statHistDump(&f->client_http.nm_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "client_http.nh_svc_time histogram:\n");
- statHistDump(&f->client_http.nh_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "client_http.hit_svc_time histogram:\n");
- statHistDump(&f->client_http.hit_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "icp.query_svc_time histogram:\n");
- statHistDump(&f->icp.query_svc_time, sentry, NULL);
- storeAppendPrintf(sentry, "icp.reply_svc_time histogram:\n");
- statHistDump(&f->icp.reply_svc_time, sentry, NULL);
+ storeAppendPrintf(sentry, "client_http.allSvcTime histogram:\n");
+ statCounter.client_http.allSvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "client_http.missSvcTime histogram:\n");
+ statCounter.client_http.missSvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "client_http.nearMissSvcTime histogram:\n");
+ statCounter.client_http.nearMissSvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "client_http.nearHitSvcTime histogram:\n");
+ statCounter.client_http.nearHitSvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "client_http.hitSvcTime histogram:\n");
+ statCounter.client_http.hitSvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "icp.querySvcTime histogram:\n");
+ statCounter.icp.querySvcTime.dump(sentry, NULL);
+ storeAppendPrintf(sentry, "icp.replySvcTime histogram:\n");
+ statCounter.icp.replySvcTime.dump(sentry, NULL);
storeAppendPrintf(sentry, "dns.svc_time histogram:\n");
- statHistDump(&f->dns.svc_time, sentry, NULL);
+ statCounter.dns.svcTime.dump(sentry, NULL);
storeAppendPrintf(sentry, "select_fds_hist histogram:\n");
- statHistDump(&f->select_fds_hist, sentry, NULL);
+ statCounter.select_fds_hist.dump(sentry, NULL);
}
static void
switch (which) {
case PCTILE_HTTP:
- x = statHistDeltaPctile(&l->client_http.all_svc_time, &f->client_http.all_svc_time, pctile);
+ x = statHistDeltaPctile(l->client_http.allSvcTime,f->client_http.allSvcTime, pctile);
break;
case PCTILE_HIT:
- x = statHistDeltaPctile(&l->client_http.hit_svc_time, &f->client_http.hit_svc_time, pctile);
+ x = statHistDeltaPctile(l->client_http.hitSvcTime,f->client_http.hitSvcTime, pctile);
break;
case PCTILE_MISS:
- x = statHistDeltaPctile(&l->client_http.miss_svc_time, &f->client_http.miss_svc_time, pctile);
+ x = statHistDeltaPctile(l->client_http.missSvcTime,f->client_http.missSvcTime, pctile);
break;
case PCTILE_NM:
- x = statHistDeltaPctile(&l->client_http.nm_svc_time, &f->client_http.nm_svc_time, pctile);
+ x = statHistDeltaPctile(l->client_http.nearMissSvcTime,f->client_http.nearMissSvcTime, pctile);
break;
case PCTILE_NH:
- x = statHistDeltaPctile(&l->client_http.nh_svc_time, &f->client_http.nh_svc_time, pctile);
+ x = statHistDeltaPctile(l->client_http.nearHitSvcTime,f->client_http.nearHitSvcTime, pctile);
break;
case PCTILE_ICP_QUERY:
- x = statHistDeltaPctile(&l->icp.query_svc_time, &f->icp.query_svc_time, pctile);
+ x = statHistDeltaPctile(l->icp.querySvcTime,f->icp.querySvcTime, pctile);
break;
case PCTILE_DNS:
- x = statHistDeltaPctile(&l->dns.svc_time, &f->dns.svc_time, pctile);
+ x = statHistDeltaPctile(l->dns.svcTime,f->dns.svcTime, pctile);
break;
default:
#include "HttpRequest.h"
#include "MemObject.h"
#include "mem_node.h"
+#include "StatCounters.h"
#include "StoreMeta.h"
#include "SwapDir.h"
#include "StoreIOState.h"
#include "Store.h"
#include "HttpReply.h"
#include "MemObject.h"
+#include "StatCounters.h"
#include "StoreMeta.h"
#include "StoreMetaUnpacker.h"
#if USE_DELAY_POOLS
#include "squid-old.h"
#include "event.h"
+#include "StatCounters.h"
#include "Store.h"
#include "SwapDir.h"
#include "StoreSearch.h"
*/
#include "squid-old.h"
+#include "StatCounters.h"
#include "StoreClient.h"
#include "Store.h"
sc->callback(0, errflag ? true : false);
}
- statCounter.swap.ins++;
+ ++statCounter.swap.ins;
}
static void
#include "mem_node.h"
#include "MemObject.h"
#include "SwapDir.h"
+#include "StatCounters.h"
#include "swap_log_op.h"
static void storeSwapOutStart(StoreEntry * e);
storeDirSwapLog(e, SWAP_LOG_ADD);
}
- statCounter.swap.outs++;
+ ++statCounter.swap.outs;
}
debugs(20, 3, "storeSwapOutFileClosed: " << __FILE__ << ":" << __LINE__);
domain_type *next;
};
-#if USE_CACHE_DIGESTS
-
-/* statistics for cache digests and other hit "predictors" */
-
-struct _cd_guess_stats {
- /* public, read-only */
- int true_hits;
- int false_hits;
- int true_misses;
- int false_misses;
- int close_hits; /* tmp, remove it later */
-};
-
-#endif
-
class PeerDigest;
struct peer {
int max_stale;
};
-/*
- * "very generic" histogram;
- * see important comments on hbase_f restrictions in StatHist.c
- */
-
-struct _StatHist {
- int *bins;
- int capacity;
- double min;
- double max;
- double scale;
- hbase_f *val_in; /* e.g., log() for log-based histogram */
- hbase_f *val_out; /* e.g., exp() for log based histogram */
-};
-
-/*
- * if you add a field to StatCounters,
- * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy
- */
-
-struct _StatCounters {
-
- struct {
- int clients;
- int requests;
- int hits;
- int mem_hits;
- int disk_hits;
- int errors;
- kb_t kbytes_in;
- kb_t kbytes_out;
- kb_t hit_kbytes_out;
- StatHist miss_svc_time;
- StatHist nm_svc_time;
- StatHist nh_svc_time;
- StatHist hit_svc_time;
- StatHist all_svc_time;
- } client_http;
-
- struct {
-
- struct {
- int requests;
- int errors;
- kb_t kbytes_in;
- kb_t kbytes_out;
- } all , http, ftp, other;
- } server;
-
- struct {
- int pkts_sent;
- int queries_sent;
- int replies_sent;
- int pkts_recv;
- int queries_recv;
- int replies_recv;
- int hits_sent;
- int hits_recv;
- int replies_queued;
- int replies_dropped;
- kb_t kbytes_sent;
- kb_t q_kbytes_sent;
- kb_t r_kbytes_sent;
- kb_t kbytes_recv;
- kb_t q_kbytes_recv;
- kb_t r_kbytes_recv;
- StatHist query_svc_time;
- StatHist reply_svc_time;
- int query_timeouts;
- int times_used;
- } icp;
-
- struct {
- int pkts_sent;
- int pkts_recv;
- } htcp;
-
- struct {
- int requests;
- } unlink;
-
- struct {
- StatHist svc_time;
- } dns;
-
- struct {
- int times_used;
- kb_t kbytes_sent;
- kb_t kbytes_recv;
- kb_t memory;
- int msgs_sent;
- int msgs_recv;
-#if USE_CACHE_DIGESTS
-
- cd_guess_stats guess;
-#endif
-
- StatHist on_xition_count;
- } cd;
-
- struct {
- int times_used;
- } netdb;
- int page_faults;
- unsigned long int select_loops;
- int select_fds;
- double select_time;
- double cputime;
-
- struct timeval timestamp;
- StatHist comm_icp_incoming;
- StatHist comm_dns_incoming;
- StatHist comm_http_incoming;
- StatHist select_fds_hist;
-
- struct {
- struct {
- int opens;
- int closes;
- int reads;
- int writes;
- int seeks;
- int unlinks;
- } disk;
-
- struct {
- int accepts;
- int sockets;
- int connects;
- int binds;
- int closes;
- int reads;
- int writes;
- int recvfroms;
- int sendtos;
- } sock;
- int selects;
- } syscalls;
- int aborted_requests;
-
- struct {
- int files_cleaned;
- int outs;
- int ins;
- } swap;
-};
-
-/* per header statistics */
-
-struct _HttpHeaderStat {
- const char *label;
- HttpHeaderMask *owner_mask;
-
- StatHist hdrUCountDistr;
- StatHist fieldTypeDistr;
- StatHist ccTypeDistr;
- StatHist scTypeDistr;
-
- int parsedCount;
- int ccParsedCount;
- int scParsedCount;
- int destroyedCount;
- int busyDestroyedCount;
-};
-
struct _CacheDigest {
/* public, read-only */
#include "squid.h"
+#define STUB_API "StatHist.cc"
+#include "STUB.h"
+#include "StatHist.h"
-// for StatHist definitions
-#include "protos.h"
void
-statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd)
-{
- fatal("statHistDump: Not implemented");
-}
+StatHist::dump(StoreEntry * sentry, StatHistBinDumper * bd) const
+{}
void
-statHistCount(StatHist * H, double val)
-{
- fatal("statHistCount: Not implemented");
-}
+StatHist::enumInit(unsigned int i)
+{}
void
-statHistEnumInit(StatHist * H, int last_enum)
-{
-//NO-OP fatal("statHistEnumInit: Not implemented");
-}
+StatHist::count(double d)
+{}
+
+double
+statHistDeltaMedian(const StatHist & A, const StatHist & B)
+STUB_RETVAL(0.0)
+
+double
+statHistDeltaPctile(const StatHist & A, const StatHist & B, double pctile)
+STUB_RETVAL(0.0)
+
+void
+StatHist::clear()
+STUB
+
+void
+StatHist::logInit(unsigned int i, double d1, double d2)
+STUB
+
+class StoreEntry;
+void
+statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count)
+STUB
+
--- /dev/null
+/*
+ * stub file for mem.cc
+ */
+
+#include "squid.h"
+
+#define STUB_API "stub_mem.cc"
+#include "STUB.h"
+/* mem* definitions are still in protos.h */
+#include "protos.h"
+
+extern "C" void
+memFreeString(size_t size, void *buf)
+{
+ xfree(buf);
+}
+
+extern "C" void *
+memAllocString(size_t net_size, size_t * gross_size)
+{
+ *gross_size=net_size;
+ return xmalloc(net_size);
+}
+
+extern "C" void
+memFreeBuf(size_t size, void *buf)
+{
+ xfree(buf);
+}
+
+extern "C" void *
+memAllocBuf(size_t net_size, size_t * gross_size)
+{
+ *gross_size=net_size;
+ return xcalloc(1, net_size);
+}
+
+/* net_size is the new size, *gross size is the old gross size, to be changed to
+ * the new gross size as a side-effect.
+ */
+extern "C" void *
+memReallocBuf(void *oldbuf, size_t net_size, size_t * gross_size)
+{
+ void *rv=xrealloc(oldbuf,net_size);
+// if (net_size > *gross_size)
+// memset(rv+net_size,0,net_size-*gross_size);
+ *gross_size=net_size;
+ return rv;
+}
+
+static void
+cxx_xfree(void * ptr)
+{
+ xfree(ptr);
+}
+
+FREE *
+memFreeBufFunc(size_t size)
+{
+ return cxx_xfree;
+}
+
+void *
+memAllocate(mem_type type)
+STUB_RETVAL(NULL)
+
+void
+memFree(void *p, int type)
+STUB
-/*
- * $Id$
- *
- * DEBUG: section 84 Helper process maintenance
- * AUTHOR: Robert Collins
- *
- * 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.
- *
- */
-
#include "squid.h"
#include "stmem.h"
-mem_hdr::mem_hdr()
-{}
+#define STUB_API "stmem.cc"
+#include "tests/STUB.h"
-mem_hdr::~mem_hdr()
-{}
+mem_hdr::mem_hdr() STUB
+mem_hdr::~mem_hdr() STUB
+size_t mem_hdr::size() const STUB_RETVAL(0)
+int64_t mem_hdr::endOffset () const STUB_RETVAL(0)
+bool mem_hdr::write (StoreIOBuffer const &writeBuffer) STUB_RETVAL(false)
-size_t
-mem_hdr::size() const
-{
- fatal ("Not implemented");
- return 0;
-}
--- /dev/null
+#define SQUID_UNIT_TEST 1
+#include "squid.h"
+#include "testStatHist.h"
+#include "StatHist.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION(testStatHist);
+
+typedef enum {
+ ZERO, ONE, TWO, THREE, FOUR, FIVE
+} number ;
+
+class InspectingStatHist : public StatHist
+{
+public:
+ bool operator==(const InspectingStatHist &);
+ bins_type counter(double val) {
+ return bins[findBin(val)];
+ }
+};
+
+bool
+InspectingStatHist::operator ==(const InspectingStatHist & src)
+{
+ assert(bins != NULL && src.bins != NULL); // TODO: remove after initializing bins at construction time
+ if (capacity_ != src.capacity_ ||
+ min_!=src.min_ ||
+ max_!=src.max_ ||
+ scale_!=src.scale_ ||
+ val_in!=src.val_in ||
+ val_out!=src.val_out)
+ return false;
+ return (memcmp(bins,src.bins,capacity_*sizeof(*bins))==0);
+}
+
+
+
+void
+testStatHist::testStatHistBaseEquality()
+{
+ InspectingStatHist raw, test;
+ raw.enumInit(FIVE);
+ test.enumInit(FIVE);
+ CPPUNIT_ASSERT(raw==test);
+ test.count(ZERO);
+ CPPUNIT_ASSERT_ASSERTION_FAIL(CPPUNIT_ASSERT(raw==test));
+}
+
+void
+testStatHist::testStatHistBaseAssignment()
+{
+ InspectingStatHist raw, test;
+ raw.enumInit(FIVE);
+ test.enumInit(FIVE);
+ test.count(ZERO);
+ CPPUNIT_ASSERT_ASSERTION_FAIL(CPPUNIT_ASSERT(raw==test));
+ test=raw;
+ CPPUNIT_ASSERT(raw==test);
+}
+
+
+void
+testStatHist::testStatHistLog()
+{
+ const double min=0.0, max=10000.0;
+ const int capacity=10;
+ InspectingStatHist raw, test;
+ raw.logInit(capacity,min,max);
+ test=raw;
+ CPPUNIT_ASSERT(test.counter(min)==0);
+ test.count(min);
+ CPPUNIT_ASSERT(test.counter(min)==1);
+ CPPUNIT_ASSERT(test.counter(max)==0);
+ test.count(max);
+ CPPUNIT_ASSERT(test.counter(max)==1);
+ test=raw;
+ test.count(max);
+ //CPPUNIT_ASSERT(test.val(capacity-1)==1); //FIXME: val() returns a density
+}
--- /dev/null
+/*
+ * StatHist unit test
+ */
+
+#ifndef TESTSTATHIST_H_
+#define TESTSTATHIST_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+class testStatHist : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE( testStatHist );
+ CPPUNIT_TEST( testStatHistBaseEquality );
+ CPPUNIT_TEST( testStatHistBaseAssignment );
+ CPPUNIT_TEST( testStatHistLog );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+protected:
+ void testStatHistBaseEquality();
+ void testStatHistBaseAssignment();
+ void testStatHistLog();
+};
+
+#endif /* TESTSTATHIST_H_ */
#include "MemBuf.h"
#include "http.h"
#include "PeerSelectState.h"
+#include "StatCounters.h"
class TunnelStateData
{
if (len > 0) {
server.bytesIn(len);
- kb_incr(&statCounter.server.all.kbytes_in, len);
- kb_incr(&statCounter.server.other.kbytes_in, len);
+ kb_incr(&(statCounter.server.all.kbytes_in), len);
+ kb_incr(&(statCounter.server.other.kbytes_in), len);
}
copy (len, errcode, xerrno, server, client, WriteClientDone);
if (len > 0) {
client.bytesIn(len);
- kb_incr(&statCounter.client_http.kbytes_in, len);
+ kb_incr(&(statCounter.client_http.kbytes_in), len);
}
copy (len, errcode, xerrno, client, server, WriteServerDone);
}
/* Valid data */
- kb_incr(&statCounter.server.all.kbytes_out, len);
- kb_incr(&statCounter.server.other.kbytes_out, len);
+ kb_incr(&(statCounter.server.all.kbytes_out), len);
+ kb_incr(&(statCounter.server.other.kbytes_out), len);
client.dataSent(len);
/* If the other end has closed, so should we */
}
/* Valid data */
- kb_incr(&statCounter.client_http.kbytes_out, len);
+ kb_incr(&(statCounter.client_http.kbytes_out), len);
server.dataSent(len);
/* If the other end has closed, so should we */
typedef struct _HttpHeaderFieldAttrs HttpHeaderFieldAttrs;
-typedef struct _HttpHeaderStat HttpHeaderStat;
-
typedef struct _domain_ping domain_ping;
typedef struct _domain_type domain_type;
typedef struct _CommWriteStateData CommWriteStateData;
-typedef struct _StatCounters StatCounters;
-
typedef struct _storeSwapLogData storeSwapLogData;
-typedef struct _StatHist StatHist;
-
-typedef struct _cd_guess_stats cd_guess_stats;
-
typedef struct _CacheDigest CacheDigest;
typedef struct _Version Version;
typedef void HLPCMDOPTS(int *argc, char **argv);
typedef void IDNSCB(void *, rfc1035_rr *, int, const char *);
-typedef double hbase_f(double);
-typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count);
-
/* MD5 cache keys */
typedef unsigned char cache_key;
#include "squid-old.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "SwapDir.h"
#include "fde.h"
#include "xusleep.h"
return;
}
- statCounter.unlink.requests++;
+ ++statCounter.unlink.requests;
/*
* Increment this syscalls counter here, even though the syscall
* is executed by the helper process. We try to be consistent
* in counting unlink operations.
*/
- statCounter.syscalls.disk.unlinks++;
+ ++statCounter.syscalls.disk.unlinks;
queuelen++;
}
#include "comm.h"
#include "HttpRequest.h"
#include "forward.h"
+#include "StatCounters.h"
#define WHOIS_PORT 43
if (!dataWritten)
setReplyToOK(entry);
- kb_incr(&statCounter.server.all.kbytes_in, aBufferLength);
- kb_incr(&statCounter.server.http.kbytes_in, aBufferLength);
+ kb_incr(&(statCounter.server.all.kbytes_in), aBufferLength);
+ kb_incr(&(statCounter.server.http.kbytes_in), aBufferLength);
/* No range support, we always grab it all */
dataWritten = true;