reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
StatisticsMessage.cxx
Go to the documentation of this file.
2#include "rutil/Lock.hxx"
3#include "rutil/Logger.hxx"
5
6#include <string.h>
7
8using namespace resip;
9
10#define RESIPROCATE_SUBSYSTEM Subsystem::STATS
11
16
18 : ApplicationMessage(rhs),
19 mPayload(rhs.mPayload)
20{}
21
24
26StatisticsMessage::encodeBrief(EncodeStream& str) const
27{
28 return str << "StatisticsMessage";
29}
30
32StatisticsMessage::encode(EncodeStream& strm) const
33{
34 strm << "StatisticsMessage";
35/*
36 strm << " [";
37 Payload payload;
38 mPayload.loadOut(payload);
39 strm << payload << "]";
40*/
41 return strm;
42}
43
44unsigned int
46{
47 unsigned int ret = 0;
48 for (int code = 200; code < 300; ++code)
49 {
50 ret += responsesReceivedByMethodByCode[method][code];
51 }
52
53 return ret;
54}
55
56unsigned int
58{
59 unsigned int ret = 0;
60 for (int code = 200; code < 300; ++code)
61 {
62 ret += responsesSentByMethodByCode[method][code];
63 }
64
65 return ret;
66}
67
68unsigned int
70{
71 unsigned int ret = 0;
72 for (int code = 300; code < MaxCode; ++code)
73 {
74 ret += responsesReceivedByMethodByCode[method][code];
75 }
76
77 return ret;
78}
79
80unsigned int
82{
83 unsigned int ret = 0;
84 for (int code = 300; code < MaxCode; ++code)
85 {
86 ret += responsesSentByMethodByCode[method][code];
87 }
88
89 return ret;
90}
91
92void
94 const StatisticsMessage::Payload& stats)
95{
96 InfoLog(<< subsystem
97 << std::endl
98 << stats);
99}
100
101
102Message*
104{
105 return new StatisticsMessage(*this);
106}
107
109{
110 zeroOut();
111}
112
113void
115{
116 tuFifoSize = 0;
117 transportFifoSizeSum = 0;
118 transactionFifoSize = 0;
119 activeTimers = 0;
120 openTcpConnections = 0;
121 activeClientTransactions = 0;
122 activeServerTransactions = 0;
123 pendingDnsQueries = 0;
124 requestsSent = 0;
125 responsesSent = 0;
126 requestsRetransmitted = 0;
127 responsesRetransmitted = 0;
128 requestsReceived = 0;
129 responsesReceived = 0;
130 memset(responsesByCode, 0, sizeof(responsesByCode));
131 memset(requestsSentByMethod, 0, sizeof(requestsSentByMethod));
132 memset(requestsRetransmittedByMethod, 0, sizeof(requestsRetransmittedByMethod));
133 memset(requestsReceivedByMethod, 0, sizeof(requestsReceivedByMethod));
134 memset(responsesSentByMethod, 0, sizeof(responsesSentByMethod));
135 memset(responsesRetransmittedByMethod, 0, sizeof(responsesRetransmittedByMethod));
136 memset(responsesReceivedByMethod, 0, sizeof(responsesReceivedByMethod));
137 memset(responsesSentByMethodByCode, 0, sizeof(responsesSentByMethodByCode));
138 memset(responsesRetransmittedByMethodByCode, 0, sizeof(responsesRetransmittedByMethodByCode));
139 memset(responsesReceivedByMethodByCode, 0, sizeof(responsesReceivedByMethodByCode));
140}
141
144{
145 if (&rhs != this)
146 {
147 transportFifoSizeSum = rhs.transportFifoSizeSum;
148 tuFifoSize = rhs.tuFifoSize;
149 activeTimers = rhs.activeTimers;
150 transactionFifoSize = rhs.transactionFifoSize;
151
152 openTcpConnections = rhs.openTcpConnections;
153 activeClientTransactions = rhs.activeClientTransactions;
154 activeServerTransactions = rhs.activeServerTransactions;
155 pendingDnsQueries = rhs.pendingDnsQueries;
156
157 requestsSent = rhs.requestsSent;
158 responsesSent = rhs.responsesSent;
159 requestsRetransmitted = rhs.requestsRetransmitted;
160 responsesRetransmitted = rhs.responsesRetransmitted;
161 requestsReceived = rhs.requestsReceived;
162 responsesReceived = rhs.responsesReceived;
163
164 memcpy(responsesByCode, rhs.responsesByCode, sizeof(responsesByCode));
165 memcpy(requestsSentByMethod, rhs.requestsSentByMethod, sizeof(requestsSentByMethod));
166 memcpy(requestsRetransmittedByMethod, rhs.requestsRetransmittedByMethod, sizeof(requestsRetransmittedByMethod));
167 memcpy(requestsReceivedByMethod, rhs.requestsReceivedByMethod, sizeof(requestsReceivedByMethod));
168 memcpy(responsesSentByMethod, rhs.responsesSentByMethod, sizeof(responsesSentByMethod));
169 memcpy(responsesRetransmittedByMethod, rhs.responsesRetransmittedByMethod, sizeof(responsesRetransmittedByMethod));
170 memcpy(responsesReceivedByMethod, rhs.responsesReceivedByMethod, sizeof(responsesReceivedByMethod));
171 memcpy(responsesSentByMethodByCode, rhs.responsesSentByMethodByCode, sizeof(responsesSentByMethodByCode));
172 memcpy(responsesRetransmittedByMethodByCode, rhs.responsesRetransmittedByMethodByCode, sizeof(responsesRetransmittedByMethodByCode));
173 memcpy(responsesReceivedByMethodByCode, rhs.responsesReceivedByMethodByCode, sizeof(responsesReceivedByMethodByCode));
174 }
175
176 return *this;
177}
178
179void
181{
182 mPayload.loadOut(payload);
183}
184
187
188void
190{
191 Lock lock(mMutex);
192 Payload::operator=(payload);
193}
194
195void
197{
198 Lock lock(mMutex);
199 payload = (*this);
200}
201
203resip::operator<<(EncodeStream& strm, const StatisticsMessage::Payload& stats)
204{
205 unsigned int retriesFinal = 0;
206 for (int c = 200; c < 300; ++c)
207 {
208 retriesFinal += stats.responsesRetransmittedByMethodByCode[INVITE][c];
209 }
210
211 unsigned int retriesNonFinal = 0;
212 for (int c = 100; c < 200; ++c)
213 {
214 retriesNonFinal += stats.responsesRetransmittedByMethodByCode[INVITE][c];
215 }
216
217 strm << "TU summary: " << stats.tuFifoSize
218 << " TRANSPORT " << stats.transportFifoSizeSum
219 << " TRANSACTION " << stats.transactionFifoSize
220 << " CLIENTTX " << stats.activeClientTransactions
221 << " SERVERTX " << stats.activeServerTransactions
222 << " TIMERS " << stats.activeTimers
223 << std::endl
224 << "Transaction summary: reqi " << stats.requestsReceived
225 << " reqo " << stats.requestsSent
226 << " rspi " << stats.responsesReceived
227 << " rspo " << stats.responsesSent
228 << std::endl
229 << "Details: INVi " << stats.requestsReceivedByMethod[INVITE] << "/S" << stats.sum2xxOut(INVITE) << "/F" << stats.sumErrOut(INVITE)
230 << " INVo " << stats.requestsSentByMethod[INVITE]-stats.requestsRetransmittedByMethod[INVITE] << "/S" << stats.sum2xxIn(INVITE) << "/F" << stats.sumErrIn(INVITE)
231 << " ACKi " << stats.requestsReceivedByMethod[ACK]
232 << " ACKo " << stats.requestsSentByMethod[ACK]-stats.requestsRetransmittedByMethod[ACK]
233 << " BYEi " << stats.requestsReceivedByMethod[BYE] << "/S" << stats.sum2xxOut(BYE) << "/F" << stats.sumErrOut(BYE)
234 << " BYEo " << stats.requestsSentByMethod[BYE]-stats.requestsRetransmittedByMethod[BYE] << "/S" << stats.sum2xxIn(BYE) << "/F" << stats.sumErrIn(BYE)
235 << " CANi " << stats.requestsReceivedByMethod[CANCEL] << "/S" << stats.sum2xxOut(BYE) << "/F" << stats.sumErrOut(BYE)
236 << " CANo " << stats.requestsSentByMethod[CANCEL]-stats.requestsRetransmittedByMethod[CANCEL] << "/S" << stats.sum2xxIn(CANCEL) << "/F" << stats.sumErrIn(CANCEL)
237 << " MSGi " << stats.requestsReceivedByMethod[MESSAGE] << "/S" << stats.sum2xxOut(MESSAGE) << "/F" << stats.sumErrOut(MESSAGE)
238 << " MSGo " << stats.requestsSentByMethod[MESSAGE]-stats.requestsRetransmittedByMethod[MESSAGE] << "/S" << stats.sum2xxIn(MESSAGE) << "/F" << stats.sumErrIn(MESSAGE)
239 << " OPTi " << stats.requestsReceivedByMethod[OPTIONS] << "/S" << stats.sum2xxOut(OPTIONS) << "/F" << stats.sumErrOut(OPTIONS)
240 << " OPTo " << stats.requestsSentByMethod[OPTIONS]-stats.requestsRetransmittedByMethod[OPTIONS] << "/S" << stats.sum2xxIn(OPTIONS) << "/F" << stats.sumErrIn(OPTIONS)
241 << " REGi " << stats.requestsReceivedByMethod[REGISTER] << "/S" << stats.sum2xxOut(REGISTER) << "/F" << stats.sumErrOut(REGISTER)
242 << " REGo " << stats.requestsSentByMethod[REGISTER]-stats.requestsRetransmittedByMethod[REGISTER] << "/S" << stats.sum2xxIn(REGISTER) << "/F" << stats.sumErrIn(REGISTER)
243 << " PUBi " << stats.requestsReceivedByMethod[PUBLISH] << "/S" << stats.sum2xxOut(PUBLISH) << "/F" << stats.sumErrOut(PUBLISH)
244 << " PUBo " << stats.requestsSentByMethod[PUBLISH] << "/S" << stats.sum2xxIn(PUBLISH) << "/F" << stats.sumErrIn(PUBLISH)
245 << " SUBi " << stats.requestsReceivedByMethod[SUBSCRIBE] << "/S" << stats.sum2xxOut(SUBSCRIBE) << "/F" << stats.sumErrOut(SUBSCRIBE)
246 << " SUBo " << stats.requestsSentByMethod[SUBSCRIBE] << "/S" << stats.sum2xxIn(SUBSCRIBE) << "/F" << stats.sumErrIn(SUBSCRIBE)
247 << " NOTi " << stats.requestsReceivedByMethod[NOTIFY] << "/S" << stats.sum2xxOut(NOTIFY) << "/F" << stats.sumErrOut(NOTIFY)
248 << " NOTo " << stats.requestsSentByMethod[NOTIFY] << "/S" << stats.sum2xxIn(NOTIFY) << "/F" << stats.sumErrIn(NOTIFY)
249 << " REFi " << stats.requestsReceivedByMethod[REFER] << "/S" << stats.sum2xxOut(REFER) << "/F" << stats.sumErrOut(REFER)
250 << " REFo " << stats.requestsSentByMethod[REFER] << "/S" << stats.sum2xxIn(REFER) << "/F" << stats.sumErrIn(REFER)
251 << " INFi " << stats.requestsReceivedByMethod[INFO] << "/S" << stats.sum2xxOut(INFO) << "/F" << stats.sumErrOut(INFO)
252 << " INFo " << stats.requestsSentByMethod[INFO] << "/S" << stats.sum2xxIn(INFO) << "/F" << stats.sumErrIn(INFO)
253 << " PRAi " << stats.requestsReceivedByMethod[PRACK] << "/S" << stats.sum2xxOut(PRACK) << "/F" << stats.sumErrOut(PRACK)
254 << " PRAo " << stats.requestsSentByMethod[PRACK] << "/S" << stats.sum2xxIn(PRACK) << "/F" << stats.sumErrIn(PRACK)
255 << " SERi " << stats.requestsReceivedByMethod[SERVICE] << "/S" << stats.sum2xxOut(SERVICE) << "/F" << stats.sumErrOut(SERVICE)
256 << " SERo " << stats.requestsSentByMethod[SERVICE] << "/S" << stats.sum2xxIn(SERVICE) << "/F" << stats.sumErrIn(SERVICE)
257 << " UPDi " << stats.requestsReceivedByMethod[UPDATE] << "/S" << stats.sum2xxOut(UPDATE) << "/F" << stats.sumErrOut(UPDATE)
258 << " UPDo " << stats.requestsSentByMethod[UPDATE] << "/S" << stats.sum2xxIn(UPDATE) << "/F" << stats.sumErrIn(UPDATE)
259 << std::endl
260 << "Retransmissions: INVx " << stats.requestsRetransmittedByMethod[INVITE]
261 << " finx " << retriesFinal
262 << " nonx " << retriesNonFinal
263 << " BYEx " << stats.requestsRetransmittedByMethod[BYE]
264 << " CANx " << stats.requestsRetransmittedByMethod[CANCEL]
265 << " MSGx " << stats.requestsRetransmittedByMethod[MESSAGE]
266 << " OPTx " << stats.requestsRetransmittedByMethod[OPTIONS]
267 << " REGx " << stats.requestsRetransmittedByMethod[REGISTER]
268 << " PUBx " << stats.requestsRetransmittedByMethod[PUBLISH]
269 << " SUBx " << stats.requestsRetransmittedByMethod[SUBSCRIBE]
270 << " NOTx " << stats.requestsRetransmittedByMethod[NOTIFY]
271 << " REFx " << stats.requestsRetransmittedByMethod[REFER]
272 << " INFx " << stats.requestsRetransmittedByMethod[INFO]
273 << " PRAx " << stats.requestsRetransmittedByMethod[PRACK]
274 << " SERx " << stats.requestsRetransmittedByMethod[SERVICE]
275 << " UPDx " << stats.requestsRetransmittedByMethod[UPDATE];
276 strm.flush();
277 return strm;
278}
279
280/* ====================================================================
281 * The Vovida Software License, Version 1.0
282 *
283 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
284 *
285 * Redistribution and use in source and binary forms, with or without
286 * modification, are permitted provided that the following conditions
287 * are met:
288 *
289 * 1. Redistributions of source code must retain the above copyright
290 * notice, this list of conditions and the following disclaimer.
291 *
292 * 2. Redistributions in binary form must reproduce the above copyright
293 * notice, this list of conditions and the following disclaimer in
294 * the documentation and/or other materials provided with the
295 * distribution.
296 *
297 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
298 * and "Vovida Open Communication Application Library (VOCAL)" must
299 * not be used to endorse or promote products derived from this
300 * software without prior written permission. For written
301 * permission, please contact vocal@vovida.org.
302 *
303 * 4. Products derived from this software may not be called "VOCAL", nor
304 * may "VOCAL" appear in their name, without prior written
305 * permission of Vovida Networks, Inc.
306 *
307 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
308 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
309 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
310 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
311 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
312 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
313 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
314 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
315 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
316 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
317 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
318 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
319 * DAMAGE.
320 *
321 * ====================================================================
322 *
323 * This software consists of voluntary contributions made by Vovida
324 * Networks, Inc. and many individuals on behalf of Vovida Networks,
325 * Inc. For more information on Vovida Networks, Inc., please see
326 * <http://www.vovida.org/>.
327 *
328 */
#define InfoLog(args_)
Definition Logger.hxx:131
A base-class for messages used by applications.
The base-class used for message-passing.
Definition Message.hxx:21
virtual EncodeStream & encodeBrief(EncodeStream &str) const
output a brief description to stream
void loadOut(Payload &payload) const
static void logStats(const Subsystem &subsystem, const Payload &stats)
virtual EncodeStream & encode(EncodeStream &strm) const
output the entire message to stream
StatisticsMessage(const AtomicPayload &payload)
Class used to specify what sub-system given sections of code belong to, for use by the logging system...
Definition Subsystem.hxx:34
dcm! – add UnusedChecking(_enum) below;
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
Definition Lock.hxx:28
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream
unsigned int responsesSentByMethod[MAX_METHODS]
unsigned int sum2xxOut(MethodTypes method) const
unsigned int responsesSentByMethodByCode[MAX_METHODS][MaxCode]
unsigned int requestsSentByMethod[MAX_METHODS]
unsigned int responsesRetransmittedByMethod[MAX_METHODS]
unsigned int sum2xxIn(MethodTypes method) const
unsigned int responsesReceivedByMethodByCode[MAX_METHODS][MaxCode]
unsigned int requestsRetransmittedByMethod[MAX_METHODS]
unsigned int responsesRetransmittedByMethodByCode[MAX_METHODS][MaxCode]
unsigned int sumErrIn(MethodTypes method) const
Payload & operator=(const Payload &payload)
unsigned int sumErrOut(MethodTypes method) const
unsigned int requestsReceivedByMethod[MAX_METHODS]
unsigned int responsesReceivedByMethod[MAX_METHODS]