4 * DEBUG: section 16 Cache Manager API
9 #include "base/TextException.h"
10 #include "ipc/Messages.h"
11 #include "ipc/TypedMsgHdr.h"
12 #include "mgr/CountersAction.h"
14 #include "SquidTime.h"
17 extern void GetCountersStats(Mgr::CountersActionData
& stats
);
18 extern void DumpCountersStats(Mgr::CountersActionData
& stats
, StoreEntry
* sentry
);
20 Mgr::CountersActionData::CountersActionData()
22 xmemset(this, 0, sizeof(*this));
25 Mgr::CountersActionData
&
26 Mgr::CountersActionData::operator += (const CountersActionData
& stats
)
28 if (timercmp(&sample_time
, &stats
.sample_time
, <))
29 sample_time
= stats
.sample_time
;
30 client_http_requests
+= stats
.client_http_requests
;
31 client_http_hits
+= stats
.client_http_hits
;
32 client_http_errors
+= stats
.client_http_errors
;
33 client_http_kbytes_in
+= stats
.client_http_kbytes_in
;
34 client_http_kbytes_out
+= stats
.client_http_kbytes_out
;
35 client_http_hit_kbytes_out
+= stats
.client_http_hit_kbytes_out
;
36 server_all_requests
+= stats
.server_all_requests
;
37 server_all_errors
+= stats
.server_all_errors
;
38 server_all_kbytes_in
+= stats
.server_all_kbytes_in
;
39 server_all_kbytes_out
+= stats
.server_all_kbytes_out
;
40 server_http_requests
+= stats
.server_http_requests
;
41 server_http_errors
+= stats
.server_http_errors
;
42 server_http_kbytes_in
+= stats
.server_http_kbytes_in
;
43 server_http_kbytes_out
+= stats
.server_http_kbytes_out
;
44 server_ftp_requests
+= stats
.server_ftp_requests
;
45 server_ftp_errors
+= stats
.server_ftp_errors
;
46 server_ftp_kbytes_in
+= stats
.server_ftp_kbytes_in
;
47 server_ftp_kbytes_out
+= stats
.server_ftp_kbytes_out
;
48 server_other_requests
+= stats
.server_other_requests
;
49 server_other_errors
+= stats
.server_other_errors
;
50 server_other_kbytes_in
+= stats
.server_other_kbytes_in
;
51 server_other_kbytes_out
+= stats
.server_other_kbytes_out
;
52 icp_pkts_sent
+= stats
.icp_pkts_sent
;
53 icp_pkts_recv
+= stats
.icp_pkts_recv
;
54 icp_queries_sent
+= stats
.icp_queries_sent
;
55 icp_replies_sent
+= stats
.icp_replies_sent
;
56 icp_queries_recv
+= stats
.icp_queries_recv
;
57 icp_replies_recv
+= stats
.icp_replies_recv
;
58 icp_replies_queued
+= stats
.icp_replies_queued
;
59 icp_query_timeouts
+= stats
.icp_query_timeouts
;
60 icp_kbytes_sent
+= stats
.icp_kbytes_sent
;
61 icp_kbytes_recv
+= stats
.icp_kbytes_recv
;
62 icp_q_kbytes_sent
+= stats
.icp_q_kbytes_sent
;
63 icp_r_kbytes_sent
+= stats
.icp_r_kbytes_sent
;
64 icp_q_kbytes_recv
+= stats
.icp_q_kbytes_recv
;
65 icp_r_kbytes_recv
+= stats
.icp_r_kbytes_recv
;
67 icp_times_used
+= stats
.icp_times_used
;
68 cd_times_used
+= stats
.cd_times_used
;
69 cd_msgs_sent
+= stats
.cd_msgs_sent
;
70 cd_msgs_recv
+= stats
.cd_msgs_recv
;
71 cd_memory
+= stats
.cd_memory
;
72 cd_local_memory
+= stats
.cd_local_memory
;
73 cd_kbytes_sent
+= stats
.cd_kbytes_sent
;
74 cd_kbytes_recv
+= stats
.cd_kbytes_recv
;
76 unlink_requests
+= stats
.unlink_requests
;
77 page_faults
+= stats
.page_faults
;
78 select_loops
+= stats
.select_loops
;
79 cpu_time
+= stats
.cpu_time
;
80 wall_time
+= stats
.wall_time
;
81 swap_outs
+= stats
.swap_outs
;
82 swap_ins
+= stats
.swap_ins
;
83 swap_files_cleaned
+= stats
.swap_files_cleaned
;
84 aborted_requests
+= stats
.aborted_requests
;
89 Mgr::CountersAction::Pointer
90 Mgr::CountersAction::Create(const CommandPointer
&cmd
)
92 return new CountersAction(cmd
);
95 Mgr::CountersAction::CountersAction(const CommandPointer
&cmd
):
102 Mgr::CountersAction::add(const Action
& action
)
105 data
+= dynamic_cast<const CountersAction
&>(action
).data
;
109 Mgr::CountersAction::collect()
112 GetCountersStats(data
);
116 Mgr::CountersAction::dump(StoreEntry
* entry
)
120 DumpCountersStats(data
, entry
);
124 Mgr::CountersAction::pack(Ipc::TypedMsgHdr
& msg
) const
126 msg
.setType(Ipc::mtCacheMgrResponse
);
131 Mgr::CountersAction::unpack(const Ipc::TypedMsgHdr
& msg
)
133 msg
.checkType(Ipc::mtCacheMgrResponse
);