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