2 * DEBUG: section 16 Cache Manager API
7 #include "base/TextException.h"
8 #include "ipc/Messages.h"
9 #include "ipc/TypedMsgHdr.h"
10 #include "mgr/IntervalAction.h"
11 #include "SquidMath.h"
15 extern void GetAvgStat(Mgr::IntervalActionData
& stats
, int minutes
, int hours
);
16 extern void DumpAvgStat(Mgr::IntervalActionData
& stats
, StoreEntry
* sentry
);
18 Mgr::IntervalActionData::IntervalActionData()
20 xmemset(this, 0, sizeof(*this));
23 Mgr::IntervalActionData
&
24 Mgr::IntervalActionData::operator += (const IntervalActionData
& stats
)
26 if (!timerisset(&sample_start_time
) || timercmp(&sample_start_time
, &stats
.sample_start_time
, >))
27 sample_start_time
= stats
.sample_start_time
;
28 if (timercmp(&sample_end_time
, &stats
.sample_end_time
, <))
29 sample_end_time
= stats
.sample_end_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_all_median_svc_time
+= stats
.client_http_all_median_svc_time
;
36 client_http_miss_median_svc_time
+= stats
.client_http_miss_median_svc_time
;
37 client_http_nm_median_svc_time
+= stats
.client_http_nm_median_svc_time
;
38 client_http_nh_median_svc_time
+= stats
.client_http_nh_median_svc_time
;
39 client_http_hit_median_svc_time
+= stats
.client_http_hit_median_svc_time
;
40 server_all_requests
+= stats
.server_all_requests
;
41 server_all_errors
+= stats
.server_all_errors
;
42 server_all_kbytes_in
+= stats
.server_all_kbytes_in
;
43 server_all_kbytes_out
+= stats
.server_all_kbytes_out
;
44 server_http_requests
+= stats
.server_http_requests
;
45 server_http_errors
+= stats
.server_http_errors
;
46 server_http_kbytes_in
+= stats
.server_http_kbytes_in
;
47 server_http_kbytes_out
+= stats
.server_http_kbytes_out
;
48 server_ftp_requests
+= stats
.server_ftp_requests
;
49 server_ftp_errors
+= stats
.server_ftp_errors
;
50 server_ftp_kbytes_in
+= stats
.server_ftp_kbytes_in
;
51 server_ftp_kbytes_out
+= stats
.server_ftp_kbytes_out
;
52 server_other_requests
+= stats
.server_other_requests
;
53 server_other_errors
+= stats
.server_other_errors
;
54 server_other_kbytes_in
+= stats
.server_other_kbytes_in
;
55 server_other_kbytes_out
+= stats
.server_other_kbytes_out
;
56 icp_pkts_sent
+= stats
.icp_pkts_sent
;
57 icp_pkts_recv
+= stats
.icp_pkts_recv
;
58 icp_queries_sent
+= stats
.icp_queries_sent
;
59 icp_replies_sent
+= stats
.icp_replies_sent
;
60 icp_queries_recv
+= stats
.icp_queries_recv
;
61 icp_replies_recv
+= stats
.icp_replies_recv
;
62 icp_replies_queued
+= stats
.icp_replies_queued
;
63 icp_query_timeouts
+= stats
.icp_query_timeouts
;
64 icp_kbytes_sent
+= stats
.icp_kbytes_sent
;
65 icp_kbytes_recv
+= stats
.icp_kbytes_recv
;
66 icp_q_kbytes_sent
+= stats
.icp_q_kbytes_sent
;
67 icp_r_kbytes_sent
+= stats
.icp_r_kbytes_sent
;
68 icp_q_kbytes_recv
+= stats
.icp_q_kbytes_recv
;
69 icp_r_kbytes_recv
+= stats
.icp_r_kbytes_recv
;
70 icp_query_median_svc_time
+= stats
.icp_query_median_svc_time
;
71 icp_reply_median_svc_time
+= stats
.icp_reply_median_svc_time
;
72 dns_median_svc_time
+= stats
.dns_median_svc_time
;
73 unlink_requests
+= stats
.unlink_requests
;
74 page_faults
+= stats
.page_faults
;
75 select_loops
+= stats
.select_loops
;
76 select_fds
+= stats
.select_fds
;
77 average_select_fd_period
+= stats
.average_select_fd_period
;
78 median_select_fds
+= stats
.median_select_fds
;
79 swap_outs
+= stats
.swap_outs
;
80 swap_ins
+= stats
.swap_ins
;
81 swap_files_cleaned
+= stats
.swap_files_cleaned
;
82 aborted_requests
+= stats
.aborted_requests
;
83 syscalls_disk_opens
+= stats
.syscalls_disk_opens
;
84 syscalls_disk_closes
+= stats
.syscalls_disk_closes
;
85 syscalls_disk_reads
+= stats
.syscalls_disk_reads
;
86 syscalls_disk_writes
+= stats
.syscalls_disk_writes
;
87 syscalls_disk_seeks
+= stats
.syscalls_disk_seeks
;
88 syscalls_disk_unlinks
+= stats
.syscalls_disk_unlinks
;
89 syscalls_sock_accepts
+= stats
.syscalls_sock_accepts
;
90 syscalls_sock_sockets
+= stats
.syscalls_sock_sockets
;
91 syscalls_sock_connects
+= stats
.syscalls_sock_connects
;
92 syscalls_sock_binds
+= stats
.syscalls_sock_binds
;
93 syscalls_sock_closes
+= stats
.syscalls_sock_closes
;
94 syscalls_sock_reads
+= stats
.syscalls_sock_reads
;
95 syscalls_sock_writes
+= stats
.syscalls_sock_writes
;
96 syscalls_sock_recvfroms
+= stats
.syscalls_sock_recvfroms
;
97 syscalls_sock_sendtos
+= stats
.syscalls_sock_sendtos
;
98 syscalls_selects
+= stats
.syscalls_selects
;
99 cpu_time
+= stats
.cpu_time
;
100 wall_time
+= stats
.wall_time
;
106 Mgr::IntervalAction::Pointer
107 Mgr::IntervalAction::Create5min(const CommandPointer
&cmd
)
109 return new IntervalAction(cmd
, 5, 0);
112 Mgr::IntervalAction::Pointer
113 Mgr::IntervalAction::Create60min(const CommandPointer
&cmd
)
115 return new IntervalAction(cmd
, 60, 0);
118 Mgr::IntervalAction::IntervalAction(const CommandPointer
&cmd
, int aMinutes
, int aHours
):
119 Action(cmd
), minutes(aMinutes
), hours(aHours
), data()
125 Mgr::IntervalAction::add(const Action
& action
)
128 data
+= dynamic_cast<const IntervalAction
&>(action
).data
;
132 Mgr::IntervalAction::collect()
134 GetAvgStat(data
, minutes
, hours
);
138 Mgr::IntervalAction::dump(StoreEntry
* entry
)
142 DumpAvgStat(data
, entry
);
146 Mgr::IntervalAction::pack(Ipc::TypedMsgHdr
& msg
) const
148 msg
.setType(Ipc::mtCacheMgrResponse
);
153 Mgr::IntervalAction::unpack(const Ipc::TypedMsgHdr
& msg
)
155 msg
.checkType(Ipc::mtCacheMgrResponse
);