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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors