InfoAction.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section 16 Cache Manager API */
10 
11 #include "squid.h"
12 #include "base/TextException.h"
13 #include "comm/Connection.h"
14 #include "globals.h"
15 #include "HttpReply.h"
16 #include "ipc/Messages.h"
17 #include "ipc/TypedMsgHdr.h"
18 #include "ipc/UdsOp.h"
19 #include "mgr/Filler.h"
20 #include "mgr/InfoAction.h"
21 #include "mgr/Request.h"
22 #include "mgr/Response.h"
23 #include "SquidTime.h"
24 #include "Store.h"
25 #include "tools.h"
26 
29 void DumpMallocStatistics(StoreEntry* sentry);
30 
32 {
33  memset(this, 0, sizeof(*this));
34 }
35 
38 {
39  if (!timerisset(&squid_start) || timercmp(&squid_start, &stats.squid_start, >))
40  squid_start = stats.squid_start;
41  if (timercmp(&current_time, &stats.current_time, <))
42  current_time = stats.current_time;
43  client_http_clients += stats.client_http_clients;
44  client_http_requests += stats.client_http_requests;
45  icp_pkts_recv += stats.icp_pkts_recv;
46  icp_pkts_sent += stats.icp_pkts_sent;
47  icp_replies_queued += stats.icp_replies_queued;
48 #if USE_HTCP
49  htcp_pkts_recv += stats.htcp_pkts_recv;
50  htcp_pkts_sent += stats.htcp_pkts_sent;
51 #endif
53  avg_client_http_requests += stats.avg_client_http_requests;
54  avg_icp_messages += stats.avg_icp_messages;
55  select_loops += stats.select_loops;
56  avg_loop_time += stats.avg_loop_time;
57  request_hit_ratio5 += stats.request_hit_ratio5;
58  request_hit_ratio60 += stats.request_hit_ratio60;
59  byte_hit_ratio5 += stats.byte_hit_ratio5;
60  byte_hit_ratio60 += stats.byte_hit_ratio60;
61  request_hit_mem_ratio5 += stats.request_hit_mem_ratio5;
62  request_hit_mem_ratio60 += stats.request_hit_mem_ratio60;
63  request_hit_disk_ratio5 += stats.request_hit_disk_ratio5;
64  request_hit_disk_ratio60 += stats.request_hit_disk_ratio60;
65 
66  store += stats.store;
67 
68  unlink_requests += stats.unlink_requests;
69  http_requests5 += stats.http_requests5;
70  http_requests60 += stats.http_requests60;
71  cache_misses5 += stats.cache_misses5;
72  cache_misses60 += stats.cache_misses60;
73  cache_hits5 += stats.cache_hits5;
74  cache_hits60 += stats.cache_hits60;
75  near_hits5 += stats.near_hits5;
76  near_hits60 += stats.near_hits60;
77  not_modified_replies5 += stats.not_modified_replies5;
78  not_modified_replies60 += stats.not_modified_replies60;
79  dns_lookups5 += stats.dns_lookups5;
80  dns_lookups60 += stats.dns_lookups60;
81  icp_queries5 += stats.icp_queries5;
82  icp_queries60 += stats.icp_queries60;
83  if (stats.up_time > up_time)
84  up_time = stats.up_time;
85  cpu_time += stats.cpu_time;
86  cpu_usage += stats.cpu_usage;
87  cpu_usage5 += stats.cpu_usage5;
88  cpu_usage60 += stats.cpu_usage60;
89  maxrss += stats.maxrss;
90  page_faults += stats.page_faults;
91 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
92  ms_bytes_total += stats.ms_bytes_total;
93  ms_bytes_free += stats.ms_bytes_free;
94 #endif
95  total_accounted += stats.total_accounted;
96  gb_saved_count += stats.gb_saved_count;
97  gb_freed_count += stats.gb_freed_count;
98  max_fd += stats.max_fd;
99  biggest_fd = max(biggest_fd, stats.biggest_fd);
100  number_fd += stats.number_fd;
101  opening_fd += stats.opening_fd;
102  num_fd_free += stats.num_fd_free;
103  reserved_fd += stats.reserved_fd;
104  ++count;
105 
106  return *this;
107 }
108 
111 {
112  return new InfoAction(cmd);
113 }
114 
116  Action(aCmd), data()
117 {
118  debugs(16, 5, HERE);
119 }
120 
121 void
123 {
124  debugs(16, 5, HERE);
125  data += dynamic_cast<const InfoAction&>(action).data;
126 }
127 
128 void
130 {
131  debugs(16, 5, HERE);
132  Ipc::ImportFdIntoComm(request.conn, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket);
133  Must(Comm::IsConnOpen(request.conn));
134  Must(request.requestId != 0);
135  AsyncJob::Start(new Mgr::Filler(this, request.conn, request.requestId));
136 }
137 
138 void
140 {
141  GetInfo(data);
142 }
143 
144 void
146 {
147  debugs(16, 5, HERE);
148  Must(entry != NULL);
149 
150 #if XMALLOC_STATISTICS
151  if (UsingSmp())
152  storeAppendPrintf(entry, "by kid%d {\n", KidIdentifier);
153  DumpMallocStatistics(entry);
154  if (UsingSmp())
155  storeAppendPrintf(entry, "} by kid%d\n\n", KidIdentifier);
156 #endif
157  if (IamPrimaryProcess())
158  DumpInfo(data, entry);
159 }
160 
161 void
163 {
165  msg.putPod(data);
166 }
167 
168 void
170 {
172  msg.getPod(data);
173 }
174 
#define timerisset(tvp)
Definition: snmp_api_util.h:85
cache manager request
Definition: Request.h:22
implement aggregated 'info' action
Definition: InfoAction.h:95
double request_failure_ratio
Definition: InfoAction.h:40
double total_accounted
Definition: InfoAction.h:82
virtual void respond(const Request &request)
respond to Coordinator request; default is to collect and sendResponse
Definition: InfoAction.cc:129
#define timercmp(tvp, uvp, cmp)
Definition: snmp_api_util.h:76
double not_modified_replies60
Definition: InfoAction.h:66
double byte_hit_ratio5
Definition: InfoAction.h:47
double icp_replies_queued
Definition: InfoAction.h:35
virtual void collect()
calculate and keep local action-specific information
Definition: InfoAction.cc:139
double request_hit_disk_ratio5
Definition: InfoAction.h:51
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:50
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
double request_hit_ratio5
Definition: InfoAction.h:45
double client_http_requests
Definition: InfoAction.h:32
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:52
class Ping::pingStats_ stats
static Pointer Create(const CommandPointer &cmd)
Definition: InfoAction.cc:110
virtual void pack(Ipc::TypedMsgHdr &msg) const
pack collected action info into a message to be sent to Coordinator
Definition: InfoAction.cc:162
struct timeval current_time
Definition: stub_time.cc:15
A const & max(A const &lhs, A const &rhs)
struct timeval current_time
Definition: InfoAction.h:30
double avg_icp_messages
Definition: InfoAction.h:42
bool IamPrimaryProcess()
Definition: tools.cc:670
static Pointer Start(AsyncJob *job)
starts a freshly created job (i.e., makes the job asynchronous)
Definition: AsyncJob.cc:23
double request_hit_ratio60
Definition: InfoAction.h:46
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:24
const Comm::ConnectionPointer & ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int protocol, FdNoteId noteId)
import socket fd from another strand into our Comm state
Definition: UdsOp.cc:194
void const char HLPCB void * data
Definition: stub_helper.cc:16
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
double request_hit_disk_ratio60
Definition: InfoAction.h:52
unsigned int requestId
unique for sender; matches request w/ response
Definition: Request.h:39
double client_http_clients
Definition: InfoAction.h:31
struct timeval squid_start
Definition: InfoAction.h:29
struct timeval squid_start
double request_hit_mem_ratio5
Definition: InfoAction.h:49
double request_hit_mem_ratio60
Definition: InfoAction.h:50
InfoActionData & operator+=(const InfoActionData &stats)
Definition: InfoAction.cc:37
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:658
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:147
bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:311
#define Must(cond)
Definition: TextException.h:89
Comm::ConnectionPointer conn
HTTP client connection descriptor.
Definition: Request.h:37
provides Coordinator with a local cache manager response
Definition: Filler.h:22
int KidIdentifier
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:31
void checkType(int aType) const
throws if stored type is not aType
Definition: TypedMsgHdr.cc:84
double request_failure_ratio
double avg_client_http_requests
Definition: InfoAction.h:41
double http_requests60
Definition: InfoAction.h:58
void DumpInfo(Mgr::InfoActionData &stats, StoreEntry *sentry)
Definition: stat.cc:585
InfoAction(const CommandPointer &cmd)
Definition: InfoAction.cc:115
virtual void dump(StoreEntry *entry)
Definition: InfoAction.cc:145
virtual void unpack(const Ipc::TypedMsgHdr &msg)
unpack action info from the message received by Coordinator
Definition: InfoAction.cc:169
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:90
void GetInfo(Mgr::InfoActionData &stats)
Definition: stat.cc:461
double unlink_requests
Definition: InfoAction.h:56
StoreInfoStats store
disk and memory cache statistics
Definition: InfoAction.h:54
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:904
double byte_hit_ratio60
Definition: InfoAction.h:48
virtual void add(const Action &action)
incrementally merge in remote information (of the same action type)
Definition: InfoAction.cc:122
#define NULL
Definition: types.h:166
double not_modified_replies5
Definition: InfoAction.h:65
void DumpMallocStatistics(StoreEntry *sentry)
Definition: stat.cc:795

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors