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"
18 extern void GetAvgStat(Mgr::IntervalActionData
& stats
, int minutes
, int hours
);
19 extern void DumpAvgStat(Mgr::IntervalActionData
& stats
, StoreEntry
* sentry
);
21 Mgr::IntervalActionData::IntervalActionData()
23 xmemset(this, 0, sizeof(*this));
26 Mgr::IntervalActionData
&
27 Mgr::IntervalActionData::operator += (const IntervalActionData
& stats
)
29 if (!timerisset(&sample_start_time
) || timercmp(&sample_start_time
, &stats
.sample_start_time
, >))
30 sample_start_time
= stats
.sample_start_time
;
31 if (timercmp(&sample_end_time
, &stats
.sample_end_time
, <))
32 sample_end_time
= stats
.sample_end_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_all_median_svc_time
+= stats
.client_http_all_median_svc_time
;
39 client_http_miss_median_svc_time
+= stats
.client_http_miss_median_svc_time
;
40 client_http_nm_median_svc_time
+= stats
.client_http_nm_median_svc_time
;
41 client_http_nh_median_svc_time
+= stats
.client_http_nh_median_svc_time
;
42 client_http_hit_median_svc_time
+= stats
.client_http_hit_median_svc_time
;
43 server_all_requests
+= stats
.server_all_requests
;
44 server_all_errors
+= stats
.server_all_errors
;
45 server_all_kbytes_in
+= stats
.server_all_kbytes_in
;
46 server_all_kbytes_out
+= stats
.server_all_kbytes_out
;
47 server_http_requests
+= stats
.server_http_requests
;
48 server_http_errors
+= stats
.server_http_errors
;
49 server_http_kbytes_in
+= stats
.server_http_kbytes_in
;
50 server_http_kbytes_out
+= stats
.server_http_kbytes_out
;
51 server_ftp_requests
+= stats
.server_ftp_requests
;
52 server_ftp_errors
+= stats
.server_ftp_errors
;
53 server_ftp_kbytes_in
+= stats
.server_ftp_kbytes_in
;
54 server_ftp_kbytes_out
+= stats
.server_ftp_kbytes_out
;
55 server_other_requests
+= stats
.server_other_requests
;
56 server_other_errors
+= stats
.server_other_errors
;
57 server_other_kbytes_in
+= stats
.server_other_kbytes_in
;
58 server_other_kbytes_out
+= stats
.server_other_kbytes_out
;
59 icp_pkts_sent
+= stats
.icp_pkts_sent
;
60 icp_pkts_recv
+= stats
.icp_pkts_recv
;
61 icp_queries_sent
+= stats
.icp_queries_sent
;
62 icp_replies_sent
+= stats
.icp_replies_sent
;
63 icp_queries_recv
+= stats
.icp_queries_recv
;
64 icp_replies_recv
+= stats
.icp_replies_recv
;
65 icp_replies_queued
+= stats
.icp_replies_queued
;
66 icp_query_timeouts
+= stats
.icp_query_timeouts
;
67 icp_kbytes_sent
+= stats
.icp_kbytes_sent
;
68 icp_kbytes_recv
+= stats
.icp_kbytes_recv
;
69 icp_q_kbytes_sent
+= stats
.icp_q_kbytes_sent
;
70 icp_r_kbytes_sent
+= stats
.icp_r_kbytes_sent
;
71 icp_q_kbytes_recv
+= stats
.icp_q_kbytes_recv
;
72 icp_r_kbytes_recv
+= stats
.icp_r_kbytes_recv
;
73 icp_query_median_svc_time
+= stats
.icp_query_median_svc_time
;
74 icp_reply_median_svc_time
+= stats
.icp_reply_median_svc_time
;
75 dns_median_svc_time
+= stats
.dns_median_svc_time
;
76 unlink_requests
+= stats
.unlink_requests
;
77 page_faults
+= stats
.page_faults
;
78 select_loops
+= stats
.select_loops
;
79 select_fds
+= stats
.select_fds
;
80 average_select_fd_period
+= stats
.average_select_fd_period
;
81 median_select_fds
+= stats
.median_select_fds
;
82 swap_outs
+= stats
.swap_outs
;
83 swap_ins
+= stats
.swap_ins
;
84 swap_files_cleaned
+= stats
.swap_files_cleaned
;
85 aborted_requests
+= stats
.aborted_requests
;
86 syscalls_disk_opens
+= stats
.syscalls_disk_opens
;
87 syscalls_disk_closes
+= stats
.syscalls_disk_closes
;
88 syscalls_disk_reads
+= stats
.syscalls_disk_reads
;
89 syscalls_disk_writes
+= stats
.syscalls_disk_writes
;
90 syscalls_disk_seeks
+= stats
.syscalls_disk_seeks
;
91 syscalls_disk_unlinks
+= stats
.syscalls_disk_unlinks
;
92 syscalls_sock_accepts
+= stats
.syscalls_sock_accepts
;
93 syscalls_sock_sockets
+= stats
.syscalls_sock_sockets
;
94 syscalls_sock_connects
+= stats
.syscalls_sock_connects
;
95 syscalls_sock_binds
+= stats
.syscalls_sock_binds
;
96 syscalls_sock_closes
+= stats
.syscalls_sock_closes
;
97 syscalls_sock_reads
+= stats
.syscalls_sock_reads
;
98 syscalls_sock_writes
+= stats
.syscalls_sock_writes
;
99 syscalls_sock_recvfroms
+= stats
.syscalls_sock_recvfroms
;
100 syscalls_sock_sendtos
+= stats
.syscalls_sock_sendtos
;
101 syscalls_selects
+= stats
.syscalls_selects
;
102 cpu_time
+= stats
.cpu_time
;
103 wall_time
+= stats
.wall_time
;
109 Mgr::IntervalAction::Pointer
110 Mgr::IntervalAction::Create5min(const CommandPointer
&cmd
)
112 return new IntervalAction(cmd
, 5, 0);
115 Mgr::IntervalAction::Pointer
116 Mgr::IntervalAction::Create60min(const CommandPointer
&cmd
)
118 return new IntervalAction(cmd
, 60, 0);
121 Mgr::IntervalAction::IntervalAction(const CommandPointer
&cmd
, int aMinutes
, int aHours
):
122 Action(cmd
), minutes(aMinutes
), hours(aHours
), data()
128 Mgr::IntervalAction::add(const Action
& action
)
131 data
+= dynamic_cast<const IntervalAction
&>(action
).data
;
135 Mgr::IntervalAction::collect()
137 GetAvgStat(data
, minutes
, hours
);
141 Mgr::IntervalAction::dump(StoreEntry
* entry
)
145 DumpAvgStat(data
, entry
);
149 Mgr::IntervalAction::pack(Ipc::TypedMsgHdr
& msg
) const
151 msg
.setType(Ipc::mtCacheMgrResponse
);
156 Mgr::IntervalAction::unpack(const Ipc::TypedMsgHdr
& msg
)
158 msg
.checkType(Ipc::mtCacheMgrResponse
);