]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/InfoAction.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 16 Cache Manager API */
12 #include "base/TextException.h"
13 #include "comm/Connection.h"
15 #include "HttpReply.h"
16 #include "ipc/Messages.h"
17 #include "ipc/TypedMsgHdr.h"
18 #include "ipc/UdsOp.h"
19 #include "mgr/Filler.h"
20 #include "mgr/InfoAction.h"
21 #include "mgr/Request.h"
22 #include "mgr/Response.h"
23 #include "SquidTime.h"
27 void GetInfo(Mgr::InfoActionData
& stats
);
28 void DumpInfo(Mgr::InfoActionData
& stats
, StoreEntry
* sentry
);
29 void DumpMallocStatistics(StoreEntry
* sentry
);
31 Mgr::InfoActionData::InfoActionData()
33 memset(this, 0, sizeof(*this));
37 Mgr::InfoActionData::operator += (const InfoActionData
& stats
)
39 if (!timerisset(&squid_start
) || timercmp(&squid_start
, &stats
.squid_start
, >))
40 squid_start
= stats
.squid_start
;
41 if (timercmp(¤t_time
, &stats
.current_time
, <))
42 current_time
= stats
.current_time
;
43 client_http_clients
+= stats
.client_http_clients
;
44 client_http_requests
+= stats
.client_http_requests
;
45 icp_pkts_recv
+= stats
.icp_pkts_recv
;
46 icp_pkts_sent
+= stats
.icp_pkts_sent
;
47 icp_replies_queued
+= stats
.icp_replies_queued
;
49 htcp_pkts_recv
+= stats
.htcp_pkts_recv
;
50 htcp_pkts_sent
+= stats
.htcp_pkts_sent
;
52 request_failure_ratio
+= stats
.request_failure_ratio
;
53 avg_client_http_requests
+= stats
.avg_client_http_requests
;
54 avg_icp_messages
+= stats
.avg_icp_messages
;
55 select_loops
+= stats
.select_loops
;
56 avg_loop_time
+= stats
.avg_loop_time
;
57 request_hit_ratio5
+= stats
.request_hit_ratio5
;
58 request_hit_ratio60
+= stats
.request_hit_ratio60
;
59 byte_hit_ratio5
+= stats
.byte_hit_ratio5
;
60 byte_hit_ratio60
+= stats
.byte_hit_ratio60
;
61 request_hit_mem_ratio5
+= stats
.request_hit_mem_ratio5
;
62 request_hit_mem_ratio60
+= stats
.request_hit_mem_ratio60
;
63 request_hit_disk_ratio5
+= stats
.request_hit_disk_ratio5
;
64 request_hit_disk_ratio60
+= stats
.request_hit_disk_ratio60
;
68 unlink_requests
+= stats
.unlink_requests
;
69 http_requests5
+= stats
.http_requests5
;
70 http_requests60
+= stats
.http_requests60
;
71 cache_misses5
+= stats
.cache_misses5
;
72 cache_misses60
+= stats
.cache_misses60
;
73 cache_hits5
+= stats
.cache_hits5
;
74 cache_hits60
+= stats
.cache_hits60
;
75 near_hits5
+= stats
.near_hits5
;
76 near_hits60
+= stats
.near_hits60
;
77 not_modified_replies5
+= stats
.not_modified_replies5
;
78 not_modified_replies60
+= stats
.not_modified_replies60
;
79 dns_lookups5
+= stats
.dns_lookups5
;
80 dns_lookups60
+= stats
.dns_lookups60
;
81 icp_queries5
+= stats
.icp_queries5
;
82 icp_queries60
+= stats
.icp_queries60
;
83 if (stats
.up_time
> up_time
)
84 up_time
= stats
.up_time
;
85 cpu_time
+= stats
.cpu_time
;
86 cpu_usage
+= stats
.cpu_usage
;
87 cpu_usage5
+= stats
.cpu_usage5
;
88 cpu_usage60
+= stats
.cpu_usage60
;
89 maxrss
+= stats
.maxrss
;
90 page_faults
+= stats
.page_faults
;
91 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
92 ms_bytes_total
+= stats
.ms_bytes_total
;
93 ms_bytes_free
+= stats
.ms_bytes_free
;
95 total_accounted
+= stats
.total_accounted
;
96 gb_saved_count
+= stats
.gb_saved_count
;
97 gb_freed_count
+= stats
.gb_freed_count
;
98 max_fd
+= stats
.max_fd
;
99 biggest_fd
= max(biggest_fd
, stats
.biggest_fd
);
100 number_fd
+= stats
.number_fd
;
101 opening_fd
+= stats
.opening_fd
;
102 num_fd_free
+= stats
.num_fd_free
;
103 reserved_fd
+= stats
.reserved_fd
;
109 Mgr::InfoAction::Pointer
110 Mgr::InfoAction::Create(const CommandPointer
&cmd
)
112 return new InfoAction(cmd
);
115 Mgr::InfoAction::InfoAction(const CommandPointer
&aCmd
):
122 Mgr::InfoAction::add(const Action
& action
)
125 data
+= dynamic_cast<const InfoAction
&>(action
).data
;
129 Mgr::InfoAction::respond(const Request
& request
)
132 Ipc::ImportFdIntoComm(request
.conn
, SOCK_STREAM
, IPPROTO_TCP
, Ipc::fdnHttpSocket
);
133 Must(Comm::IsConnOpen(request
.conn
));
134 Must(request
.requestId
!= 0);
135 AsyncJob::Start(new Mgr::Filler(this, request
.conn
, request
.requestId
));
139 Mgr::InfoAction::collect()
145 Mgr::InfoAction::dump(StoreEntry
* entry
)
150 #if XMALLOC_STATISTICS
152 storeAppendPrintf(entry
, "by kid%d {\n", KidIdentifier
);
153 DumpMallocStatistics(entry
);
155 storeAppendPrintf(entry
, "} by kid%d\n\n", KidIdentifier
);
157 if (IamPrimaryProcess())
158 DumpInfo(data
, entry
);
162 Mgr::InfoAction::pack(Ipc::TypedMsgHdr
& msg
) const
164 msg
.setType(Ipc::mtCacheMgrResponse
);
169 Mgr::InfoAction::unpack(const Ipc::TypedMsgHdr
& msg
)
171 msg
.checkType(Ipc::mtCacheMgrResponse
);