2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-04-15 12:48:12 +02:00
|
|
|
|
2013-11-13 14:56:31 +01:00
|
|
|
#ifndef SCHEDULEDDOWNTIME_H
|
|
|
|
#define SCHEDULEDDOWNTIME_H
|
2013-04-15 12:48:12 +02:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
2018-01-18 13:50:38 +01:00
|
|
|
#include "icinga/scheduleddowntime-ti.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/checkable.hpp"
|
2018-12-06 12:41:49 +01:00
|
|
|
#include <atomic>
|
2013-04-15 12:48:12 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2014-05-11 17:14:35 +02:00
|
|
|
class ApplyRule;
|
2014-12-12 15:33:02 +01:00
|
|
|
struct ScriptFrame;
|
2014-11-16 16:20:39 +01:00
|
|
|
class Host;
|
|
|
|
class Service;
|
2014-05-11 17:14:35 +02:00
|
|
|
|
2013-04-15 12:48:12 +02:00
|
|
|
/**
|
2013-11-13 14:56:31 +01:00
|
|
|
* An Icinga scheduled downtime specification.
|
2013-04-15 12:48:12 +02:00
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class ScheduledDowntime final : public ObjectImpl<ScheduledDowntime>
|
2013-04-15 12:48:12 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-11-03 00:44:04 +01:00
|
|
|
DECLARE_OBJECT(ScheduledDowntime);
|
|
|
|
DECLARE_OBJECTNAME(ScheduledDowntime);
|
2013-11-13 14:56:31 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
Checkable::Ptr GetCheckable() const;
|
2013-11-13 14:56:31 +01:00
|
|
|
|
2014-11-16 16:20:39 +01:00
|
|
|
static void EvaluateApplyRules(const intrusive_ptr<Host>& host);
|
|
|
|
static void EvaluateApplyRules(const intrusive_ptr<Service>& service);
|
2018-12-06 12:41:49 +01:00
|
|
|
static bool AllConfigIsLoaded();
|
2014-11-16 16:20:39 +01:00
|
|
|
|
2018-01-11 07:08:09 +01:00
|
|
|
void ValidateRanges(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
|
2018-08-08 14:42:18 +02:00
|
|
|
void ValidateChildOptions(const Lazy<Value>& lvalue, const ValidationUtils& utils) override;
|
2020-10-05 15:12:42 +02:00
|
|
|
String HashDowntimeOptions();
|
2015-03-09 07:51:55 +01:00
|
|
|
|
2013-11-13 14:56:31 +01:00
|
|
|
protected:
|
2018-01-04 05:12:56 +01:00
|
|
|
void OnAllConfigLoaded() override;
|
|
|
|
void Start(bool runtimeCreated) override;
|
2013-04-15 12:48:12 +02:00
|
|
|
|
|
|
|
private:
|
2018-01-04 04:25:35 +01:00
|
|
|
static void TimerProc();
|
2013-11-13 14:56:31 +01:00
|
|
|
|
2018-10-18 18:42:21 +02:00
|
|
|
std::pair<double, double> FindRunningSegment(double minEnd = 0);
|
2018-01-04 04:25:35 +01:00
|
|
|
std::pair<double, double> FindNextSegment();
|
|
|
|
void CreateNextDowntime();
|
2021-07-02 10:37:29 +02:00
|
|
|
void RemoveObsoleteDowntimes();
|
2014-04-05 12:56:56 +02:00
|
|
|
|
2018-12-06 12:41:49 +01:00
|
|
|
static std::atomic<bool> m_AllConfigLoaded;
|
|
|
|
|
2022-10-27 16:15:35 +02:00
|
|
|
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);
|
2013-04-15 12:48:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-13 14:56:31 +01:00
|
|
|
#endif /* SCHEDULEDDOWNTIME_H */
|