InfoAction.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
33 {
34  if (!timerisset(&squid_start) || timercmp(&squid_start, &stats.squid_start, >))
35  squid_start = stats.squid_start;
36  if (timercmp(&current_time, &stats.current_time, <))
37  current_time = stats.current_time;
43 #if USE_HTCP
46 #endif
50  select_loops += stats.select_loops;
60 
61  store += stats.store;
62 
68  cache_hits5 += stats.cache_hits5;
69  cache_hits60 += stats.cache_hits60;
70  near_hits5 += stats.near_hits5;
71  near_hits60 += stats.near_hits60;
74  dns_lookups5 += stats.dns_lookups5;
76  icp_queries5 += stats.icp_queries5;
78  if (stats.up_time > up_time)
79  up_time = stats.up_time;
80  cpu_time += stats.cpu_time;
81  cpu_usage += stats.cpu_usage;
82  cpu_usage5 += stats.cpu_usage5;
83  cpu_usage60 += stats.cpu_usage60;
84  maxrss += stats.maxrss;
85  page_faults += stats.page_faults;
86 #if HAVE_MSTATS && HAVE_GNUMALLOC_H
87  ms_bytes_total += stats.ms_bytes_total;
88  ms_bytes_free += stats.ms_bytes_free;
89 #endif
93  max_fd += stats.max_fd;
95  number_fd += stats.number_fd;
96  opening_fd += stats.opening_fd;
97  num_fd_free += stats.num_fd_free;
98  reserved_fd += stats.reserved_fd;
99  ++count;
100 
101  return *this;
102 }
103 
106 {
107  return new InfoAction(cmd);
108 }
109 
111  Action(aCmd), data()
112 {
113  debugs(16, 5, HERE);
114 }
115 
116 void
118 {
119  debugs(16, 5, HERE);
120  data += dynamic_cast<const InfoAction&>(action).data;
121 }
122 
123 void
125 {
126  debugs(16, 5, HERE);
127  Ipc::ImportFdIntoComm(request.conn, SOCK_STREAM, IPPROTO_TCP, Ipc::fdnHttpSocket);
128  Must(Comm::IsConnOpen(request.conn));
129  Must(request.requestId != 0);
130  AsyncJob::Start(new Mgr::Filler(this, request.conn, request.requestId));
131 }
132 
133 void
135 {
136  GetInfo(data);
137 }
138 
139 void
141 {
142  debugs(16, 5, HERE);
143  Must(entry != NULL);
144 
145 #if XMALLOC_STATISTICS
146  if (UsingSmp())
147  storeAppendPrintf(entry, "by kid%d {\n", KidIdentifier);
148  DumpMallocStatistics(entry);
149  if (UsingSmp())
150  storeAppendPrintf(entry, "} by kid%d\n\n", KidIdentifier);
151 #endif
152  if (IamPrimaryProcess())
153  DumpInfo(data, entry);
154 }
155 
156 void
158 {
160  msg.putPod(data);
161 }
162 
163 void
165 {
167  msg.getPod(data);
168 }
169 
#define timerisset(tvp)
Definition: snmp_api_util.h:85
cache manager request
Definition: Request.h:22
implement aggregated &#39;info&#39; action
Definition: InfoAction.h:94
double request_failure_ratio
Definition: InfoAction.h:39
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:50
double total_accounted
Definition: InfoAction.h:81
virtual void respond(const Request &request)
respond to Coordinator request; default is to collect and sendResponse
Definition: InfoAction.cc:124
#define timercmp(tvp, uvp, cmp)
Definition: snmp_api_util.h:76
double not_modified_replies60
Definition: InfoAction.h:65
double byte_hit_ratio5
Definition: InfoAction.h:46
double icp_replies_queued
Definition: InfoAction.h:34
virtual void collect()
calculate and keep local action-specific information
Definition: InfoAction.cc:134
InfoActionData data
Definition: InfoAction.h:113
double request_hit_disk_ratio5
Definition: InfoAction.h:50
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
double request_hit_ratio5
Definition: InfoAction.h:44
double client_http_requests
Definition: InfoAction.h:31
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:52
class Ping::pingStats_ stats
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
static Pointer Create(const CommandPointer &cmd)
Definition: InfoAction.cc:105
A const & max(A const &lhs, A const &rhs)
struct timeval current_time
Definition: InfoAction.h:29
double avg_icp_messages
Definition: InfoAction.h:41
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:45
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:26
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:128
unsigned int count
Definition: InfoAction.h:90
double request_hit_disk_ratio60
Definition: InfoAction.h:51
unsigned int requestId
unique for sender; matches request w/ response
Definition: Request.h:39
double client_http_clients
Definition: InfoAction.h:30
struct timeval squid_start
Definition: InfoAction.h:28
double request_hit_mem_ratio5
Definition: InfoAction.h:48
double request_hit_mem_ratio60
Definition: InfoAction.h:49
InfoActionData & operator+=(const InfoActionData &stats)
Definition: InfoAction.cc:32
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:157
bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
Definition: purge.cc:311
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
double avg_client_http_requests
Definition: InfoAction.h:40
double http_requests60
Definition: InfoAction.h:57
void DumpInfo(Mgr::InfoActionData &stats, StoreEntry *sentry)
Definition: stat.cc:581
InfoAction(const CommandPointer &cmd)
Definition: InfoAction.cc:110
virtual void dump(StoreEntry *entry)
Definition: InfoAction.cc:140
virtual void unpack(const Ipc::TypedMsgHdr &msg)
unpack action info from the message received by Coordinator
Definition: InfoAction.cc:164
virtual void pack(Ipc::TypedMsgHdr &msg) const
pack collected action info into a message to be sent to Coordinator
Definition: InfoAction.cc:157
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:107
void GetInfo(Mgr::InfoActionData &stats)
Definition: stat.cc:457
void checkType(int aType) const
throws if stored type is not aType
Definition: TypedMsgHdr.cc:101
double unlink_requests
Definition: InfoAction.h:55
StoreInfoStats store
disk and memory cache statistics
Definition: InfoAction.h:53
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:881
double byte_hit_ratio60
Definition: InfoAction.h:47
virtual void add(const Action &action)
incrementally merge in remote information (of the same action type)
Definition: InfoAction.cc:117
#define NULL
Definition: types.h:166
double not_modified_replies5
Definition: InfoAction.h:64
void DumpMallocStatistics(StoreEntry *sentry)
Definition: stat.cc:791

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors