]>
Commit | Line | Data |
---|---|---|
8822ebee | 1 | /* |
bf95c10a | 2 | * Copyright (C) 1996-2022 The Squid Software Foundation and contributors |
8822ebee | 3 | * |
bbc27441 AJ |
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. | |
8822ebee AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 16 Cache Manager API */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
8822ebee AR |
12 | #include "base/TextException.h" |
13 | #include "ipc/Messages.h" | |
14 | #include "ipc/TypedMsgHdr.h" | |
15 | #include "mgr/IntervalAction.h" | |
16 | #include "SquidMath.h" | |
17 | #include "Store.h" | |
5bed43d6 | 18 | #include "tools.h" |
8822ebee | 19 | |
82afb125 FC |
20 | void GetAvgStat(Mgr::IntervalActionData& stats, int minutes, int hours); |
21 | void DumpAvgStat(Mgr::IntervalActionData& stats, StoreEntry* sentry); | |
8822ebee AR |
22 | |
23 | Mgr::IntervalActionData::IntervalActionData() | |
24 | { | |
e297be13 | 25 | memset(this, 0, sizeof(*this)); |
8822ebee AR |
26 | } |
27 | ||
28 | Mgr::IntervalActionData& | |
29 | Mgr::IntervalActionData::operator += (const IntervalActionData& stats) | |
30 | { | |
31 | if (!timerisset(&sample_start_time) || timercmp(&sample_start_time, &stats.sample_start_time, >)) | |
32 | sample_start_time = stats.sample_start_time; | |
33 | if (timercmp(&sample_end_time, &stats.sample_end_time, <)) | |
34 | sample_end_time = stats.sample_end_time; | |
35 | client_http_requests += stats.client_http_requests; | |
36 | client_http_hits += stats.client_http_hits; | |
37 | client_http_errors += stats.client_http_errors; | |
38 | client_http_kbytes_in += stats.client_http_kbytes_in; | |
39 | client_http_kbytes_out += stats.client_http_kbytes_out; | |
40 | client_http_all_median_svc_time += stats.client_http_all_median_svc_time; | |
41 | client_http_miss_median_svc_time += stats.client_http_miss_median_svc_time; | |
42 | client_http_nm_median_svc_time += stats.client_http_nm_median_svc_time; | |
43 | client_http_nh_median_svc_time += stats.client_http_nh_median_svc_time; | |
44 | client_http_hit_median_svc_time += stats.client_http_hit_median_svc_time; | |
45 | server_all_requests += stats.server_all_requests; | |
46 | server_all_errors += stats.server_all_errors; | |
47 | server_all_kbytes_in += stats.server_all_kbytes_in; | |
48 | server_all_kbytes_out += stats.server_all_kbytes_out; | |
49 | server_http_requests += stats.server_http_requests; | |
50 | server_http_errors += stats.server_http_errors; | |
51 | server_http_kbytes_in += stats.server_http_kbytes_in; | |
52 | server_http_kbytes_out += stats.server_http_kbytes_out; | |
53 | server_ftp_requests += stats.server_ftp_requests; | |
54 | server_ftp_errors += stats.server_ftp_errors; | |
55 | server_ftp_kbytes_in += stats.server_ftp_kbytes_in; | |
56 | server_ftp_kbytes_out += stats.server_ftp_kbytes_out; | |
57 | server_other_requests += stats.server_other_requests; | |
58 | server_other_errors += stats.server_other_errors; | |
59 | server_other_kbytes_in += stats.server_other_kbytes_in; | |
60 | server_other_kbytes_out += stats.server_other_kbytes_out; | |
61 | icp_pkts_sent += stats.icp_pkts_sent; | |
62 | icp_pkts_recv += stats.icp_pkts_recv; | |
63 | icp_queries_sent += stats.icp_queries_sent; | |
64 | icp_replies_sent += stats.icp_replies_sent; | |
65 | icp_queries_recv += stats.icp_queries_recv; | |
66 | icp_replies_recv += stats.icp_replies_recv; | |
67 | icp_replies_queued += stats.icp_replies_queued; | |
68 | icp_query_timeouts += stats.icp_query_timeouts; | |
69 | icp_kbytes_sent += stats.icp_kbytes_sent; | |
70 | icp_kbytes_recv += stats.icp_kbytes_recv; | |
71 | icp_q_kbytes_sent += stats.icp_q_kbytes_sent; | |
72 | icp_r_kbytes_sent += stats.icp_r_kbytes_sent; | |
73 | icp_q_kbytes_recv += stats.icp_q_kbytes_recv; | |
74 | icp_r_kbytes_recv += stats.icp_r_kbytes_recv; | |
75 | icp_query_median_svc_time += stats.icp_query_median_svc_time; | |
76 | icp_reply_median_svc_time += stats.icp_reply_median_svc_time; | |
77 | dns_median_svc_time += stats.dns_median_svc_time; | |
78 | unlink_requests += stats.unlink_requests; | |
79 | page_faults += stats.page_faults; | |
80 | select_loops += stats.select_loops; | |
81 | select_fds += stats.select_fds; | |
82 | average_select_fd_period += stats.average_select_fd_period; | |
83 | median_select_fds += stats.median_select_fds; | |
84 | swap_outs += stats.swap_outs; | |
85 | swap_ins += stats.swap_ins; | |
86 | swap_files_cleaned += stats.swap_files_cleaned; | |
87 | aborted_requests += stats.aborted_requests; | |
b2aca62a EB |
88 | hitValidationAttempts += stats.hitValidationAttempts; |
89 | hitValidationRefusalsDueToLocking += stats.hitValidationRefusalsDueToLocking; | |
90 | hitValidationRefusalsDueToZeroSize += stats.hitValidationRefusalsDueToZeroSize; | |
91 | hitValidationRefusalsDueToTimeLimit += stats.hitValidationRefusalsDueToTimeLimit; | |
92 | hitValidationFailures += stats.hitValidationFailures; | |
8822ebee AR |
93 | syscalls_disk_opens += stats.syscalls_disk_opens; |
94 | syscalls_disk_closes += stats.syscalls_disk_closes; | |
95 | syscalls_disk_reads += stats.syscalls_disk_reads; | |
96 | syscalls_disk_writes += stats.syscalls_disk_writes; | |
97 | syscalls_disk_seeks += stats.syscalls_disk_seeks; | |
98 | syscalls_disk_unlinks += stats.syscalls_disk_unlinks; | |
99 | syscalls_sock_accepts += stats.syscalls_sock_accepts; | |
100 | syscalls_sock_sockets += stats.syscalls_sock_sockets; | |
101 | syscalls_sock_connects += stats.syscalls_sock_connects; | |
102 | syscalls_sock_binds += stats.syscalls_sock_binds; | |
103 | syscalls_sock_closes += stats.syscalls_sock_closes; | |
104 | syscalls_sock_reads += stats.syscalls_sock_reads; | |
105 | syscalls_sock_writes += stats.syscalls_sock_writes; | |
106 | syscalls_sock_recvfroms += stats.syscalls_sock_recvfroms; | |
107 | syscalls_sock_sendtos += stats.syscalls_sock_sendtos; | |
108 | syscalls_selects += stats.syscalls_selects; | |
109 | cpu_time += stats.cpu_time; | |
110 | wall_time += stats.wall_time; | |
111 | ++count; | |
112 | ||
113 | return *this; | |
114 | } | |
115 | ||
116 | Mgr::IntervalAction::Pointer | |
117 | Mgr::IntervalAction::Create5min(const CommandPointer &cmd) | |
118 | { | |
119 | return new IntervalAction(cmd, 5, 0); | |
120 | } | |
121 | ||
122 | Mgr::IntervalAction::Pointer | |
123 | Mgr::IntervalAction::Create60min(const CommandPointer &cmd) | |
124 | { | |
125 | return new IntervalAction(cmd, 60, 0); | |
126 | } | |
127 | ||
9dca980d | 128 | Mgr::IntervalAction::IntervalAction(const CommandPointer &aCmd, int aMinutes, int aHours): |
f53969cc | 129 | Action(aCmd), minutes(aMinutes), hours(aHours), data() |
8822ebee | 130 | { |
bf95c10a | 131 | debugs(16, 5, MYNAME); |
8822ebee AR |
132 | } |
133 | ||
134 | void | |
135 | Mgr::IntervalAction::add(const Action& action) | |
136 | { | |
bf95c10a | 137 | debugs(16, 5, MYNAME); |
8822ebee AR |
138 | data += dynamic_cast<const IntervalAction&>(action).data; |
139 | } | |
140 | ||
141 | void | |
142 | Mgr::IntervalAction::collect() | |
143 | { | |
144 | GetAvgStat(data, minutes, hours); | |
145 | } | |
146 | ||
147 | void | |
148 | Mgr::IntervalAction::dump(StoreEntry* entry) | |
149 | { | |
bf95c10a | 150 | debugs(16, 5, MYNAME); |
aee3523a | 151 | Must(entry != nullptr); |
8822ebee AR |
152 | DumpAvgStat(data, entry); |
153 | } | |
154 | ||
155 | void | |
156 | Mgr::IntervalAction::pack(Ipc::TypedMsgHdr& msg) const | |
157 | { | |
158 | msg.setType(Ipc::mtCacheMgrResponse); | |
159 | msg.putPod(data); | |
160 | } | |
161 | ||
162 | void | |
163 | Mgr::IntervalAction::unpack(const Ipc::TypedMsgHdr& msg) | |
164 | { | |
165 | msg.checkType(Ipc::mtCacheMgrResponse); | |
166 | msg.getPod(data); | |
167 | } | |
f53969cc | 168 |