]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/CountersAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / CountersAction.cc
1 /*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8 #include "squid.h"
9 #include "base/TextException.h"
10 #include "ipc/Messages.h"
11 #include "ipc/TypedMsgHdr.h"
12 #include "mgr/CountersAction.h"
13 #include "protos.h"
14 #include "SquidTime.h"
15 #include "Store.h"
16
17 extern void GetCountersStats(Mgr::CountersActionData& stats);
18 extern void DumpCountersStats(Mgr::CountersActionData& stats, StoreEntry* sentry);
19
20 Mgr::CountersActionData::CountersActionData()
21 {
22 xmemset(this, 0, sizeof(*this));
23 }
24
25 Mgr::CountersActionData&
26 Mgr::CountersActionData::operator += (const CountersActionData& stats)
27 {
28 if (timercmp(&sample_time, &stats.sample_time, <))
29 sample_time = stats.sample_time;
30 client_http_requests += stats.client_http_requests;
31 client_http_hits += stats.client_http_hits;
32 client_http_errors += stats.client_http_errors;
33 client_http_kbytes_in += stats.client_http_kbytes_in;
34 client_http_kbytes_out += stats.client_http_kbytes_out;
35 client_http_hit_kbytes_out += stats.client_http_hit_kbytes_out;
36 server_all_requests += stats.server_all_requests;
37 server_all_errors += stats.server_all_errors;
38 server_all_kbytes_in += stats.server_all_kbytes_in;
39 server_all_kbytes_out += stats.server_all_kbytes_out;
40 server_http_requests += stats.server_http_requests;
41 server_http_errors += stats.server_http_errors;
42 server_http_kbytes_in += stats.server_http_kbytes_in;
43 server_http_kbytes_out += stats.server_http_kbytes_out;
44 server_ftp_requests += stats.server_ftp_requests;
45 server_ftp_errors += stats.server_ftp_errors;
46 server_ftp_kbytes_in += stats.server_ftp_kbytes_in;
47 server_ftp_kbytes_out += stats.server_ftp_kbytes_out;
48 server_other_requests += stats.server_other_requests;
49 server_other_errors += stats.server_other_errors;
50 server_other_kbytes_in += stats.server_other_kbytes_in;
51 server_other_kbytes_out += stats.server_other_kbytes_out;
52 icp_pkts_sent += stats.icp_pkts_sent;
53 icp_pkts_recv += stats.icp_pkts_recv;
54 icp_queries_sent += stats.icp_queries_sent;
55 icp_replies_sent += stats.icp_replies_sent;
56 icp_queries_recv += stats.icp_queries_recv;
57 icp_replies_recv += stats.icp_replies_recv;
58 icp_replies_queued += stats.icp_replies_queued;
59 icp_query_timeouts += stats.icp_query_timeouts;
60 icp_kbytes_sent += stats.icp_kbytes_sent;
61 icp_kbytes_recv += stats.icp_kbytes_recv;
62 icp_q_kbytes_sent += stats.icp_q_kbytes_sent;
63 icp_r_kbytes_sent += stats.icp_r_kbytes_sent;
64 icp_q_kbytes_recv += stats.icp_q_kbytes_recv;
65 icp_r_kbytes_recv += stats.icp_r_kbytes_recv;
66 #if USE_CACHE_DIGESTS
67 icp_times_used += stats.icp_times_used;
68 cd_times_used += stats.cd_times_used;
69 cd_msgs_sent += stats.cd_msgs_sent;
70 cd_msgs_recv += stats.cd_msgs_recv;
71 cd_memory += stats.cd_memory;
72 cd_local_memory += stats.cd_local_memory;
73 cd_kbytes_sent += stats.cd_kbytes_sent;
74 cd_kbytes_recv += stats.cd_kbytes_recv;
75 #endif
76 unlink_requests += stats.unlink_requests;
77 page_faults += stats.page_faults;
78 select_loops += stats.select_loops;
79 cpu_time += stats.cpu_time;
80 wall_time += stats.wall_time;
81 swap_outs += stats.swap_outs;
82 swap_ins += stats.swap_ins;
83 swap_files_cleaned += stats.swap_files_cleaned;
84 aborted_requests += stats.aborted_requests;
85
86 return *this;
87 }
88
89 Mgr::CountersAction::Pointer
90 Mgr::CountersAction::Create(const CommandPointer &cmd)
91 {
92 return new CountersAction(cmd);
93 }
94
95 Mgr::CountersAction::CountersAction(const CommandPointer &cmd):
96 Action(cmd), data()
97 {
98 debugs(16, 5, HERE);
99 }
100
101 void
102 Mgr::CountersAction::add(const Action& action)
103 {
104 debugs(16, 5, HERE);
105 data += dynamic_cast<const CountersAction&>(action).data;
106 }
107
108 void
109 Mgr::CountersAction::collect()
110 {
111 debugs(16, 5, HERE);
112 GetCountersStats(data);
113 }
114
115 void
116 Mgr::CountersAction::dump(StoreEntry* entry)
117 {
118 debugs(16, 5, HERE);
119 Must(entry != NULL);
120 DumpCountersStats(data, entry);
121 }
122
123 void
124 Mgr::CountersAction::pack(Ipc::TypedMsgHdr& msg) const
125 {
126 msg.setType(Ipc::mtCacheMgrResponse);
127 msg.putPod(data);
128 }
129
130 void
131 Mgr::CountersAction::unpack(const Ipc::TypedMsgHdr& msg)
132 {
133 msg.checkType(Ipc::mtCacheMgrResponse);
134 msg.getPod(data);
135 }