]> granicus.if.org Git - icinga2/commitdiff
Make NotificationResult available for events: Cluster and Features
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 28 Mar 2019 10:42:28 +0000 (11:42 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 28 Mar 2019 10:42:28 +0000 (11:42 +0100)
lib/compat/compatlogger.cpp
lib/compat/compatlogger.hpp
lib/db_ido/dbevents.cpp
lib/db_ido/dbevents.hpp
lib/icinga/checkable-notification.cpp
lib/icinga/checkable.hpp
lib/icinga/clusterevents.cpp
lib/icinga/clusterevents.hpp
lib/icinga/notification.cpp
lib/perfdata/gelfwriter.cpp
lib/perfdata/gelfwriter.hpp

index 87a4da5dc459dda15f21b3e8c059eb3f18dd6097..767dd72877670c546413c590c5820d9c63fa702c 100644 (file)
@@ -50,7 +50,7 @@ void CompatLogger::Start(bool runtimeCreated)
                << "The CompatLogger feature is DEPRECATED and will be removed in Icinga v2.11.";
 
        Checkable::OnNewCheckResult.connect(std::bind(&CompatLogger::CheckResultHandler, this, _1, _2));
-       Checkable::OnNotificationSentToUser.connect(std::bind(&CompatLogger::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6, _7, _8));
+       Checkable::OnNotificationSentToUser.connect(std::bind(&CompatLogger::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6, _7, _8, _9));
        Downtime::OnDowntimeTriggered.connect(std::bind(&CompatLogger::TriggerDowntimeHandler, this, _1));
        Downtime::OnDowntimeRemoved.connect(std::bind(&CompatLogger::RemoveDowntimeHandler, this, _1));
        Checkable::OnEventCommandExecuted.connect(std::bind(&CompatLogger::EventCommandHandler, this, _1));
@@ -230,7 +230,7 @@ void CompatLogger::RemoveDowntimeHandler(const Downtime::Ptr& downtime)
  * @threadsafety Always.
  */
 void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-       const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
+       const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
        const String& author, const String& comment_text, const String& command_name)
 {
        Host::Ptr host;
index 9fb0b29781179aa2bf3848c0e65bc8513f751c1d..748bb90a9e8b71b310f7e04c12563ad64127841e 100644 (file)
@@ -36,8 +36,8 @@ private:
 
        void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
        void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
-               const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
-               const String& author, const String& comment_text, const String& command_name);
+               const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr,
+               const NotificationResult::Ptr& nr, const String& author, const String& comment_text, const String& command_name);
        void FlappingChangedHandler(const Checkable::Ptr& checkable);
        void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
        void TriggerDowntimeHandler(const Downtime::Ptr& downtime);
index 111999b5e2f95b23fdb879f18c626254d17a0199..f5c87b2771a2fb5e990e758cd8f473503ef3c7aa 100644 (file)
@@ -56,7 +56,7 @@ void DbEvents::StaticInitialize()
        Checkable::OnStateChange.connect(std::bind(&DbEvents::AddStateChangeHistory, _1, _2, _3));
 
        Checkable::OnNewCheckResult.connect(std::bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
-       Checkable::OnNotificationSentToUser.connect(std::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7));
+       Checkable::OnNotificationSentToUser.connect(std::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7, _8));
        Checkable::OnFlappingChanged.connect(std::bind(&DbEvents::AddFlappingChangedLogHistory, _1));
        Checkable::OnEnableFlappingChanged.connect(std::bind(&DbEvents::AddEnableFlappingChangedLogHistory, _1));
        Downtime::OnDowntimeTriggered.connect(std::bind(&DbEvents::AddTriggerDowntimeLogHistory, _1));
@@ -1061,7 +1061,7 @@ void DbEvents::AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime)
 }
 
 void DbEvents::AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
-       NotificationType notification_type, const CheckResult::Ptr& cr,
+       NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
        const String& author, const String& comment_text)
 {
        CheckCommand::Ptr commandObj = checkable->GetCheckCommand();
index 858f3b3da6755b28e2dc14fe7f843ceeb1e41eb9..6e620ddfa574559314a812661d65e4f468d6703f 100644 (file)
@@ -94,8 +94,8 @@ public:
        static void AddTriggerDowntimeLogHistory(const Downtime::Ptr& downtime);
        static void AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime);
        static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-               const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
-               const String& comment_text);
+               const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+               const String& author, const String& comment_text);
 
        static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
        static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
index abb33ad399e7aa6aa601a269d2cfd1bb0680152e..568ff6c52daf0e08340d44a607fe5fc03f300b4d 100644 (file)
@@ -14,8 +14,8 @@ boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, c
        const NotificationType&, const CheckResult::Ptr&, const String&, const String&,
        const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToAllUsers;
 boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
-       const NotificationType&, const CheckResult::Ptr&, const String&, const String&, const String&,
-       const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToUser;
+       const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
+       const String&, const String&, const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToUser;
 
 void Checkable::ResetNotificationNumbers()
 {
index 29a5c6db0f3d9c9c4465905f3d9b628b3ec6d1dc..8c1d5fd4a8843697fb3c4d098ec1e2c02d430783 100644 (file)
@@ -116,8 +116,8 @@ public:
        static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
                const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationsRequested;
        static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
-               const NotificationType&, const CheckResult::Ptr&, const String&, const String&, const String&,
-               const MessageOrigin::Ptr&)> OnNotificationSentToUser;
+               const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
+               const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationSentToUser;
        static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&,
                const NotificationType&, const CheckResult::Ptr&, const String&,
                const String&, const MessageOrigin::Ptr&)> OnNotificationSentToAllUsers;
index 11f43f7adf8d7ba7cad5217ccf382f76879c99c4..2c14a35503b264aca30bd856aaff0c97ea805609 100644 (file)
@@ -624,7 +624,7 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi
 }
 
 void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
-       NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const String& command,
+       NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr, const String& author, const String& commentText, const String& command,
        const MessageOrigin::Ptr& origin)
 {
        ApiListener::Ptr listener = ApiListener::GetInstance();
@@ -644,6 +644,7 @@ void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notific
        params->Set("user", user->GetName());
        params->Set("type", notificationType);
        params->Set("cr", Serialize(cr));
+       params->Set("nr", Serialize(nr));
        params->Set("author", author);
        params->Set("text", commentText);
        params->Set("command", command);
@@ -705,6 +706,14 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or
                }
        }
 
+       NotificationResult::Ptr nr;
+       if (params->Contains("nr")) {
+               nr = new NotificationResult();
+               Dictionary::Ptr vnr = params->Get("nr");
+
+               Deserialize(nr, vnr, true);
+       }
+
        NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
        String author = params->Get("author");
        String text = params->Get("text");
@@ -721,7 +730,7 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or
 
        String command = params->Get("command");
 
-       Checkable::OnNotificationSentToUser(notification, checkable, user, type, cr, author, text, command, origin);
+       Checkable::OnNotificationSentToUser(notification, checkable, user, type, cr, nr, author, text, command, origin);
 
        return Empty;
 }
index 5ad18c3d9602ef800ac464f6220f65da6a76d9ab..144155cc544afdcc41c83fd9a83e8dfd3206bbb5 100644 (file)
@@ -51,7 +51,8 @@ public:
        static Value SendNotificationsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
 
        static void NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
-               NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const String& command, const MessageOrigin::Ptr& origin);
+               NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+               const String& author, const String& commentText, const String& command, const MessageOrigin::Ptr& origin);
        static Value NotificationSentUserAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
 
        static void NotificationSentToAllUsersHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
index 32a091a30e5c2d30cd6080db95588b176313f1d1..998705efaeb1513eeda8d93b556dd3ad872e5985 100644 (file)
@@ -539,7 +539,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
                command->Execute(this, user, cr, nr, type, author, text);
 
                /* required by compatlogger */
-               Checkable::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, command->GetName(), nullptr);
+               Checkable::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, nr, author, text, command->GetName(), nullptr);
 
                Log(LogInformation, "Notification")
                        << "Completed sending '" << NotificationTypeToStringInternal(type)
index 59fc7dcc4a105a3d18124b5ab50accd3d5936b94..55199d7172adf27a5bf2d30ea1848cd95fdb0c25 100644 (file)
@@ -86,7 +86,7 @@ void GelfWriter::Resume()
 
        /* Register event handlers. */
        Checkable::OnNewCheckResult.connect(std::bind(&GelfWriter::CheckResultHandler, this, _1, _2));
-       Checkable::OnNotificationSentToUser.connect(std::bind(&GelfWriter::NotificationToUserHandler, this, _1, _2, _3, _4, _5, _6, _7, _8));
+       Checkable::OnNotificationSentToUser.connect(std::bind(&GelfWriter::NotificationToUserHandler, this, _1, _2, _3, _4, _5, _6, _7, _8, _9));
        Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
 }
 
@@ -306,18 +306,18 @@ void GelfWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable, con
 }
 
 void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-       const User::Ptr& user, NotificationType notificationType, CheckResult::Ptr const& cr,
+       const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
        const String& author, const String& commentText, const String& commandName)
 {
        if (IsPaused())
                return;
 
        m_WorkQueue.Enqueue(std::bind(&GelfWriter::NotificationToUserHandlerInternal, this,
-               notification, checkable, user, notificationType, cr, author, commentText, commandName));
+               notification, checkable, user, notificationType, cr, nr, author, commentText, commandName));
 }
 
 void GelfWriter::NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-       const User::Ptr& user, NotificationType notificationType, CheckResult::Ptr const& cr,
+       const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
        const String& author, const String& commentText, const String& commandName)
 {
        AssertOnWorkQueue();
index 6e222d214c10b907aa4f5df6d2114f47de23818d..41680cb34a6e08259b8cfb1dc7b76df9da3166cd 100644 (file)
@@ -41,10 +41,10 @@ private:
        void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
        void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
        void NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-               const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr,
+               const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
                const String& author, const String& commentText, const String& commandName);
        void NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
-               const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr,
+               const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
                const String& author, const String& comment_text, const String& command_name);
        void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
        void StateChangeHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);