]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/ServiceTimesAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / ServiceTimesAction.cc
CommitLineData
8822ebee 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
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.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
f7f3304a 11#include "squid.h"
8822ebee
AR
12#include "base/TextException.h"
13#include "ipc/Messages.h"
14#include "ipc/TypedMsgHdr.h"
15#include "mgr/ServiceTimesAction.h"
16#include "Store.h"
5bed43d6 17#include "tools.h"
8822ebee 18
82afb125
FC
19void GetServiceTimesStats(Mgr::ServiceTimesActionData& stats);
20void DumpServiceTimesStats(Mgr::ServiceTimesActionData& stats, StoreEntry* sentry);
8822ebee
AR
21
22Mgr::ServiceTimesActionData::ServiceTimesActionData()
23{
e297be13 24 memset(this, 0, sizeof(*this));
8822ebee
AR
25}
26
27Mgr::ServiceTimesActionData&
28Mgr::ServiceTimesActionData::operator += (const ServiceTimesActionData& stats)
29{
30 for (int i = 0; i < seriesSize; ++i) {
31 http_requests5[i] += stats.http_requests5[i];
32 http_requests60[i] += stats.http_requests60[i];
33
34 cache_misses5[i] += stats.cache_misses5[i];
35 cache_misses60[i] += stats.cache_misses60[i];
36
37 cache_hits5[i] += stats.cache_hits5[i];
38 cache_hits60[i] += stats.cache_hits60[i];
39
40 near_hits5[i] += stats.near_hits5[i];
41 near_hits60[i] += stats.near_hits60[i];
42
43 not_modified_replies5[i] += stats.not_modified_replies5[i];
44 not_modified_replies60[i] += stats.not_modified_replies60[i];
45
46 dns_lookups5[i] += stats.dns_lookups5[i];
47 dns_lookups60[i] += stats.dns_lookups60[i];
48
49 icp_queries5[i] += stats.icp_queries5[i];
50 icp_queries60[i] += stats.icp_queries60[i];
51 }
52 ++count;
53
54 return *this;
55}
56
57Mgr::ServiceTimesAction::Pointer
58Mgr::ServiceTimesAction::Create(const CommandPointer &cmd)
59{
60 return new ServiceTimesAction(cmd);
61}
62
9dca980d 63Mgr::ServiceTimesAction::ServiceTimesAction(const CommandPointer &aCmd):
f53969cc 64 Action(aCmd), data()
8822ebee
AR
65{
66 debugs(16, 5, HERE);
67}
68
69void
70Mgr::ServiceTimesAction::add(const Action& action)
71{
72 debugs(16, 5, HERE);
73 data += dynamic_cast<const ServiceTimesAction&>(action).data;
74}
75
76void
77Mgr::ServiceTimesAction::collect()
78{
79 debugs(16, 5, HERE);
80 GetServiceTimesStats(data);
81}
82
83void
84Mgr::ServiceTimesAction::dump(StoreEntry* entry)
85{
86 debugs(16, 5, HERE);
87 Must(entry != NULL);
88 DumpServiceTimesStats(data, entry);
89}
90
91void
92Mgr::ServiceTimesAction::pack(Ipc::TypedMsgHdr& msg) const
93{
94 msg.setType(Ipc::mtCacheMgrResponse);
95 msg.putPod(data);
96}
97
98void
99Mgr::ServiceTimesAction::unpack(const Ipc::TypedMsgHdr& msg)
100{
101 msg.checkType(Ipc::mtCacheMgrResponse);
102 msg.getPod(data);
103}
f53969cc 104