like flapping and downtimes behave now.
refs #4361
m_Endpoint = Endpoint::MakeEndpoint("compatlog_" + GetName(), false);
m_Endpoint->RegisterTopicHandler("checker::CheckResult",
boost::bind(&CompatLog::CheckResultRequestHandler, this, _3));
- m_Endpoint->RegisterTopicHandler("icinga::NotificationSent",
- boost::bind(&CompatLog::NotificationSentRequestHandler, this, _3));
Service::OnDowntimeChanged.connect(bind(&CompatLog::DowntimeHandler, this, _1, _2));
+ Service::OnNotificationSentChanged.connect(bind(&CompatLog::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6));
Service::OnFlappingChanged.connect(bind(&CompatLog::FlappingHandler, this, _1, _2));
m_RotationTimer = boost::make_shared<Timer>();
/**
* @threadsafety Always.
*/
-void CompatLog::NotificationSentRequestHandler(const RequestMessage& request)
+void CompatLog::NotificationSentHandler(const Service::Ptr& service, const String& username,
+ NotificationType const& notification_type, Dictionary::Ptr const& cr,
+ const String& author, const String& comment_text)
{
- NotificationMessage params;
- if (!request.GetParams(¶ms))
- return;
-
- String svcname = params.GetService();
- Service::Ptr service = Service::GetByName(svcname);
-
Host::Ptr host = service->GetHost();
if (!host)
return;
- String username = params.GetUser();
- String author = params.GetAuthor();
- String comment_text = params.GetCommentText();
-
CheckCommand::Ptr commandObj = service->GetCheckCommand();
String check_command = "";
if (commandObj)
check_command = commandObj->GetName();
- NotificationType notification_type = params.GetType();
String notification_type_str = Notification::NotificationTypeToString(notification_type);
String author_comment = "";
author_comment = ";" + author + ";" + comment_text;
}
- Dictionary::Ptr cr = params.GetCheckResult();
if (!cr)
return;
Endpoint::Ptr m_Endpoint;
void CheckResultRequestHandler(const RequestMessage& request);
- void NotificationSentRequestHandler(const RequestMessage& request);
void DowntimeHandler(const Service::Ptr& service, DowntimeState downtime_state);
+ void NotificationSentHandler(const Service::Ptr& service, const String& username, NotificationType const& notification_type, Dictionary::Ptr const& cr, const String& author, const String& comment_text);
void FlappingHandler(const Service::Ptr& service, FlappingState flapping_state);
Timer::Ptr m_RotationTimer;
#include "icinga/service.h"
#include "icinga/notificationrequestmessage.h"
+#include "icinga/notificationmessage.h"
#include "remoting/endpointmanager.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
static bool l_NotificationsCacheNeedsUpdate = false;
static Timer::Ptr l_NotificationsCacheTimer;
+boost::signals2::signal<void (const Service::Ptr&, const String&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> Service::OnNotificationSentChanged;
+
+void Service::NotificationSentRequestHandler(const RequestMessage& request)
+{
+ NotificationMessage params;
+ if (!request.GetParams(¶ms))
+ return;
+
+ String svcname = params.GetService();
+ Service::Ptr service = Service::GetByName(svcname);
+
+ String username = params.GetUser();
+ String author = params.GetAuthor();
+ String comment_text = params.GetCommentText();
+
+ NotificationType notification_type = params.GetType();
+ Dictionary::Ptr cr = params.GetCheckResult();
+
+ OnNotificationSentChanged(service, username, notification_type, cr, author, comment_text);
+}
+
void Service::RequestNotifications(NotificationType type, const Dictionary::Ptr& cr, const String& author, const String& text)
{
RequestMessage msg;
void Service::Initialize(void)
{
m_Endpoint = Endpoint::MakeEndpoint("service", false);
+ m_Endpoint->RegisterTopicHandler("icinga::NotificationSent",
+ boost::bind(&Service::NotificationSentRequestHandler, _3));
m_Endpoint->RegisterTopicHandler("icinga::Downtime",
boost::bind(&Service::DowntimeRequestHandler, _3));
m_Endpoint->RegisterTopicHandler("icinga::Flapping",
static boost::signals2::signal<void (const Service::Ptr&)> OnCheckerChanged;
static boost::signals2::signal<void (const Service::Ptr&)> OnNextCheckChanged;
+ static boost::signals2::signal<void (const Service::Ptr&, const String&, const NotificationType&, const Dictionary::Ptr&, const String&, const String&)> OnNotificationSentChanged;
static boost::signals2::signal<void (const Service::Ptr&, DowntimeState)> OnDowntimeChanged;
static boost::signals2::signal<void (const Service::Ptr&, FlappingState)> OnFlappingChanged;
static void RefreshNotificationsCache(void);
+ static void NotificationSentRequestHandler(const RequestMessage& request);
+
/* Event Handler */
Attribute<String> m_EventCommand;