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