]>
Commit | Line | Data |
---|---|---|
8822ebee | 1 | /* |
8822ebee AR |
2 | * DEBUG: section 16 Cache Manager API |
3 | * | |
4 | */ | |
5 | ||
f7f3304a | 6 | #include "squid.h" |
8822ebee | 7 | #include "base/TextException.h" |
c3e8e4e9 | 8 | #include "comm/Connection.h" |
582c2af2 | 9 | #include "globals.h" |
8822ebee AR |
10 | #include "HttpReply.h" |
11 | #include "ipc/Messages.h" | |
51ea0904 | 12 | #include "ipc/UdsOp.h" |
8822ebee AR |
13 | #include "ipc/TypedMsgHdr.h" |
14 | #include "mgr/Filler.h" | |
15 | #include "mgr/InfoAction.h" | |
16 | #include "mgr/Request.h" | |
17 | #include "mgr/Response.h" | |
18 | #include "SquidTime.h" | |
19 | #include "Store.h" | |
5bed43d6 | 20 | #include "tools.h" |
8822ebee | 21 | |
8822ebee AR |
22 | extern void GetInfo(Mgr::InfoActionData& stats); |
23 | extern void DumpInfo(Mgr::InfoActionData& stats, StoreEntry* sentry); | |
24 | extern void DumpMallocStatistics(StoreEntry* sentry); | |
25 | ||
26 | Mgr::InfoActionData::InfoActionData() | |
27 | { | |
28 | xmemset(this, 0, sizeof(*this)); | |
29 | } | |
30 | ||
31 | Mgr::InfoActionData& | |
32 | Mgr::InfoActionData::operator += (const InfoActionData& stats) | |
33 | { | |
34 | if (!timerisset(&squid_start) || timercmp(&squid_start, &stats.squid_start, >)) | |
35 | squid_start = stats.squid_start; | |
36 | if (timercmp(¤t_time, &stats.current_time, <)) | |
37 | current_time = stats.current_time; | |
38 | client_http_clients += stats.client_http_clients; | |
39 | client_http_requests += stats.client_http_requests; | |
40 | icp_pkts_recv += stats.icp_pkts_recv; | |
41 | icp_pkts_sent += stats.icp_pkts_sent; | |
42 | icp_replies_queued += stats.icp_replies_queued; | |
43 | #if USE_HTCP | |
44 | htcp_pkts_recv += stats.htcp_pkts_recv; | |
45 | htcp_pkts_sent += stats.htcp_pkts_sent; | |
46 | #endif | |
47 | request_failure_ratio += stats.request_failure_ratio; | |
48 | avg_client_http_requests += stats.avg_client_http_requests; | |
49 | avg_icp_messages += stats.avg_icp_messages; | |
50 | select_loops += stats.select_loops; | |
51 | avg_loop_time += stats.avg_loop_time; | |
52 | request_hit_ratio5 += stats.request_hit_ratio5; | |
53 | request_hit_ratio60 += stats.request_hit_ratio60; | |
54 | byte_hit_ratio5 += stats.byte_hit_ratio5; | |
55 | byte_hit_ratio60 += stats.byte_hit_ratio60; | |
56 | request_hit_mem_ratio5 += stats.request_hit_mem_ratio5; | |
57 | request_hit_mem_ratio60 += stats.request_hit_mem_ratio60; | |
58 | request_hit_disk_ratio5 += stats.request_hit_disk_ratio5; | |
59 | request_hit_disk_ratio60 += stats.request_hit_disk_ratio60; | |
93bc1434 AR |
60 | |
61 | store += stats.store; | |
62 | ||
8822ebee AR |
63 | unlink_requests += stats.unlink_requests; |
64 | http_requests5 += stats.http_requests5; | |
65 | http_requests60 += stats.http_requests60; | |
66 | cache_misses5 += stats.cache_misses5; | |
67 | cache_misses60 += stats.cache_misses60; | |
68 | cache_hits5 += stats.cache_hits5; | |
69 | cache_hits60 += stats.cache_hits60; | |
70 | near_hits5 += stats.near_hits5; | |
71 | near_hits60 += stats.near_hits60; | |
72 | not_modified_replies5 += stats.not_modified_replies5; | |
73 | not_modified_replies60 += stats.not_modified_replies60; | |
74 | dns_lookups5 += stats.dns_lookups5; | |
75 | dns_lookups60 += stats.dns_lookups60; | |
76 | icp_queries5 += stats.icp_queries5; | |
77 | icp_queries60 += stats.icp_queries60; | |
78 | if (stats.up_time > up_time) | |
79 | up_time = stats.up_time; | |
80 | cpu_time += stats.cpu_time; | |
81 | cpu_usage += stats.cpu_usage; | |
82 | cpu_usage5 += stats.cpu_usage5; | |
83 | cpu_usage60 += stats.cpu_usage60; | |
84 | #if HAVE_SBRK | |
85 | proc_data_seg += stats.proc_data_seg; | |
86 | #endif | |
87 | maxrss += stats.maxrss; | |
88 | page_faults += stats.page_faults; | |
89 | #if HAVE_MSTATS && HAVE_GNUMALLOC_H | |
90 | ms_bytes_total += stats.ms_bytes_total; | |
91 | ms_bytes_free += stats.ms_bytes_free; | |
92 | #elif HAVE_MALLINFO && HAVE_STRUCT_MALLINFO | |
93 | mp_arena += stats.mp_arena; | |
94 | mp_uordblks += stats.mp_uordblks; | |
95 | mp_ordblks += stats.mp_ordblks; | |
96 | mp_usmblks += stats.mp_usmblks; | |
97 | mp_smblks += stats.mp_smblks; | |
98 | mp_hblkhd += stats.mp_hblkhd; | |
99 | mp_hblks += stats.mp_hblks; | |
100 | mp_fsmblks += stats.mp_fsmblks; | |
101 | mp_fordblks += stats.mp_fordblks; | |
102 | #if HAVE_STRUCT_MALLINFO_MXFAST | |
103 | mp_mxfast += stats.mp_mxfast; | |
104 | mp_nlblks += stats.mp_nlblks; | |
105 | mp_grain += stats.mp_grain; | |
106 | mp_uordbytes += stats.mp_uordbytes; | |
107 | mp_allocated += stats.mp_allocated; | |
108 | mp_treeoverhead += stats.mp_treeoverhead; | |
109 | #endif | |
110 | #endif | |
111 | total_accounted += stats.total_accounted; | |
112 | #if !(HAVE_MSTATS && HAVE_GNUMALLOC_H) && HAVE_MALLINFO && HAVE_STRUCT_MALLINFO | |
113 | mem_pool_allocated += stats.mem_pool_allocated; | |
114 | #endif | |
115 | gb_saved_count += stats.gb_saved_count; | |
116 | gb_freed_count += stats.gb_freed_count; | |
117 | max_fd += stats.max_fd; | |
118 | biggest_fd += stats.biggest_fd; | |
119 | number_fd += stats.number_fd; | |
120 | opening_fd += stats.opening_fd; | |
121 | num_fd_free += stats.num_fd_free; | |
122 | reserved_fd += stats.reserved_fd; | |
8822ebee AR |
123 | ++count; |
124 | ||
125 | return *this; | |
126 | } | |
127 | ||
128 | Mgr::InfoAction::Pointer | |
129 | Mgr::InfoAction::Create(const CommandPointer &cmd) | |
130 | { | |
131 | return new InfoAction(cmd); | |
132 | } | |
133 | ||
134 | Mgr::InfoAction::InfoAction(const CommandPointer &cmd): | |
d9fc6862 | 135 | Action(cmd), data() |
8822ebee AR |
136 | { |
137 | debugs(16, 5, HERE); | |
138 | } | |
139 | ||
140 | void | |
141 | Mgr::InfoAction::add(const Action& action) | |
142 | { | |
143 | debugs(16, 5, HERE); | |
144 | data += dynamic_cast<const InfoAction&>(action).data; | |
145 | } | |
146 | ||
147 | void | |
148 | Mgr::InfoAction::respond(const Request& request) | |
149 | { | |
150 | debugs(16, 5, HERE); | |
1b76e6c1 AJ |
151 | Ipc::ImportFdIntoComm(request.conn, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket); |
152 | Must(Comm::IsConnOpen(request.conn)); | |
8822ebee | 153 | Must(request.requestId != 0); |
1b76e6c1 | 154 | AsyncJob::Start(new Mgr::Filler(this, request.conn, request.requestId)); |
8822ebee AR |
155 | } |
156 | ||
157 | void | |
158 | Mgr::InfoAction::collect() | |
159 | { | |
160 | GetInfo(data); | |
161 | } | |
162 | ||
163 | void | |
164 | Mgr::InfoAction::dump(StoreEntry* entry) | |
165 | { | |
166 | debugs(16, 5, HERE); | |
167 | Must(entry != NULL); | |
168 | ||
169 | #if XMALLOC_STATISTICS | |
39c1e1d9 | 170 | if (UsingSmp()) |
8822ebee AR |
171 | storeAppendPrintf(entry, "by kid%d {\n", KidIdentifier); |
172 | DumpMallocStatistics(entry); | |
39c1e1d9 | 173 | if (UsingSmp()) |
8822ebee AR |
174 | storeAppendPrintf(entry, "} by kid%d\n\n", KidIdentifier); |
175 | #endif | |
176 | if (IamPrimaryProcess()) | |
177 | DumpInfo(data, entry); | |
178 | } | |
179 | ||
180 | void | |
181 | Mgr::InfoAction::pack(Ipc::TypedMsgHdr& msg) const | |
182 | { | |
183 | msg.setType(Ipc::mtCacheMgrResponse); | |
184 | msg.putPod(data); | |
185 | } | |
186 | ||
187 | void | |
188 | Mgr::InfoAction::unpack(const Ipc::TypedMsgHdr& msg) | |
189 | { | |
190 | msg.checkType(Ipc::mtCacheMgrResponse); | |
191 | msg.getPod(data); | |
192 | } |