1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/downtime-ti.hpp"
8 #include "icinga/checkable-ti.hpp"
9 #include "remote/messageorigin.hpp"
14 enum DowntimeChildOptions
17 DowntimeTriggeredChildren,
18 DowntimeNonTriggeredChildren
26 class Downtime final : public ObjectImpl<Downtime>
29 DECLARE_OBJECT(Downtime);
30 DECLARE_OBJECTNAME(Downtime);
32 static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeAdded;
33 static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeRemoved;
34 static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeStarted;
35 static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeTriggered;
37 intrusive_ptr<Checkable> GetCheckable() const;
39 bool IsInEffect() const;
40 bool IsTriggered() const;
41 bool IsExpired() const;
42 bool HasValidConfigOwner() const;
44 static void StaticInitialize();
46 static int GetNextDowntimeID();
48 static String AddDowntime(const intrusive_ptr<Checkable>& checkable, const String& author,
49 const String& comment, double startTime, double endTime, bool fixed,
50 const String& triggeredBy, double duration, const String& scheduledDowntime = String(),
51 const String& scheduledBy = String(), const String& id = String(),
52 const MessageOrigin::Ptr& origin = nullptr);
54 static void RemoveDowntime(const String& id, bool cancelled, bool expired = false, const MessageOrigin::Ptr& origin = nullptr);
56 void TriggerDowntime();
58 static String GetDowntimeIDFromLegacyID(int id);
60 static DowntimeChildOptions ChildOptionsFromValue(const Value& options);
63 void OnAllConfigLoaded() override;
64 void Start(bool runtimeCreated) override;
65 void Stop(bool runtimeRemoved) override;
67 void ValidateStartTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
68 void ValidateEndTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
71 ObjectImpl<Checkable>::Ptr m_Checkable;
73 bool CanBeTriggered();
75 static void DowntimesStartTimerHandler();
76 static void DowntimesExpireTimerHandler();
81 #endif /* DOWNTIME_H */