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