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