]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mem/Stats.cc
Refactor memory pools statistics gathering (#1186)
[thirdparty/squid.git] / src / mem / Stats.cc
1 /*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "mem/Pool.h"
11 #include "mem/Stats.h"
12
13 size_t
14 Mem::GlobalStats(PoolStats &stats)
15 {
16 MemPools::GetInstance().flushMeters();
17
18 stats.meter = &TheMeter;
19 stats.label = "Total";
20 stats.obj_size = 1;
21 stats.overhead += sizeof(MemPools);
22
23 /* gather all stats for Totals */
24 size_t pools_inuse = 0;
25 for (const auto pool: MemPools::GetInstance().pools) {
26 if (pool->getStats(stats) > 0)
27 ++pools_inuse;
28 stats.overhead += sizeof(Allocator *);
29 }
30
31 return pools_inuse;
32 }