From 0915b3ef56dfac3113cce55a59a5765dc94976be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:34:54 +0200 Subject: Adding upstream version 2.13.6. Signed-off-by: Daniel Baumann --- lib/icinga/scheduleddowntime.hpp | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lib/icinga/scheduleddowntime.hpp (limited to 'lib/icinga/scheduleddowntime.hpp') diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp new file mode 100644 index 0000000..e701236 --- /dev/null +++ b/lib/icinga/scheduleddowntime.hpp @@ -0,0 +1,60 @@ +/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ + +#ifndef SCHEDULEDDOWNTIME_H +#define SCHEDULEDDOWNTIME_H + +#include "icinga/i2-icinga.hpp" +#include "icinga/scheduleddowntime-ti.hpp" +#include "icinga/checkable.hpp" +#include + +namespace icinga +{ + +class ApplyRule; +struct ScriptFrame; +class Host; +class Service; + +/** + * An Icinga scheduled downtime specification. + * + * @ingroup icinga + */ +class ScheduledDowntime final : public ObjectImpl +{ +public: + DECLARE_OBJECT(ScheduledDowntime); + DECLARE_OBJECTNAME(ScheduledDowntime); + + Checkable::Ptr GetCheckable() const; + + static void EvaluateApplyRules(const intrusive_ptr& host); + static void EvaluateApplyRules(const intrusive_ptr& service); + static bool AllConfigIsLoaded(); + + void ValidateRanges(const Lazy& lvalue, const ValidationUtils& utils) override; + void ValidateChildOptions(const Lazy& lvalue, const ValidationUtils& utils) override; + String HashDowntimeOptions(); + +protected: + void OnAllConfigLoaded() override; + void Start(bool runtimeCreated) override; + +private: + static void TimerProc(); + + std::pair FindRunningSegment(double minEnd = 0); + std::pair FindNextSegment(); + void CreateNextDowntime(); + void RemoveObsoleteDowntimes(); + + static std::atomic m_AllConfigLoaded; + + static bool EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule, bool skipFilter); + static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule, bool skipFilter = false); +}; + +} + +#endif /* SCHEDULEDDOWNTIME_H */ -- cgit v1.2.3