2013-11-09 22:08:26 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2018-10-18 09:27:04 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
2013-11-09 22:08:26 +01:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DOWNTIME_H
|
|
|
|
#define DOWNTIME_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/i2-icinga.hpp"
|
2018-01-18 13:50:38 +01:00
|
|
|
#include "icinga/downtime-ti.hpp"
|
|
|
|
#include "icinga/checkable-ti.hpp"
|
2015-08-20 17:18:48 +02:00
|
|
|
#include "remote/messageorigin.hpp"
|
2013-11-09 22:08:26 +01:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2018-08-08 14:42:18 +02:00
|
|
|
enum DowntimeChildOptions
|
|
|
|
{
|
|
|
|
DowntimeNoChildren,
|
|
|
|
DowntimeTriggeredChildren,
|
|
|
|
DowntimeNonTriggeredChildren
|
|
|
|
};
|
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
/**
|
2015-08-20 17:18:48 +02:00
|
|
|
* A downtime.
|
2013-11-09 22:08:26 +01:00
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class Downtime final : public ObjectImpl<Downtime>
|
2013-11-09 22:08:26 +01:00
|
|
|
{
|
|
|
|
public:
|
2014-11-03 00:44:04 +01:00
|
|
|
DECLARE_OBJECT(Downtime);
|
2015-08-20 17:18:48 +02:00
|
|
|
DECLARE_OBJECTNAME(Downtime);
|
|
|
|
|
|
|
|
static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeAdded;
|
|
|
|
static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeRemoved;
|
2016-11-11 19:36:19 +01:00
|
|
|
static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeStarted;
|
2015-08-20 17:18:48 +02:00
|
|
|
static boost::signals2::signal<void (const Downtime::Ptr&)> OnDowntimeTriggered;
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
intrusive_ptr<Checkable> GetCheckable() const;
|
2013-11-09 22:16:53 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
bool IsInEffect() const;
|
|
|
|
bool IsTriggered() const;
|
|
|
|
bool IsExpired() const;
|
|
|
|
bool HasValidConfigOwner() const;
|
2013-11-09 22:16:53 +01:00
|
|
|
|
2018-08-08 14:42:18 +02:00
|
|
|
static void StaticInitialize();
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
static int GetNextDowntimeID();
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
static String AddDowntime(const intrusive_ptr<Checkable>& checkable, const String& author,
|
2017-12-19 15:50:05 +01:00
|
|
|
const String& comment, double startTime, double endTime, bool fixed,
|
|
|
|
const String& triggeredBy, double duration, const String& scheduledDowntime = String(),
|
|
|
|
const String& scheduledBy = String(), const String& id = String(),
|
|
|
|
const MessageOrigin::Ptr& origin = nullptr);
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2017-11-30 08:36:35 +01:00
|
|
|
static void RemoveDowntime(const String& id, bool cancelled, bool expired = false, const MessageOrigin::Ptr& origin = nullptr);
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
void TriggerDowntime();
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
static String GetDowntimeIDFromLegacyID(int id);
|
|
|
|
|
2018-08-08 14:42:18 +02:00
|
|
|
static DowntimeChildOptions ChildOptionsFromValue(const Value& options);
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
protected:
|
2018-01-04 05:12:56 +01:00
|
|
|
void OnAllConfigLoaded() override;
|
|
|
|
void Start(bool runtimeCreated) override;
|
|
|
|
void Stop(bool runtimeRemoved) override;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2018-01-11 07:08:09 +01:00
|
|
|
void ValidateStartTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
|
|
|
|
void ValidateEndTime(const Lazy<Timestamp>& lvalue, const ValidationUtils& utils) override;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
private:
|
2015-10-29 08:06:03 +01:00
|
|
|
ObjectImpl<Checkable>::Ptr m_Checkable;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
bool CanBeTriggered();
|
2016-11-11 19:36:19 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
static void DowntimesStartTimerHandler();
|
|
|
|
static void DowntimesExpireTimerHandler();
|
2013-11-09 22:08:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DOWNTIME_H */
|