icinga2/lib/db_ido/servicedbobject.h

121 lines
5.9 KiB
C
Raw Normal View History

/******************************************************************************
* Icinga 2 *
2013-09-25 07:43:57 +02:00
* Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
* *
* 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"
#include "base/dynamicobject.h"
#include "icinga/service.h"
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
};
/**
* 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);
static void StaticInitialize(void);
virtual Dictionary::Ptr GetConfigFields(void) const;
virtual Dictionary::Ptr GetStatusFields(void) const;
2013-07-24 10:55:04 +02:00
protected:
2013-07-24 10:55:04 +02:00
virtual bool IsStatusAttribute(const String& attribute) const;
virtual void OnConfigUpdate(void);
virtual void OnStatusUpdate(void);
private:
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);
static void AddComments(const Service::Ptr& service);
static void RemoveComments(const Service::Ptr& service);
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);
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 19:47:23 +02:00
/* Status */
static void AddComment(const Service::Ptr& service, const Comment::Ptr& comment);
static void RemoveComment(const Service::Ptr& service, const Comment::Ptr& comment);
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
/* History */
static void AddCommentHistory(const Service::Ptr& service, const Comment::Ptr& comment);
static void AddDowntimeHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
static void AddAcknowledgementHistory(const Service::Ptr& service, const String& author, const String& comment, AcknowledgementType type, double expiry);
static void AddContactNotificationHistory(const Service::Ptr& service, const User::Ptr& user);
static void AddNotificationHistory(const Service::Ptr& service, const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text);
static void AddStateChangeHistory(const Service::Ptr& service, const CheckResult::Ptr& cr, StateType type);
2013-09-24 11:49:02 +02:00
static void AddCheckResultLogHistory(const Service::Ptr& service, const CheckResult::Ptr &cr);
static void AddTriggerDowntimeLogHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
static void AddRemoveDowntimeLogHistory(const Service::Ptr& service, const Downtime::Ptr& downtime);
static void AddNotificationSentLogHistory(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);
static void AddFlappingHistory(const Service::Ptr& service, FlappingState flapping_state);
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);
static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
};
}
#endif /* SERVICEDBOBJECT_H */