2014-04-03 15:36:13 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2018-10-18 09:27:04 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
2014-04-03 15:36:13 +02: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 DBEVENTS_H
|
|
|
|
#define DBEVENTS_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "db_ido/dbobject.hpp"
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configobject.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/service.hpp"
|
2014-04-03 15:36:13 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
enum LogEntryType
|
|
|
|
{
|
2017-12-19 15:50:05 +01:00
|
|
|
LogEntryTypeRuntimeError = 1,
|
|
|
|
LogEntryTypeRuntimeWarning = 2,
|
|
|
|
LogEntryTypeVerificationError = 4,
|
|
|
|
LogEntryTypeVerificationWarning = 8,
|
|
|
|
LogEntryTypeConfigError = 16,
|
|
|
|
LogEntryTypeConfigWarning = 32,
|
|
|
|
LogEntryTypeProcessInfo = 64,
|
|
|
|
LogEntryTypeEventHandler = 128,
|
|
|
|
LogEntryTypeExternalCommand = 512,
|
|
|
|
LogEntryTypeHostUp = 1024,
|
|
|
|
LogEntryTypeHostDown = 2048,
|
|
|
|
LogEntryTypeHostUnreachable = 4096,
|
|
|
|
LogEntryTypeServiceOk = 8192,
|
|
|
|
LogEntryTypeServiceUnknown = 16384,
|
|
|
|
LogEntryTypeServiceWarning = 32768,
|
|
|
|
LogEntryTypeServiceCritical = 65536,
|
|
|
|
LogEntryTypePassiveCheck = 1231072,
|
|
|
|
LogEntryTypeInfoMessage = 262144,
|
|
|
|
LogEntryTypeHostNotification = 524288,
|
|
|
|
LogEntryTypeServiceNotification = 1048576
|
2014-04-03 15:36:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IDO events
|
|
|
|
*
|
|
|
|
* @ingroup ido
|
|
|
|
*/
|
|
|
|
class DbEvents
|
|
|
|
{
|
|
|
|
public:
|
2018-01-04 04:25:35 +01:00
|
|
|
static void StaticInitialize();
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
static void AddComments(const Checkable::Ptr& checkable);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
static void AddDowntimes(const Checkable::Ptr& checkable);
|
|
|
|
static void RemoveDowntimes(const Checkable::Ptr& checkable);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2018-01-04 08:54:18 +01:00
|
|
|
static void AddLogHistory(const Checkable::Ptr& checkable, const String& buffer, LogEntryType type);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* Status */
|
2016-01-22 18:42:15 +01:00
|
|
|
static void NextCheckUpdatedHandler(const Checkable::Ptr& checkable);
|
2015-08-04 14:47:44 +02:00
|
|
|
static void FlappingChangedHandler(const Checkable::Ptr& checkable);
|
2014-05-03 00:16:53 +02:00
|
|
|
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
2014-05-02 23:38:37 +02:00
|
|
|
|
2015-08-04 14:47:44 +02:00
|
|
|
static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable);
|
|
|
|
static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable);
|
|
|
|
static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable);
|
|
|
|
static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable);
|
|
|
|
static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
|
2014-05-10 16:52:48 +02:00
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
static void AddComment(const Comment::Ptr& comment);
|
|
|
|
static void RemoveComment(const Comment::Ptr& comment);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2015-12-14 11:36:03 +01:00
|
|
|
static void AddDowntime(const Downtime::Ptr& downtime);
|
2015-08-20 17:18:48 +02:00
|
|
|
static void RemoveDowntime(const Downtime::Ptr& downtime);
|
|
|
|
static void TriggerDowntime(const Downtime::Ptr& downtime);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-05-02 23:17:36 +02:00
|
|
|
static void AddAcknowledgement(const Checkable::Ptr& checkable, AcknowledgementType type);
|
|
|
|
static void RemoveAcknowledgement(const Checkable::Ptr& checkable);
|
|
|
|
static void AddAcknowledgementInternal(const Checkable::Ptr& checkable, AcknowledgementType type, bool add);
|
|
|
|
|
2014-12-12 15:53:10 +01:00
|
|
|
static void ReachabilityChangedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, std::set<Checkable::Ptr> children);
|
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* comment, downtime, acknowledgement history */
|
2015-08-20 17:18:48 +02:00
|
|
|
static void AddCommentHistory(const Comment::Ptr& comment);
|
|
|
|
static void AddDowntimeHistory(const Downtime::Ptr& downtime);
|
2014-08-17 17:57:20 +02:00
|
|
|
static void AddAcknowledgementHistory(const Checkable::Ptr& checkable, const String& author, const String& comment,
|
2017-12-19 15:50:05 +01:00
|
|
|
AcknowledgementType type, bool notify, double expiry);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* notification & contactnotification history */
|
2014-04-03 15:36:13 +02:00
|
|
|
static void AddNotificationHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
2017-12-19 15:50:05 +01:00
|
|
|
const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author,
|
|
|
|
const String& text);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* statehistory */
|
2014-04-03 15:36:13 +02:00
|
|
|
static void AddStateChangeHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* logentries */
|
2014-04-03 15:36:13 +02:00
|
|
|
static void AddCheckResultLogHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
2015-08-20 17:18:48 +02:00
|
|
|
static void AddTriggerDowntimeLogHistory(const Downtime::Ptr& downtime);
|
|
|
|
static void AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime);
|
2014-04-03 15:36:13 +02:00
|
|
|
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
2017-12-19 15:50:05 +01:00
|
|
|
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
|
|
|
|
const String& comment_text);
|
2015-08-04 14:47:44 +02:00
|
|
|
|
|
|
|
static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
|
|
|
static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
/* other history */
|
2015-08-04 14:47:44 +02:00
|
|
|
static void AddFlappingChangedHistory(const Checkable::Ptr& checkable);
|
|
|
|
static void AddEnableFlappingChangedHistory(const Checkable::Ptr& checkable);
|
2015-04-24 17:41:07 +02:00
|
|
|
static void AddCheckableCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
|
2014-08-17 17:57:20 +02:00
|
|
|
static void AddEventHandlerHistory(const Checkable::Ptr& checkable);
|
|
|
|
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
2014-04-03 15:36:13 +02:00
|
|
|
|
|
|
|
private:
|
2018-01-04 04:25:35 +01:00
|
|
|
DbEvents();
|
2014-04-03 15:36:13 +02:00
|
|
|
|
2015-12-14 11:36:03 +01:00
|
|
|
static void AddCommentInternal(std::vector<DbQuery>& queries, const Comment::Ptr& comment, bool historical);
|
|
|
|
static void RemoveCommentInternal(std::vector<DbQuery>& queries, const Comment::Ptr& comment);
|
|
|
|
static void AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime, bool historical);
|
|
|
|
static void RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime);
|
2015-08-04 14:47:44 +02:00
|
|
|
static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled);
|
2017-12-06 16:18:26 +01:00
|
|
|
|
2017-12-21 09:12:12 +01:00
|
|
|
static int GetHostState(const Host::Ptr& host);
|
2017-12-21 09:24:04 +01:00
|
|
|
static String GetHostStateString(const Host::Ptr& host);
|
2017-12-06 16:18:26 +01:00
|
|
|
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
2017-12-06 16:39:22 +01:00
|
|
|
static int MapNotificationReasonType(NotificationType type);
|
|
|
|
static int MapExternalCommandType(const String& name);
|
2014-04-03 15:36:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DBEVENTS_H */
|