mirror of https://github.com/Icinga/icinga2.git
Implement cluster event for SetForceNextNotification.
This commit is contained in:
parent
911f64c411
commit
24b7aed259
|
@ -56,6 +56,7 @@ void ClusterComponent::Start(void)
|
||||||
Service::OnNextCheckChanged.connect(bind(&ClusterComponent::NextCheckChangedHandler, this, _1, _2, _3));
|
Service::OnNextCheckChanged.connect(bind(&ClusterComponent::NextCheckChangedHandler, this, _1, _2, _3));
|
||||||
Notification::OnNextNotificationChanged.connect(bind(&ClusterComponent::NextNotificationChangedHandler, this, _1, _2, _3));
|
Notification::OnNextNotificationChanged.connect(bind(&ClusterComponent::NextNotificationChangedHandler, this, _1, _2, _3));
|
||||||
Service::OnForceNextCheckChanged.connect(bind(&ClusterComponent::ForceNextCheckChangedHandler, this, _1, _2, _3));
|
Service::OnForceNextCheckChanged.connect(bind(&ClusterComponent::ForceNextCheckChangedHandler, this, _1, _2, _3));
|
||||||
|
Service::OnForceNextNotificationChanged.connect(bind(&ClusterComponent::ForceNextNotificationChangedHandler, this, _1, _2, _3));
|
||||||
Service::OnEnableActiveChecksChanged.connect(bind(&ClusterComponent::EnableActiveChecksChangedHandler, this, _1, _2, _3));
|
Service::OnEnableActiveChecksChanged.connect(bind(&ClusterComponent::EnableActiveChecksChangedHandler, this, _1, _2, _3));
|
||||||
Service::OnEnablePassiveChecksChanged.connect(bind(&ClusterComponent::EnablePassiveChecksChangedHandler, this, _1, _2, _3));
|
Service::OnEnablePassiveChecksChanged.connect(bind(&ClusterComponent::EnablePassiveChecksChangedHandler, this, _1, _2, _3));
|
||||||
Service::OnCommentAdded.connect(bind(&ClusterComponent::CommentAddedHandler, this, _1, _2, _3));
|
Service::OnCommentAdded.connect(bind(&ClusterComponent::CommentAddedHandler, this, _1, _2, _3));
|
||||||
|
@ -330,6 +331,25 @@ void ClusterComponent::ForceNextCheckChangedHandler(const Service::Ptr& service,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClusterComponent::ForceNextNotificationChangedHandler(const Service::Ptr& service, bool forced, const String& authority)
|
||||||
|
{
|
||||||
|
if (!authority.IsEmpty() && authority != GetIdentity())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dictionary::Ptr params = boost::make_shared<Dictionary>();
|
||||||
|
params->Set("service", service->GetName());
|
||||||
|
params->Set("forced", forced);
|
||||||
|
|
||||||
|
Dictionary::Ptr message = boost::make_shared<Dictionary>();
|
||||||
|
message->Set("jsonrpc", "2.0");
|
||||||
|
message->Set("method", "cluster::SetForceNextNotification");
|
||||||
|
message->Set("params", params);
|
||||||
|
|
||||||
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
||||||
|
endpoint->SendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ClusterComponent::EnableActiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority)
|
void ClusterComponent::EnableActiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority)
|
||||||
{
|
{
|
||||||
if (!authority.IsEmpty() && authority != GetIdentity())
|
if (!authority.IsEmpty() && authority != GetIdentity())
|
||||||
|
@ -492,6 +512,17 @@ void ClusterComponent::MessageHandler(const Endpoint::Ptr& sender, const Diction
|
||||||
bool forced = params->Get("forced");
|
bool forced = params->Get("forced");
|
||||||
|
|
||||||
service->SetForceNextCheck(forced, sender->GetName());
|
service->SetForceNextCheck(forced, sender->GetName());
|
||||||
|
} else if (message->Get("method") == "cluster::SetForceNextNotification") {
|
||||||
|
String svc = params->Get("service");
|
||||||
|
|
||||||
|
Service::Ptr service = Service::GetByName(svc);
|
||||||
|
|
||||||
|
if (!service)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool forced = params->Get("forced");
|
||||||
|
|
||||||
|
service->SetForceNextNotification(forced, sender->GetName());
|
||||||
} else if (message->Get("method") == "cluster::SetEnableActiveChecks") {
|
} else if (message->Get("method") == "cluster::SetEnableActiveChecks") {
|
||||||
String svc = params->Get("service");
|
String svc = params->Get("service");
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
void NextCheckChangedHandler(const Service::Ptr& service, double nextCheck, const String& authority);
|
void NextCheckChangedHandler(const Service::Ptr& service, double nextCheck, const String& authority);
|
||||||
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
|
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
|
||||||
void ForceNextCheckChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
|
void ForceNextCheckChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
|
||||||
|
void ForceNextNotificationChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
|
||||||
void EnableActiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
|
void EnableActiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
|
||||||
void EnablePassiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
|
void EnablePassiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
|
||||||
void CommentAddedHandler(const Service::Ptr& service, const Dictionary::Ptr& comment, const String& authority);
|
void CommentAddedHandler(const Service::Ptr& service, const Dictionary::Ptr& comment, const String& authority);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "base/utility.h"
|
||||||
#include "config/configitembuilder.h"
|
#include "config/configitembuilder.h"
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
@ -219,7 +220,9 @@ bool Service::GetForceNextNotification(void) const
|
||||||
return static_cast<bool>(m_ForceNextNotification);
|
return static_cast<bool>(m_ForceNextNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::SetForceNextNotification(bool forced)
|
void Service::SetForceNextNotification(bool forced, const String& authority)
|
||||||
{
|
{
|
||||||
m_ForceNextNotification = forced ? 1 : 0;
|
m_ForceNextNotification = forced ? 1 : 0;
|
||||||
|
|
||||||
|
Utility::QueueAsyncCallback(bind(boost::ref(OnForceNextNotificationChanged), GetSelf(), forced, authority));
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,7 @@ public:
|
||||||
|
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, double, const String&)> OnNextCheckChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, double, const String&)> OnNextCheckChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnForceNextCheckChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnForceNextCheckChanged;
|
||||||
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnForceNextNotificationChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableActiveChecksChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnableActiveChecksChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnablePassiveChecksChanged;
|
static boost::signals2::signal<void (const Service::Ptr&, bool, const String&)> OnEnablePassiveChecksChanged;
|
||||||
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnNewCheckResult;
|
static boost::signals2::signal<void (const Service::Ptr&, const Dictionary::Ptr&, const String&)> OnNewCheckResult;
|
||||||
|
@ -306,7 +307,7 @@ public:
|
||||||
void AddNotification(const Notification::Ptr& notification);
|
void AddNotification(const Notification::Ptr& notification);
|
||||||
void RemoveNotification(const Notification::Ptr& notification);
|
void RemoveNotification(const Notification::Ptr& notification);
|
||||||
|
|
||||||
void SetForceNextNotification(bool force);
|
void SetForceNextNotification(bool force, const String& authority = String());
|
||||||
bool GetForceNextNotification(void) const;
|
bool GetForceNextNotification(void) const;
|
||||||
|
|
||||||
void ResetNotificationNumbers(void);
|
void ResetNotificationNumbers(void);
|
||||||
|
|
Loading…
Reference in New Issue