From edb5c47a9dbb337891cc4d7b2c676facc5ed157b Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Wed, 29 Jul 2020 08:52:15 +0200 Subject: [PATCH] Execute notification command only if there is a source param --- lib/icinga/clusterevents-check.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/icinga/clusterevents-check.cpp b/lib/icinga/clusterevents-check.cpp index ac5aed797..5be2b43bb 100644 --- a/lib/icinga/clusterevents-check.cpp +++ b/lib/icinga/clusterevents-check.cpp @@ -306,7 +306,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons throw; } } - } else if (command_type == "notification_command") { + } else if (command_type == "notification_command" && params->Contains("source")) { /* Get user */ User::Ptr user = new User(); Dictionary::Ptr attrs = new Dictionary(); @@ -332,14 +332,12 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons notificationCommand->Execute(notification, user, cr, NotificationType::NotificationCustom, author, ""); } catch (const std::exception& ex) { - if (params->Contains("source")) { - String output = "Exception occurred during notification '" + notification->GetName() - + "' for checkable '" + notification->GetCheckable()->GetName() - + "' and user '" + user->GetName() + "' using command '" + command + "': " - + DiagnosticInformation(ex, false); - double now = Utility::GetTime(); - SendEventExecuteCommand(params, ServiceUnknown, output, now, now, listener, origin, sourceEndpoint); - } + String output = "Exception occurred during notification '" + notification->GetName() + + "' for checkable '" + notification->GetCheckable()->GetName() + + "' and user '" + user->GetName() + "' using command '" + command + "': " + + DiagnosticInformation(ex, false); + double now = Utility::GetTime(); + SendEventExecuteCommand(params, ServiceUnknown, output, now, now, listener, origin, sourceEndpoint); } } }