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/IntervalAction.h"
14 #include "SquidMath.h"
17 extern void GetAvgStat(Mgr::IntervalActionData
& stats
, int minutes
, int hours
);
18 extern void DumpAvgStat(Mgr::IntervalActionData
& stats
, StoreEntry
* sentry
);
20 Mgr::IntervalActionData::IntervalActionData()
22 xmemset(this, 0, sizeof(*this));
25 Mgr::IntervalActionData
&
26 Mgr::IntervalActionData::operator += (const IntervalActionData
& stats
)
28 if (!timerisset(&sample_start_time
) || timercmp(&sample_start_time
, &stats
.sample_start_time
, >))
29 sample_start_time
= stats
.sample_start_time
;
30 if (timercmp(&sample_end_time
, &stats
.sample_end_time
, <))
31 sample_end_time
= stats
.sample_end_time
;
32 client_http_requests
+= stats
.client_http_requests
;
33 client_http_hits
+= stats
.client_http_hits
;
34 client_http_errors
+= stats
.client_http_errors
;
35 client_http_kbytes_in
+= stats
.client_http_kbytes_in
;
36 client_http_kbytes_out
+= stats
.client_http_kbytes_out
;
37 client_http_all_median_svc_time
+= stats
.client_http_all_median_svc_time
;
38 client_http_miss_median_svc_time
+= stats
.client_http_miss_median_svc_time
;
39 client_http_nm_median_svc_time
+= stats
.client_http_nm_median_svc_time
;
40 client_http_nh_median_svc_time
+= stats
.client_http_nh_median_svc_time
;
41 client_http_hit_median_svc_time
+= stats
.client_http_hit_median_svc_time
;
42 server_all_requests
+= stats
.server_all_requests
;
43 server_all_errors
+= stats
.server_all_errors
;
44 server_all_kbytes_in
+= stats
.server_all_kbytes_in
;
45 server_all_kbytes_out
+= stats
.server_all_kbytes_out
;
46 server_http_requests
+= stats
.server_http_requests
;
47 server_http_errors
+= stats
.server_http_errors
;
48 server_http_kbytes_in
+= stats
.server_http_kbytes_in
;
49 server_http_kbytes_out
+= stats
.server_http_kbytes_out
;
50 server_ftp_requests
+= stats
.server_ftp_requests
;
51 server_ftp_errors
+= stats
.server_ftp_errors
;
52 server_ftp_kbytes_in
+= stats
.server_ftp_kbytes_in
;
53 server_ftp_kbytes_out
+= stats
.server_ftp_kbytes_out
;
54 server_other_requests
+= stats
.server_other_requests
;
55 server_other_errors
+= stats
.server_other_errors
;
56 server_other_kbytes_in
+= stats
.server_other_kbytes_in
;
57 server_other_kbytes_out
+= stats
.server_other_kbytes_out
;
58 icp_pkts_sent
+= stats
.icp_pkts_sent
;
59 icp_pkts_recv
+= stats
.icp_pkts_recv
;
60 icp_queries_sent
+= stats
.icp_queries_sent
;
61 icp_replies_sent
+= stats
.icp_replies_sent
;
62 icp_queries_recv
+= stats
.icp_queries_recv
;
63 icp_replies_recv
+= stats
.icp_replies_recv
;
64 icp_replies_queued
+= stats
.icp_replies_queued
;
65 icp_query_timeouts
+= stats
.icp_query_timeouts
;
66 icp_kbytes_sent
+= stats
.icp_kbytes_sent
;
67 icp_kbytes_recv
+= stats
.icp_kbytes_recv
;
68 icp_q_kbytes_sent
+= stats
.icp_q_kbytes_sent
;
69 icp_r_kbytes_sent
+= stats
.icp_r_kbytes_sent
;
70 icp_q_kbytes_recv
+= stats
.icp_q_kbytes_recv
;
71 icp_r_kbytes_recv
+= stats
.icp_r_kbytes_recv
;
72 icp_query_median_svc_time
+= stats
.icp_query_median_svc_time
;
73 icp_reply_median_svc_time
+= stats
.icp_reply_median_svc_time
;
74 dns_median_svc_time
+= stats
.dns_median_svc_time
;
75 unlink_requests
+= stats
.unlink_requests
;
76 page_faults
+= stats
.page_faults
;
77 select_loops
+= stats
.select_loops
;
78 select_fds
+= stats
.select_fds
;
79 average_select_fd_period
+= stats
.average_select_fd_period
;
80 median_select_fds
+= stats
.median_select_fds
;
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
;
85 syscalls_disk_opens
+= stats
.syscalls_disk_opens
;
86 syscalls_disk_closes
+= stats
.syscalls_disk_closes
;
87 syscalls_disk_reads
+= stats
.syscalls_disk_reads
;
88 syscalls_disk_writes
+= stats
.syscalls_disk_writes
;
89 syscalls_disk_seeks
+= stats
.syscalls_disk_seeks
;
90 syscalls_disk_unlinks
+= stats
.syscalls_disk_unlinks
;
91 syscalls_sock_accepts
+= stats
.syscalls_sock_accepts
;
92 syscalls_sock_sockets
+= stats
.syscalls_sock_sockets
;
93 syscalls_sock_connects
+= stats
.syscalls_sock_connects
;
94 syscalls_sock_binds
+= stats
.syscalls_sock_binds
;
95 syscalls_sock_closes
+= stats
.syscalls_sock_closes
;
96 syscalls_sock_reads
+= stats
.syscalls_sock_reads
;
97 syscalls_sock_writes
+= stats
.syscalls_sock_writes
;
98 syscalls_sock_recvfroms
+= stats
.syscalls_sock_recvfroms
;
99 syscalls_sock_sendtos
+= stats
.syscalls_sock_sendtos
;
100 syscalls_selects
+= stats
.syscalls_selects
;
101 cpu_time
+= stats
.cpu_time
;
102 wall_time
+= stats
.wall_time
;
108 Mgr::IntervalAction::Pointer
109 Mgr::IntervalAction::Create5min(const CommandPointer
&cmd
)
111 return new IntervalAction(cmd
, 5, 0);
114 Mgr::IntervalAction::Pointer
115 Mgr::IntervalAction::Create60min(const CommandPointer
&cmd
)
117 return new IntervalAction(cmd
, 60, 0);
120 Mgr::IntervalAction::IntervalAction(const CommandPointer
&cmd
, int aMinutes
, int aHours
):
121 Action(cmd
), minutes(aMinutes
), hours(aHours
), data()
127 Mgr::IntervalAction::add(const Action
& action
)
130 data
+= dynamic_cast<const IntervalAction
&>(action
).data
;
134 Mgr::IntervalAction::collect()
136 GetAvgStat(data
, minutes
, hours
);
140 Mgr::IntervalAction::dump(StoreEntry
* entry
)
144 DumpAvgStat(data
, entry
);
148 Mgr::IntervalAction::pack(Ipc::TypedMsgHdr
& msg
) const
150 msg
.setType(Ipc::mtCacheMgrResponse
);
155 Mgr::IntervalAction::unpack(const Ipc::TypedMsgHdr
& msg
)
157 msg
.checkType(Ipc::mtCacheMgrResponse
);