SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stats.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
24 #ifndef _SIPWITCH_STATS_H_
25 #define _SIPWITCH_STATS_H_
26 
27 #ifndef _UCOMMON_LINKED_H_
28 #include <ucommon/linked.h>
29 #endif
30 
31 #ifndef _UCOMMON_THREAD_H_
32 #include <ucommon/thread.h>
33 #endif
34 
35 #ifndef _UCOMMON_STRING_H_
36 #include <ucommon/string.h>
37 #endif
38 
39 #ifndef _SIPWITCH_NAMESPACE_H_
40 #include <sipwitch/namespace.h>
41 #endif
42 
43 namespace sipwitch {
44 
45 #define STAT_MAP "sipwitch.stats"
46 
57 class __EXPORT stats
58 {
59 public:
60  char id[12];
61 
62  typedef enum {INCOMING = 0, OUTGOING = 1} stat_t;
63 
67  struct
68  {
69  unsigned long total, period, pperiod;
70  unsigned short current, peak, min, max, pmin, pmax;
71  } data[2];
72 
73  time_t lastcall;
74  unsigned short limit;
75 
81  void assign(stat_t element);
82 
88  void release(stat_t element);
89 
94  unsigned active(void) const;
95 
102  static void period(FILE *file = NULL);
103 
109  static stats *create(void);
110 
116  static stats *request(const char *id);
117 
122  static void allocate(unsigned count);
123 
127  static void release(void);
128 };
129 
130 } // namespace sipwitch
131 
132 #endif
unsigned long total
Definition: stats.h:69
A stat element of call traffic.
Definition: stats.h:57
unsigned count
Definition: cgiserver.cpp:92
unsigned short limit
Definition: stats.h:74
unsigned short pmin
Definition: stats.h:70
time_t lastcall
Definition: stats.h:73
GNU SIP Witch library namespace.