blob: 00461e31fe48482074caa9eec09c836cdbbb83db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#ifndef CIB_H
#define CIB_H
#include "icinga/i2-icinga.hpp"
#include "base/ringbuffer.hpp"
#include "base/dictionary.hpp"
#include "base/array.hpp"
namespace icinga
{
struct CheckableCheckStatistics {
double min_latency;
double max_latency;
double avg_latency;
double min_execution_time;
double max_execution_time;
double avg_execution_time;
};
struct ServiceStatistics {
double services_ok;
double services_warning;
double services_critical;
double services_unknown;
double services_pending;
double services_unreachable;
double services_flapping;
double services_in_downtime;
double services_acknowledged;
double services_handled;
double services_problem;
};
struct HostStatistics {
double hosts_up;
double hosts_down;
double hosts_unreachable;
double hosts_pending;
double hosts_flapping;
double hosts_in_downtime;
double hosts_acknowledged;
double hosts_handled;
double hosts_problem;
};
/**
* Common Information Base class. Holds some statistics (and will likely be
* removed/refactored).
*
* @ingroup icinga
*/
class CIB
{
public:
static void UpdateActiveHostChecksStatistics(long tv, int num);
static int GetActiveHostChecksStatistics(long timespan);
static void UpdateActiveServiceChecksStatistics(long tv, int num);
static int GetActiveServiceChecksStatistics(long timespan);
static void UpdatePassiveHostChecksStatistics(long tv, int num);
static int GetPassiveHostChecksStatistics(long timespan);
static void UpdatePassiveServiceChecksStatistics(long tv, int num);
static int GetPassiveServiceChecksStatistics(long timespan);
static CheckableCheckStatistics CalculateHostCheckStats();
static CheckableCheckStatistics CalculateServiceCheckStats();
static HostStatistics CalculateHostStats();
static ServiceStatistics CalculateServiceStats();
static std::pair<Dictionary::Ptr, Array::Ptr> GetFeatureStats();
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
private:
CIB();
static std::mutex m_Mutex;
static RingBuffer m_ActiveHostChecksStatistics;
static RingBuffer m_PassiveHostChecksStatistics;
static RingBuffer m_ActiveServiceChecksStatistics;
static RingBuffer m_PassiveServiceChecksStatistics;
};
}
#endif /* CIB_H */
|