mirror of https://github.com/Icinga/icinga2.git
commit
faf758eb26
|
@ -50,29 +50,35 @@ void DbEvents::StaticInitialize(void)
|
||||||
Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4));
|
Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4));
|
||||||
Checkable::OnAcknowledgementCleared.connect(boost::bind(&DbEvents::RemoveAcknowledgement, _1));
|
Checkable::OnAcknowledgementCleared.connect(boost::bind(&DbEvents::RemoveAcknowledgement, _1));
|
||||||
|
|
||||||
Checkable::OnNextCheckChanged.connect(bind(&DbEvents::NextCheckChangedHandler, _1, _2));
|
Checkable::OnNextCheckChanged.connect(boost::bind(&DbEvents::NextCheckChangedHandler, _1, _2));
|
||||||
Checkable::OnFlappingChanged.connect(bind(&DbEvents::FlappingChangedHandler, _1, _2));
|
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::FlappingChangedHandler, _1, _2));
|
||||||
Checkable::OnNotificationSentToAllUsers.connect(bind(&DbEvents::LastNotificationChangedHandler, _1, _2));
|
Checkable::OnNotificationSentToAllUsers.connect(boost::bind(&DbEvents::LastNotificationChangedHandler, _1, _2));
|
||||||
|
|
||||||
|
Checkable::OnEnableActiveChecksChanged.connect(boost::bind(&DbEvents::EnableActiveChecksChangedHandler, _1, _2));
|
||||||
|
Checkable::OnEnablePassiveChecksChanged.connect(boost::bind(&DbEvents::EnablePassiveChecksChangedHandler, _1, _2));
|
||||||
|
Checkable::OnEnableNotificationsChanged.connect(boost::bind(&DbEvents::EnableNotificationsChangedHandler, _1, _2));
|
||||||
|
Checkable::OnEnablePerfdataChanged.connect(boost::bind(&DbEvents::EnablePerfdataChangedHandler, _1, _2));
|
||||||
|
Checkable::OnEnableFlappingChanged.connect(boost::bind(&DbEvents::EnableFlappingChangedHandler, _1, _2));
|
||||||
|
|
||||||
/* History */
|
/* History */
|
||||||
Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddCommentHistory, _1, _2));
|
Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddCommentHistory, _1, _2));
|
||||||
Checkable::OnDowntimeAdded.connect(boost::bind(&DbEvents::AddDowntimeHistory, _1, _2));
|
Checkable::OnDowntimeAdded.connect(boost::bind(&DbEvents::AddDowntimeHistory, _1, _2));
|
||||||
Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgementHistory, _1, _2, _3, _4, _5));
|
Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgementHistory, _1, _2, _3, _4, _5));
|
||||||
|
|
||||||
Checkable::OnNotificationSentToAllUsers.connect(bind(&DbEvents::AddNotificationHistory, _1, _2, _3, _4, _5, _6, _7));
|
Checkable::OnNotificationSentToAllUsers.connect(boost::bind(&DbEvents::AddNotificationHistory, _1, _2, _3, _4, _5, _6, _7));
|
||||||
|
|
||||||
Checkable::OnStateChange.connect(boost::bind(&DbEvents::AddStateChangeHistory, _1, _2, _3));
|
Checkable::OnStateChange.connect(boost::bind(&DbEvents::AddStateChangeHistory, _1, _2, _3));
|
||||||
|
|
||||||
Checkable::OnNewCheckResult.connect(bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
|
Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
|
||||||
Checkable::OnNotificationSentToUser.connect(bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7));
|
Checkable::OnNotificationSentToUser.connect(boost::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7));
|
||||||
Checkable::OnFlappingChanged.connect(bind(&DbEvents::AddFlappingLogHistory, _1, _2));
|
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingLogHistory, _1, _2));
|
||||||
Checkable::OnDowntimeTriggered.connect(boost::bind(&DbEvents::AddTriggerDowntimeLogHistory, _1, _2));
|
Checkable::OnDowntimeTriggered.connect(boost::bind(&DbEvents::AddTriggerDowntimeLogHistory, _1, _2));
|
||||||
Checkable::OnDowntimeRemoved.connect(boost::bind(&DbEvents::AddRemoveDowntimeLogHistory, _1, _2));
|
Checkable::OnDowntimeRemoved.connect(boost::bind(&DbEvents::AddRemoveDowntimeLogHistory, _1, _2));
|
||||||
|
|
||||||
Checkable::OnFlappingChanged.connect(bind(&DbEvents::AddFlappingHistory, _1, _2));
|
Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::AddFlappingHistory, _1, _2));
|
||||||
Checkable::OnNewCheckResult.connect(bind(&DbEvents::AddServiceCheckHistory, _1, _2));
|
Checkable::OnNewCheckResult.connect(boost::bind(&DbEvents::AddServiceCheckHistory, _1, _2));
|
||||||
|
|
||||||
Checkable::OnEventCommandExecuted.connect(bind(&DbEvents::AddEventHandlerHistory, _1));
|
Checkable::OnEventCommandExecuted.connect(boost::bind(&DbEvents::AddEventHandlerHistory, _1));
|
||||||
|
|
||||||
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&DbEvents::AddExternalCommandHistory, _1, _2, _3));
|
ExternalCommandProcessor::OnNewExternalCommand.connect(boost::bind(&DbEvents::AddExternalCommandHistory, _1, _2, _3));
|
||||||
}
|
}
|
||||||
|
@ -175,6 +181,73 @@ void DbEvents::LastNotificationChangedHandler(const Notification::Ptr& notificat
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* enable changed events */
|
||||||
|
void DbEvents::EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled)
|
||||||
|
{
|
||||||
|
EnableChangedHandlerInternal(checkable, enabled, EnableActiveChecks);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbEvents::EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled)
|
||||||
|
{
|
||||||
|
EnableChangedHandlerInternal(checkable, enabled, EnablePassiveChecks);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbEvents::EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled)
|
||||||
|
{
|
||||||
|
EnableChangedHandlerInternal(checkable, enabled, EnableNotifications);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbEvents::EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled)
|
||||||
|
{
|
||||||
|
EnableChangedHandlerInternal(checkable, enabled, EnablePerfdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbEvents::EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled)
|
||||||
|
{
|
||||||
|
EnableChangedHandlerInternal(checkable, enabled, EnableFlapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DbEvents::EnableChangedHandlerInternal(const Checkable::Ptr& checkable, bool enabled, EnableType type)
|
||||||
|
{
|
||||||
|
Host::Ptr host;
|
||||||
|
Service::Ptr service;
|
||||||
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
|
DbQuery query1;
|
||||||
|
if (service)
|
||||||
|
query1.Table = "servicestatus";
|
||||||
|
else
|
||||||
|
query1.Table = "hoststatus";
|
||||||
|
|
||||||
|
query1.Type = DbQueryUpdate;
|
||||||
|
|
||||||
|
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
||||||
|
|
||||||
|
if (type == EnableActiveChecks) {
|
||||||
|
fields1->Set("active_checks_enabled", enabled ? 1 : 0);
|
||||||
|
} else if (type == EnablePassiveChecks) {
|
||||||
|
fields1->Set("passive_checks_enabled", enabled ? 1 : 0);
|
||||||
|
} else if (type == EnableNotifications) {
|
||||||
|
fields1->Set("notifications_enabled", enabled ? 1 : 0);
|
||||||
|
} else if (type == EnablePerfdata) {
|
||||||
|
fields1->Set("process_performance_data", enabled ? 1 : 0);
|
||||||
|
} else if (type == EnableFlapping) {
|
||||||
|
fields1->Set("flap_detection_enabled", enabled ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
query1.Fields = fields1;
|
||||||
|
|
||||||
|
query1.WhereCriteria = make_shared<Dictionary>();
|
||||||
|
if (service)
|
||||||
|
query1.WhereCriteria->Set("service_object_id", service);
|
||||||
|
else
|
||||||
|
query1.WhereCriteria->Set("host_object_id", host);
|
||||||
|
|
||||||
|
query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
|
DbObject::OnQuery(query1);
|
||||||
|
}
|
||||||
|
|
||||||
/* comments */
|
/* comments */
|
||||||
void DbEvents::AddComments(const Checkable::Ptr& checkable)
|
void DbEvents::AddComments(const Checkable::Ptr& checkable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,15 @@ enum LogEntryType
|
||||||
LogEntryTypeServiceNotification = 1048576
|
LogEntryTypeServiceNotification = 1048576
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EnableType
|
||||||
|
{
|
||||||
|
EnableActiveChecks = 1,
|
||||||
|
EnablePassiveChecks = 2,
|
||||||
|
EnableNotifications = 3,
|
||||||
|
EnablePerfdata = 4,
|
||||||
|
EnableFlapping = 5
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IDO events
|
* IDO events
|
||||||
*
|
*
|
||||||
|
@ -76,6 +85,12 @@ public:
|
||||||
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
static void FlappingChangedHandler(const Checkable::Ptr& checkable, FlappingState state);
|
||||||
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
|
static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled);
|
||||||
|
static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled);
|
||||||
|
static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled);
|
||||||
|
static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable, bool enabled);
|
||||||
|
static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled);
|
||||||
|
|
||||||
static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
||||||
static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
|
||||||
|
|
||||||
|
@ -121,6 +136,7 @@ private:
|
||||||
|
|
||||||
static void AddCommentInternal(const Checkable::Ptr& checkable, const Comment::Ptr& comment, bool historical);
|
static void AddCommentInternal(const Checkable::Ptr& checkable, const Comment::Ptr& comment, bool historical);
|
||||||
static void AddDowntimeInternal(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical);
|
static void AddDowntimeInternal(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool historical);
|
||||||
|
static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, bool enabled, EnableType type);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ using namespace icinga;
|
||||||
|
|
||||||
REGISTER_TYPE(Checkable);
|
REGISTER_TYPE(Checkable);
|
||||||
|
|
||||||
|
boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> Checkable::OnEnablePerfdataChanged;
|
||||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet;
|
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, double, const MessageOrigin&)> Checkable::OnAcknowledgementSet;
|
||||||
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> Checkable::OnAcknowledgementCleared;
|
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin&)> Checkable::OnAcknowledgementCleared;
|
||||||
|
|
||||||
|
@ -162,6 +163,8 @@ bool Checkable::GetEnablePerfdata(void) const
|
||||||
void Checkable::SetEnablePerfdata(bool enabled, const MessageOrigin& origin)
|
void Checkable::SetEnablePerfdata(bool enabled, const MessageOrigin& origin)
|
||||||
{
|
{
|
||||||
SetOverrideEnablePerfdata(enabled);
|
SetOverrideEnablePerfdata(enabled);
|
||||||
|
|
||||||
|
OnEnablePerfdataChanged(GetSelf(), enabled, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Checkable::GetModifiedAttributes(void) const
|
int Checkable::GetModifiedAttributes(void) const
|
||||||
|
@ -212,25 +215,35 @@ int Checkable::GetModifiedAttributes(void) const
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checkable::SetModifiedAttributes(int flags)
|
void Checkable::SetModifiedAttributes(int flags, const MessageOrigin& origin)
|
||||||
{
|
{
|
||||||
if ((flags & ModAttrNotificationsEnabled) == 0)
|
if ((flags & ModAttrNotificationsEnabled) == 0) {
|
||||||
SetOverrideEnableNotifications(Empty);
|
SetOverrideEnableNotifications(Empty);
|
||||||
|
OnEnableNotificationsChanged(GetSelf(), GetEnableNotifications(), origin);
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & ModAttrActiveChecksEnabled) == 0)
|
if ((flags & ModAttrActiveChecksEnabled) == 0) {
|
||||||
SetOverrideEnableActiveChecks(Empty);
|
SetOverrideEnableActiveChecks(Empty);
|
||||||
|
OnEnableActiveChecksChanged(GetSelf(), GetEnableActiveChecks(), origin);
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & ModAttrPassiveChecksEnabled) == 0)
|
if ((flags & ModAttrPassiveChecksEnabled) == 0) {
|
||||||
SetOverrideEnablePassiveChecks(Empty);
|
SetOverrideEnablePassiveChecks(Empty);
|
||||||
|
OnEnablePassiveChecksChanged(GetSelf(), GetEnablePassiveChecks(), origin);
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & ModAttrFlapDetectionEnabled) == 0)
|
if ((flags & ModAttrFlapDetectionEnabled) == 0) {
|
||||||
SetOverrideEnableFlapping(Empty);
|
SetOverrideEnableFlapping(Empty);
|
||||||
|
OnEnableFlappingChanged(GetSelf(), GetEnableFlapping(), origin);
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & ModAttrEventHandlerEnabled) == 0)
|
if ((flags & ModAttrEventHandlerEnabled) == 0)
|
||||||
SetOverrideEnableEventHandler(Empty);
|
SetOverrideEnableEventHandler(Empty);
|
||||||
|
|
||||||
if ((flags & ModAttrPerformanceDataEnabled) == 0)
|
if ((flags & ModAttrPerformanceDataEnabled) == 0) {
|
||||||
SetOverrideEnablePerfdata(Empty);
|
SetOverrideEnablePerfdata(Empty);
|
||||||
|
OnEnablePerfdataChanged(GetSelf(), GetEnablePerfdata(), origin);
|
||||||
|
}
|
||||||
|
|
||||||
if ((flags & ModAttrNormalCheckInterval) == 0)
|
if ((flags & ModAttrNormalCheckInterval) == 0)
|
||||||
SetOverrideCheckInterval(Empty);
|
SetOverrideCheckInterval(Empty);
|
||||||
|
|
|
@ -143,7 +143,7 @@ public:
|
||||||
void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin = MessageOrigin());
|
void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin& origin = MessageOrigin());
|
||||||
|
|
||||||
int GetModifiedAttributes(void) const;
|
int GetModifiedAttributes(void) const;
|
||||||
void SetModifiedAttributes(int flags);
|
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin());
|
||||||
|
|
||||||
bool IsCheckPending(void) const;
|
bool IsCheckPending(void) const;
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ public:
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePassiveChecksChanged;
|
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePassiveChecksChanged;
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged;
|
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableNotificationsChanged;
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableFlappingChanged;
|
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnableFlappingChanged;
|
||||||
|
static boost::signals2::signal<void (const Checkable::Ptr&, bool, const MessageOrigin&)> OnEnablePerfdataChanged;
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin&)> OnNewCheckResult;
|
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, const MessageOrigin&)> OnNewCheckResult;
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin&)> OnStateChange;
|
static boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin&)> OnStateChange;
|
||||||
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
|
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
|
||||||
|
|
|
@ -45,7 +45,7 @@ int Command::GetModifiedAttributes(void) const
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command::SetModifiedAttributes(int flags)
|
void Command::SetModifiedAttributes(int flags, const MessageOrigin& origin)
|
||||||
{
|
{
|
||||||
if ((flags & ModAttrCustomVariable) == 0) {
|
if ((flags & ModAttrCustomVariable) == 0) {
|
||||||
SetOverrideVars(Empty);
|
SetOverrideVars(Empty);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "base/i2-base.h"
|
#include "base/i2-base.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
|
#include "remote/messageorigin.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -45,7 +46,7 @@ public:
|
||||||
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
int GetModifiedAttributes(void) const;
|
int GetModifiedAttributes(void) const;
|
||||||
void SetModifiedAttributes(int flags);
|
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin());
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ int User::GetModifiedAttributes(void) const
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void User::SetModifiedAttributes(int flags)
|
void User::SetModifiedAttributes(int flags, const MessageOrigin& origin)
|
||||||
{
|
{
|
||||||
if ((flags & ModAttrCustomVariable) == 0) {
|
if ((flags & ModAttrCustomVariable) == 0) {
|
||||||
SetOverrideVars(Empty);
|
SetOverrideVars(Empty);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "icinga/macroresolver.h"
|
#include "icinga/macroresolver.h"
|
||||||
#include "icinga/timeperiod.h"
|
#include "icinga/timeperiod.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
|
#include "remote/messageorigin.h"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
@ -48,7 +49,7 @@ public:
|
||||||
static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
|
static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
|
||||||
|
|
||||||
int GetModifiedAttributes(void) const;
|
int GetModifiedAttributes(void) const;
|
||||||
void SetModifiedAttributes(int flags);
|
void SetModifiedAttributes(int flags, const MessageOrigin& origin = MessageOrigin());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
Loading…
Reference in New Issue