]>
Commit | Line | Data |
---|---|---|
8822ebee | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 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/CountersAction.h" | |
16 | #include "SquidTime.h" | |
17 | #include "Store.h" | |
5bed43d6 | 18 | #include "tools.h" |
8822ebee | 19 | |
82afb125 FC |
20 | void GetCountersStats(Mgr::CountersActionData& stats); |
21 | void DumpCountersStats(Mgr::CountersActionData& stats, StoreEntry* sentry); | |
8822ebee AR |
22 | |
23 | Mgr::CountersActionData::CountersActionData() | |
24 | { | |
e297be13 | 25 | memset(this, 0, sizeof(*this)); |
8822ebee AR |
26 | } |
27 | ||
28 | Mgr::CountersActionData& | |
29 | Mgr::CountersActionData::operator += (const CountersActionData& stats) | |
30 | { | |
31 | if (timercmp(&sample_time, &stats.sample_time, <)) | |
32 | sample_time = stats.sample_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_hit_kbytes_out += stats.client_http_hit_kbytes_out; | |
39 | server_all_requests += stats.server_all_requests; | |
40 | server_all_errors += stats.server_all_errors; | |
41 | server_all_kbytes_in += stats.server_all_kbytes_in; | |
42 | server_all_kbytes_out += stats.server_all_kbytes_out; | |
43 | server_http_requests += stats.server_http_requests; | |
44 | server_http_errors += stats.server_http_errors; | |
45 | server_http_kbytes_in += stats.server_http_kbytes_in; | |
46 | server_http_kbytes_out += stats.server_http_kbytes_out; | |
47 | server_ftp_requests += stats.server_ftp_requests; | |
48 | server_ftp_errors += stats.server_ftp_errors; | |
49 | server_ftp_kbytes_in += stats.server_ftp_kbytes_in; | |
50 | server_ftp_kbytes_out += stats.server_ftp_kbytes_out; | |
51 | server_other_requests += stats.server_other_requests; | |
52 | server_other_errors += stats.server_other_errors; | |
53 | server_other_kbytes_in += stats.server_other_kbytes_in; | |
54 | server_other_kbytes_out += stats.server_other_kbytes_out; | |
55 | icp_pkts_sent += stats.icp_pkts_sent; | |
56 | icp_pkts_recv += stats.icp_pkts_recv; | |
57 | icp_queries_sent += stats.icp_queries_sent; | |
58 | icp_replies_sent += stats.icp_replies_sent; | |
59 | icp_queries_recv += stats.icp_queries_recv; | |
60 | icp_replies_recv += stats.icp_replies_recv; | |
61 | icp_replies_queued += stats.icp_replies_queued; | |
62 | icp_query_timeouts += stats.icp_query_timeouts; | |
63 | icp_kbytes_sent += stats.icp_kbytes_sent; | |
64 | icp_kbytes_recv += stats.icp_kbytes_recv; | |
65 | icp_q_kbytes_sent += stats.icp_q_kbytes_sent; | |
66 | icp_r_kbytes_sent += stats.icp_r_kbytes_sent; | |
67 | icp_q_kbytes_recv += stats.icp_q_kbytes_recv; | |
68 | icp_r_kbytes_recv += stats.icp_r_kbytes_recv; | |
69 | #if USE_CACHE_DIGESTS | |
70 | icp_times_used += stats.icp_times_used; | |
71 | cd_times_used += stats.cd_times_used; | |
72 | cd_msgs_sent += stats.cd_msgs_sent; | |
73 | cd_msgs_recv += stats.cd_msgs_recv; | |
74 | cd_memory += stats.cd_memory; | |
75 | cd_local_memory += stats.cd_local_memory; | |
76 | cd_kbytes_sent += stats.cd_kbytes_sent; | |
77 | cd_kbytes_recv += stats.cd_kbytes_recv; | |
78 | #endif | |
79 | unlink_requests += stats.unlink_requests; | |
80 | page_faults += stats.page_faults; | |
81 | select_loops += stats.select_loops; | |
82 | cpu_time += stats.cpu_time; | |
83 | wall_time += stats.wall_time; | |
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; | |
88 | ||
89 | return *this; | |
90 | } | |
91 | ||
92 | Mgr::CountersAction::Pointer | |
93 | Mgr::CountersAction::Create(const CommandPointer &cmd) | |
94 | { | |
95 | return new CountersAction(cmd); | |
96 | } | |
97 | ||
9dca980d | 98 | Mgr::CountersAction::CountersAction(const CommandPointer &aCmd): |
f53969cc | 99 | Action(aCmd), data() |
8822ebee AR |
100 | { |
101 | debugs(16, 5, HERE); | |
102 | } | |
103 | ||
104 | void | |
105 | Mgr::CountersAction::add(const Action& action) | |
106 | { | |
107 | debugs(16, 5, HERE); | |
108 | data += dynamic_cast<const CountersAction&>(action).data; | |
109 | } | |
110 | ||
111 | void | |
112 | Mgr::CountersAction::collect() | |
113 | { | |
114 | debugs(16, 5, HERE); | |
115 | GetCountersStats(data); | |
116 | } | |
117 | ||
118 | void | |
119 | Mgr::CountersAction::dump(StoreEntry* entry) | |
120 | { | |
121 | debugs(16, 5, HERE); | |
122 | Must(entry != NULL); | |
123 | DumpCountersStats(data, entry); | |
124 | } | |
125 | ||
126 | void | |
127 | Mgr::CountersAction::pack(Ipc::TypedMsgHdr& msg) const | |
128 | { | |
129 | msg.setType(Ipc::mtCacheMgrResponse); | |
130 | msg.putPod(data); | |
131 | } | |
132 | ||
133 | void | |
134 | Mgr::CountersAction::unpack(const Ipc::TypedMsgHdr& msg) | |
135 | { | |
136 | msg.checkType(Ipc::mtCacheMgrResponse); | |
137 | msg.getPod(data); | |
138 | } | |
f53969cc | 139 |