]> git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreStats.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / StoreStats.h
1 /*
2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_STORE_STATS_H
10 #define SQUID_STORE_STATS_H
11
12 /// High-level store statistics used by mgr:info action. Used inside PODs!
13 class StoreInfoStats
14 {
15 public:
16 /// Info common to memory and disk parts of the storage. Used inside PODs!
17 class Part
18 {
19 public:
20 double size = 0.0; ///< bytes currently in use
21 double count = 0.0; ///< number of cached objects
22 double capacity = 0.0; ///< the size limit
23
24 /// mean size of a cached object
25 double meanObjectSize() const { return count > 0 ? size/count : 0.0; }
26
27 /// number of unused bytes
28 double available() const { return capacity - size; }
29 };
30
31 /// disk cache (all cache_dirs) storage stats
32 class Swap: public Part
33 {
34 public:
35 double open_disk_fd = 0.0; ///< number of opened disk files
36 };
37
38 /// memory cache (cache_mem) storage stats
39 class Mem: public Part
40 {
41 public:
42 bool shared = false; ///< whether memory cache is shared among workers
43 };
44
45 StoreInfoStats &operator +=(const StoreInfoStats &stats);
46
47 Swap swap; ///< cache_mem stats
48 Mem mem; ///< all cache_dirs stats
49
50 /* stats that could be shared by memory and disk storage */
51 double store_entry_count = 0.0; ///< number of StoreEntry objects in existence
52 double mem_object_count = 0.0; ///< number of MemObject objects in existence
53 };
54
55 // TODO: this should be adjusted for use in StoreIoActionData, DiskdActionData
56 /// Store statistics related to low-level I/O.
57 class StoreIoStats
58 {
59 public:
60 StoreIoStats();
61
62 struct {
63 int calls;
64 int select_fail;
65 int create_fail;
66 int success;
67 } create; ///< cache_dir selection and disk entry creation stats
68 };
69
70 #endif /* SQUID_STORE_STATS_H */
71