From 56ae875861ab260b80a030f50c4aff9f9dc8fff0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:32:39 +0200 Subject: Adding upstream version 2.14.2. Signed-off-by: Daniel Baumann --- lib/icinga/cib.hpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 lib/icinga/cib.hpp (limited to 'lib/icinga/cib.hpp') diff --git a/lib/icinga/cib.hpp b/lib/icinga/cib.hpp new file mode 100644 index 0000000..00461e3 --- /dev/null +++ b/lib/icinga/cib.hpp @@ -0,0 +1,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 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 */ -- cgit v1.2.3