2013-07-17 14:10:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2014-01-09 00:32:11 +01:00
|
|
|
* Copyright (C) 2012-present Icinga Development Team (http://www.icinga.org) *
|
2013-07-17 14:10:28 +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 SERVICEDBOBJECT_H
|
|
|
|
#define SERVICEDBOBJECT_H
|
|
|
|
|
2013-09-25 10:41:59 +02:00
|
|
|
#include "db_ido/dbobject.h"
|
2013-07-17 14:10:28 +02:00
|
|
|
#include "base/dynamicobject.h"
|
2013-08-07 15:39:09 +02:00
|
|
|
#include "icinga/service.h"
|
2013-07-17 14:10:28 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2013-09-25 19:47:23 +02:00
|
|
|
enum LogEntryType
|
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2013-07-17 14:10:28 +02:00
|
|
|
/**
|
|
|
|
* A Service database object.
|
|
|
|
*
|
|
|
|
* @ingroup ido
|
|
|
|
*/
|
|
|
|
class ServiceDbObject : public DbObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_PTR_TYPEDEFS(ServiceDbObject);
|
|
|
|
|
2013-08-01 13:20:30 +02:00
|
|
|
ServiceDbObject(const DbType::Ptr& type, const String& name1, const String& name2);
|
2013-07-17 14:10:28 +02:00
|
|
|
|
2013-08-07 15:39:09 +02:00
|
|
|
static void StaticInitialize(void);
|
|
|
|
|
2013-07-22 12:08:49 +02:00
|
|
|
virtual Dictionary::Ptr GetConfigFields(void) const;
|
|
|
|
virtual Dictionary::Ptr GetStatusFields(void) const;
|
2013-07-24 10:55:04 +02:00
|
|
|
|
2013-07-25 08:30:02 +02:00
|
|
|
protected:
|
2013-07-24 10:55:04 +02:00
|
|
|
virtual bool IsStatusAttribute(const String& attribute) const;
|
2013-07-25 08:30:02 +02:00
|
|
|
|
|
|
|
virtual void OnConfigUpdate(void);
|
|
|
|
virtual void OnStatusUpdate(void);
|
|
|
|
|
2013-08-09 15:30:28 +02:00
|
|
|
private:
|
2013-11-09 21:19:52 +01:00
|
|
|
static void AddCommentInternal(const Service::Ptr& service, const Comment::Ptr& comment, bool historical);
|
|
|
|
static void AddCommentByType(const DynamicObject::Ptr& object, const Comment::Ptr& comment, bool historical);
|
2013-09-25 16:59:08 +02:00
|
|
|
static void AddComments(const Service::Ptr& service);
|
|
|
|
static void RemoveComments(const Service::Ptr& service);
|
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
static void AddDowntimeInternal(const Service::Ptr& service, const Downtime::Ptr& downtime, bool historical);
|
|
|
|
static void AddDowntimeByType(const DynamicObject::Ptr& object, const Downtime::Ptr& downtime, bool historical);
|
2013-09-25 16:59:08 +02:00
|
|
|
static void AddDowntimes(const Service::Ptr& service);
|
|
|
|
static void RemoveDowntimes(const Service::Ptr& service);
|
|
|
|
|
2013-09-25 19:47:23 +02:00
|
|
|
static void AddLogHistory(const Service::Ptr& service, String buffer, LogEntryType type);
|
2013-09-25 16:59:08 +02:00
|
|
|
|
2013-09-25 19:47:23 +02:00
|
|
|
/* Status */
|
2013-11-09 21:19:52 +01:00
|
|
|
static void AddComment(const Service::Ptr& service, const Comment::Ptr& comment);
|
|
|
|
static void RemoveComment(const Service::Ptr& service, const Comment::Ptr& comment);
|
2013-08-09 15:30:28 +02:00
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
static void AddDowntime(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
|
|
|
static void RemoveDowntime(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
|
|
|
static void TriggerDowntime(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
2013-09-24 11:49:02 +02:00
|
|
|
|
2014-01-28 17:53:40 +01:00
|
|
|
/* comment, downtime, acknowledgement history */
|
2013-11-09 21:19:52 +01:00
|
|
|
static void AddCommentHistory(const Service::Ptr& service, const Comment::Ptr& comment);
|
2013-11-09 22:08:26 +01:00
|
|
|
static void AddDowntimeHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
2014-01-27 17:22:48 +01:00
|
|
|
static void AddAcknowledgementHistory(const Service::Ptr& service, const String& author, const String& comment,
|
|
|
|
AcknowledgementType type, double expiry);
|
2014-01-28 17:53:40 +01:00
|
|
|
|
|
|
|
/* notification & contactnotification history */
|
2014-01-27 17:22:48 +01:00
|
|
|
static void AddNotificationHistory(const Notification::Ptr& notification, const Service::Ptr& service,
|
|
|
|
const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author,
|
|
|
|
const String& text);
|
2014-01-28 17:53:40 +01:00
|
|
|
|
|
|
|
/* statehistory */
|
2013-11-09 14:22:38 +01:00
|
|
|
static void AddStateChangeHistory(const Service::Ptr& service, const CheckResult::Ptr& cr, StateType type);
|
2013-09-24 11:49:02 +02:00
|
|
|
|
2014-01-28 17:53:40 +01:00
|
|
|
/* logentries */
|
2013-11-09 14:22:38 +01:00
|
|
|
static void AddCheckResultLogHistory(const Service::Ptr& service, const CheckResult::Ptr &cr);
|
2013-11-09 22:08:26 +01:00
|
|
|
static void AddTriggerDowntimeLogHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
|
|
|
static void AddRemoveDowntimeLogHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
2014-01-27 17:22:48 +01:00
|
|
|
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Service::Ptr& service,
|
|
|
|
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
|
|
|
|
const String& comment_text);
|
2013-09-25 19:47:23 +02:00
|
|
|
static void AddFlappingLogHistory(const Service::Ptr& service, FlappingState flapping_state);
|
2013-09-30 17:36:14 +02:00
|
|
|
|
2014-01-28 17:53:40 +01:00
|
|
|
/* other history */
|
2013-09-30 17:36:14 +02:00
|
|
|
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
|
2013-11-09 14:22:38 +01:00
|
|
|
static void AddServiceCheckHistory(const Service::Ptr& service, const CheckResult::Ptr &cr);
|
2013-10-01 11:04:30 +02:00
|
|
|
static void AddEventHandlerHistory(const Service::Ptr& service);
|
2013-09-30 19:32:32 +02:00
|
|
|
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
|
2013-07-17 14:10:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SERVICEDBOBJECT_H */
|