]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/IntervalAction.cc
Removed squid-old.h
[thirdparty/squid.git] / src / mgr / IntervalAction.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/IntervalAction.h"
13 #include "protos.h"
14 #include "SquidMath.h"
15 #include "Store.h"
16
17
18 extern void GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours);
19 extern void DumpAvgStat(Mgr::IntervalActionData& stats, StoreEntry* sentry);
20
21 Mgr::IntervalActionData::IntervalActionData()
22 {
23 xmemset(this, 0, sizeof(*this));
24 }
25
26 Mgr::IntervalActionData&
27 Mgr::IntervalActionData::operator += (const IntervalActionData& stats)
28 {
29 if (!timerisset(&sample_start_time) || timercmp(&sample_start_time, &stats.sample_start_time, >))
30 sample_start_time = stats.sample_start_time;
31 if (timercmp(&sample_end_time, &stats.sample_end_time, <))
32 sample_end_time = stats.sample_end_time;
33 client_http_requests += stats.client_http_requests;
34 client_http_hits += stats.client_http_hits;
35 client_http_errors += stats.client_http_errors;
36 client_http_kbytes_in += stats.client_http_kbytes_in;
37 client_http_kbytes_out += stats.client_http_kbytes_out;
38 client_http_all_median_svc_time += stats.client_http_all_median_svc_time;
39 client_http_miss_median_svc_time += stats.client_http_miss_median_svc_time;
40 client_http_nm_median_svc_time += stats.client_http_nm_median_svc_time;
41 client_http_nh_median_svc_time += stats.client_http_nh_median_svc_time;
42 client_http_hit_median_svc_time += stats.client_http_hit_median_svc_time;
43 server_all_requests += stats.server_all_requests;
44 server_all_errors += stats.server_all_errors;
45 server_all_kbytes_in += stats.server_all_kbytes_in;
46 server_all_kbytes_out += stats.server_all_kbytes_out;
47 server_http_requests += stats.server_http_requests;
48 server_http_errors += stats.server_http_errors;
49 server_http_kbytes_in += stats.server_http_kbytes_in;
50 server_http_kbytes_out += stats.server_http_kbytes_out;
51 server_ftp_requests += stats.server_ftp_requests;
52 server_ftp_errors += stats.server_ftp_errors;
53 server_ftp_kbytes_in += stats.server_ftp_kbytes_in;
54 server_ftp_kbytes_out += stats.server_ftp_kbytes_out;
55 server_other_requests += stats.server_other_requests;
56 server_other_errors += stats.server_other_errors;
57 server_other_kbytes_in += stats.server_other_kbytes_in;
58 server_other_kbytes_out += stats.server_other_kbytes_out;
59 icp_pkts_sent += stats.icp_pkts_sent;
60 icp_pkts_recv += stats.icp_pkts_recv;
61 icp_queries_sent += stats.icp_queries_sent;
62 icp_replies_sent += stats.icp_replies_sent;
63 icp_queries_recv += stats.icp_queries_recv;
64 icp_replies_recv += stats.icp_replies_recv;
65 icp_replies_queued += stats.icp_replies_queued;
66 icp_query_timeouts += stats.icp_query_timeouts;
67 icp_kbytes_sent += stats.icp_kbytes_sent;
68 icp_kbytes_recv += stats.icp_kbytes_recv;
69 icp_q_kbytes_sent += stats.icp_q_kbytes_sent;
70 icp_r_kbytes_sent += stats.icp_r_kbytes_sent;
71 icp_q_kbytes_recv += stats.icp_q_kbytes_recv;
72 icp_r_kbytes_recv += stats.icp_r_kbytes_recv;
73 icp_query_median_svc_time += stats.icp_query_median_svc_time;
74 icp_reply_median_svc_time += stats.icp_reply_median_svc_time;
75 dns_median_svc_time += stats.dns_median_svc_time;
76 unlink_requests += stats.unlink_requests;
77 page_faults += stats.page_faults;
78 select_loops += stats.select_loops;
79 select_fds += stats.select_fds;
80 average_select_fd_period += stats.average_select_fd_period;
81 median_select_fds += stats.median_select_fds;
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 syscalls_disk_opens += stats.syscalls_disk_opens;
87 syscalls_disk_closes += stats.syscalls_disk_closes;
88 syscalls_disk_reads += stats.syscalls_disk_reads;
89 syscalls_disk_writes += stats.syscalls_disk_writes;
90 syscalls_disk_seeks += stats.syscalls_disk_seeks;
91 syscalls_disk_unlinks += stats.syscalls_disk_unlinks;
92 syscalls_sock_accepts += stats.syscalls_sock_accepts;
93 syscalls_sock_sockets += stats.syscalls_sock_sockets;
94 syscalls_sock_connects += stats.syscalls_sock_connects;
95 syscalls_sock_binds += stats.syscalls_sock_binds;
96 syscalls_sock_closes += stats.syscalls_sock_closes;
97 syscalls_sock_reads += stats.syscalls_sock_reads;
98 syscalls_sock_writes += stats.syscalls_sock_writes;
99 syscalls_sock_recvfroms += stats.syscalls_sock_recvfroms;
100 syscalls_sock_sendtos += stats.syscalls_sock_sendtos;
101 syscalls_selects += stats.syscalls_selects;
102 cpu_time += stats.cpu_time;
103 wall_time += stats.wall_time;
104 ++count;
105
106 return *this;
107 }
108
109 Mgr::IntervalAction::Pointer
110 Mgr::IntervalAction::Create5min(const CommandPointer &cmd)
111 {
112 return new IntervalAction(cmd, 5, 0);
113 }
114
115 Mgr::IntervalAction::Pointer
116 Mgr::IntervalAction::Create60min(const CommandPointer &cmd)
117 {
118 return new IntervalAction(cmd, 60, 0);
119 }
120
121 Mgr::IntervalAction::IntervalAction(const CommandPointer &cmd, int aMinutes, int aHours):
122 Action(cmd), minutes(aMinutes), hours(aHours), data()
123 {
124 debugs(16, 5, HERE);
125 }
126
127 void
128 Mgr::IntervalAction::add(const Action& action)
129 {
130 debugs(16, 5, HERE);
131 data += dynamic_cast<const IntervalAction&>(action).data;
132 }
133
134 void
135 Mgr::IntervalAction::collect()
136 {
137 GetAvgStat(data, minutes, hours);
138 }
139
140 void
141 Mgr::IntervalAction::dump(StoreEntry* entry)
142 {
143 debugs(16, 5, HERE);
144 Must(entry != NULL);
145 DumpAvgStat(data, entry);
146 }
147
148 void
149 Mgr::IntervalAction::pack(Ipc::TypedMsgHdr& msg) const
150 {
151 msg.setType(Ipc::mtCacheMgrResponse);
152 msg.putPod(data);
153 }
154
155 void
156 Mgr::IntervalAction::unpack(const Ipc::TypedMsgHdr& msg)
157 {
158 msg.checkType(Ipc::mtCacheMgrResponse);
159 msg.getPod(data);
160 }