diff --git a/doc/08-advanced-topics.md b/doc/08-advanced-topics.md
index f0f154525..0b8cf065a 100644
--- a/doc/08-advanced-topics.md
+++ b/doc/08-advanced-topics.md
@@ -1170,3 +1170,16 @@ Icinga 2 parses performance data strings returned by check plugins and makes the
warn | Value | Warning threshold value.
min | Value | Minimum value returned by the check.
max | Value | Maximum value returned by the check.
+
+### NotificationResult
+
+ Name | Type | Description
+ --------------------------|-----------------------|----------------------------------
+ exit\_status | Number | The exit status returned by the check execution.
+ output | String | The notification command output.
+ execution\_endpoint | String | Name of the node executing the check.
+ command | Value | Array of command with shell-escaped arguments or command line string.
+ execution\_start | Timestamp | Check execution start time (as a UNIX timestamp).
+ execution\_end | Timestamp | Check execution end time (as a UNIX timestamp).
+ active | Boolean | Whether the result is from an active or passive check.
+
diff --git a/lib/compat/compatlogger.cpp b/lib/compat/compatlogger.cpp
index fda1b2b8d..fbbc95e6e 100644
--- a/lib/compat/compatlogger.cpp
+++ b/lib/compat/compatlogger.cpp
@@ -50,7 +50,7 @@ void CompatLogger::Start(bool runtimeCreated)
<< "This feature is DEPRECATED and will be removed in future releases. Check the roadmap at https://github.com/Icinga/icinga2/milestones";
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;
diff --git a/lib/compat/compatlogger.hpp b/lib/compat/compatlogger.hpp
index 9fb0b2978..748bb90a9 100644
--- a/lib/compat/compatlogger.hpp
+++ b/lib/compat/compatlogger.hpp
@@ -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);
diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp
index 111999b5e..f5c87b277 100644
--- a/lib/db_ido/dbevents.cpp
+++ b/lib/db_ido/dbevents.cpp
@@ -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();
diff --git a/lib/db_ido/dbevents.hpp b/lib/db_ido/dbevents.hpp
index 858f3b3da..6e620ddfa 100644
--- a/lib/db_ido/dbevents.hpp
+++ b/lib/db_ido/dbevents.hpp
@@ -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);
diff --git a/lib/icinga/CMakeLists.txt b/lib/icinga/CMakeLists.txt
index 7079d84e5..00951609b 100644
--- a/lib/icinga/CMakeLists.txt
+++ b/lib/icinga/CMakeLists.txt
@@ -13,6 +13,7 @@ mkclass_target(host.ti host-ti.cpp host-ti.hpp)
mkclass_target(icingaapplication.ti icingaapplication-ti.cpp icingaapplication-ti.hpp)
mkclass_target(customvarobject.ti customvarobject-ti.cpp customvarobject-ti.hpp)
mkclass_target(notificationcommand.ti notificationcommand-ti.cpp notificationcommand-ti.hpp)
+mkclass_target(notificationresult.ti notificationresult-ti.cpp notificationresult-ti.hpp)
mkclass_target(notification.ti notification-ti.cpp notification-ti.hpp)
mkclass_target(scheduleddowntime.ti scheduleddowntime-ti.cpp scheduleddowntime-ti.hpp)
mkclass_target(servicegroup.ti servicegroup-ti.cpp servicegroup-ti.hpp)
@@ -51,6 +52,7 @@ set(icinga_SOURCES
macroresolver.hpp
notification.cpp notification.hpp notification-ti.hpp notification-apply.cpp
notificationcommand.cpp notificationcommand.hpp notificationcommand-ti.hpp
+ notificationresult.cpp notificationresult.hpp notificationresult-ti.hpp
objectutils.cpp objectutils.hpp
pluginutility.cpp pluginutility.hpp
scheduleddowntime.cpp scheduleddowntime.hpp scheduleddowntime-ti.hpp scheduleddowntime-apply.cpp
diff --git a/lib/icinga/checkable-notification.cpp b/lib/icinga/checkable-notification.cpp
index abb33ad39..568ff6c52 100644
--- a/lib/icinga/checkable-notification.cpp
+++ b/lib/icinga/checkable-notification.cpp
@@ -14,8 +14,8 @@ boost::signals2::signal Checkable::OnNotificationSentToAllUsers;
boost::signals2::signal Checkable::OnNotificationSentToUser;
+ const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
+ const String&, const String&, const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToUser;
void Checkable::ResetNotificationNumbers()
{
diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp
index 6f0b94253..fcfb3f74b 100644
--- a/lib/icinga/checkable.hpp
+++ b/lib/icinga/checkable.hpp
@@ -119,8 +119,8 @@ public:
static boost::signals2::signal OnNotificationsRequested;
static boost::signals2::signal OnNotificationSentToUser;
+ const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
+ const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationSentToUser;
static boost::signals2::signal&,
const NotificationType&, const CheckResult::Ptr&, const String&,
const String&, const MessageOrigin::Ptr&)> OnNotificationSentToAllUsers;
diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp
index 11f43f7ad..2c14a3550 100644
--- a/lib/icinga/clusterevents.cpp
+++ b/lib/icinga/clusterevents.cpp
@@ -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(static_cast(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;
}
diff --git a/lib/icinga/clusterevents.hpp b/lib/icinga/clusterevents.hpp
index 5ad18c3d9..144155cc5 100644
--- a/lib/icinga/clusterevents.hpp
+++ b/lib/icinga/clusterevents.hpp
@@ -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& users,
diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp
index 9379cf40a..998705efa 100644
--- a/lib/icinga/notification.cpp
+++ b/lib/icinga/notification.cpp
@@ -22,6 +22,7 @@ std::map Notification::m_StateFilterMap;
std::map Notification::m_TypeFilterMap;
boost::signals2::signal Notification::OnNextNotificationChanged;
+boost::signals2::signal Notification::OnNewNotificationResult;
String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
{
@@ -531,10 +532,14 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
String commandName = command->GetName();
try {
- command->Execute(this, user, cr, type, author, text);
+ NotificationResult::Ptr nr = new NotificationResult();
+
+ nr->SetExecutionStart(Utility::GetTime());
+
+ command->Execute(this, user, cr, nr, type, author, text);
/* required by compatlogger */
- Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, commandName, nullptr);
+ Checkable::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, nr, author, text, command->GetName(), nullptr);
Log(LogInformation, "Notification")
<< "Completed sending '" << NotificationTypeToStringInternal(type)
@@ -550,6 +555,36 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
}
}
+void Notification::ProcessNotificationResult(const NotificationResult::Ptr& nr, const MessageOrigin::Ptr& origin)
+{
+ if (!nr)
+ return;
+
+ double now = Utility::GetTime();
+
+ if (nr->GetExecutionStart() == 0)
+ nr->SetExecutionStart(now);
+
+ if (nr->GetExecutionEnd() == 0)
+ nr->SetExecutionEnd(now);
+
+ /* Determine the execution endpoint from a locally executed check. */
+ if (!origin || origin->IsLocal())
+ nr->SetExecutionEndpoint(IcingaApplication::GetInstance()->GetNodeName());
+
+ if (!IsActive())
+ return;
+
+ {
+ ObjectLock olock(this);
+
+ SetLastNotificationResult(nr);
+ }
+
+ /* Notify cluster, API and feature events. */
+ OnNewNotificationResult(this, nr, origin);
+}
+
int icinga::ServiceStateToFilter(ServiceState state)
{
switch (state) {
diff --git a/lib/icinga/notification.hpp b/lib/icinga/notification.hpp
index 32333a559..5006e89d8 100644
--- a/lib/icinga/notification.hpp
+++ b/lib/icinga/notification.hpp
@@ -10,6 +10,7 @@
#include "icinga/usergroup.hpp"
#include "icinga/timeperiod.hpp"
#include "icinga/checkresult.hpp"
+#include "icinga/notificationresult.hpp"
#include "remote/endpoint.hpp"
#include "remote/messageorigin.hpp"
#include "base/array.hpp"
@@ -82,10 +83,13 @@ public:
Endpoint::Ptr GetCommandEndpoint() const;
+ void ProcessNotificationResult(const NotificationResult::Ptr& nr, const MessageOrigin::Ptr& origin = nullptr);
+
static String NotificationTypeToString(NotificationType type);
static String NotificationFilterToString(int filter, const std::map& filterMap);
static boost::signals2::signal OnNextNotificationChanged;
+ static boost::signals2::signal OnNewNotificationResult;
void Validate(int types, const ValidationUtils& utils) override;
diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti
index 04e6214ea..f2aa77ed1 100644
--- a/lib/icinga/notification.ti
+++ b/lib/icinga/notification.ti
@@ -1,6 +1,8 @@
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#include "icinga/customvarobject.hpp"
+#include "icinga/notificationresult.hpp"
+#include "base/array.hpp"
#impl_include "icinga/notificationcommand.hpp"
#impl_include "icinga/service.hpp"
@@ -16,6 +18,7 @@ public:
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
virtual Dictionary::Ptr ParseName(const String& name) const;
};
+
}}}
class Notification : CustomVarObject < NotificationNameComposer
@@ -81,6 +84,7 @@ class Notification : CustomVarObject < NotificationNameComposer
[state] Timestamp next_notification;
[state] int notification_number;
[state] Timestamp last_problem_notification;
+ [state] NotificationResult::Ptr last_notification_result;
[config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
navigate {{{
diff --git a/lib/icinga/notificationcommand.cpp b/lib/icinga/notificationcommand.cpp
index 8ae3e82a5..dc9edb4f3 100644
--- a/lib/icinga/notificationcommand.cpp
+++ b/lib/icinga/notificationcommand.cpp
@@ -8,14 +8,15 @@ using namespace icinga;
REGISTER_TYPE(NotificationCommand);
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
- const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
- const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
- bool useResolvedMacros)
+ const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+ const NotificationType& type, const String& author, const String& comment,
+ const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
return GetExecute()->Invoke({
notification,
user,
cr,
+ nr,
type,
author,
comment,
diff --git a/lib/icinga/notificationcommand.hpp b/lib/icinga/notificationcommand.hpp
index 210c91e86..0c76a0142 100644
--- a/lib/icinga/notificationcommand.hpp
+++ b/lib/icinga/notificationcommand.hpp
@@ -23,8 +23,8 @@ public:
DECLARE_OBJECTNAME(NotificationCommand);
virtual Dictionary::Ptr Execute(const intrusive_ptr& notification,
- const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
- const String& author, const String& comment,
+ const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+ const NotificationType& type, const String& author, const String& comment,
const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false);
};
diff --git a/lib/icinga/notificationresult.cpp b/lib/icinga/notificationresult.cpp
new file mode 100644
index 000000000..d57ad4bb0
--- /dev/null
+++ b/lib/icinga/notificationresult.cpp
@@ -0,0 +1,13 @@
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
+
+#include "icinga/notificationresult.hpp"
+#include "icinga/notificationresult-ti.cpp"
+
+using namespace icinga;
+
+REGISTER_TYPE(NotificationResult);
+
+double NotificationResult::CalculateExecutionTime() const
+{
+ return GetExecutionEnd() - GetExecutionStart();
+}
diff --git a/lib/icinga/notificationresult.hpp b/lib/icinga/notificationresult.hpp
new file mode 100644
index 000000000..bb7049f18
--- /dev/null
+++ b/lib/icinga/notificationresult.hpp
@@ -0,0 +1,27 @@
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
+
+#ifndef NOTIFICATIONRESULT_H
+#define NOTIFICATIONRESULT_H
+
+#include "icinga/i2-icinga.hpp"
+#include "icinga/notificationresult-ti.hpp"
+
+namespace icinga
+{
+
+/**
+ * A notification result.
+ *
+ * @ingroup icinga
+ */
+class NotificationResult final : public ObjectImpl
+{
+public:
+ DECLARE_OBJECT(NotificationResult);
+
+ double CalculateExecutionTime() const;
+};
+
+}
+
+#endif /* NOTIFICATIONRESULT_H */
diff --git a/lib/icinga/notificationresult.ti b/lib/icinga/notificationresult.ti
new file mode 100644
index 000000000..0b77c938f
--- /dev/null
+++ b/lib/icinga/notificationresult.ti
@@ -0,0 +1,24 @@
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
+
+library icinga;
+
+namespace icinga
+{
+
+class NotificationResult
+{
+ [state] Timestamp execution_start;
+ [state] Timestamp execution_end;
+
+ [state] Value command;
+ [state] int exit_status;
+ [state] String output;
+
+ [state] bool active {
+ default {{{ return true; }}}
+ };
+
+ [state] String execution_endpoint;
+};
+
+}
diff --git a/lib/methods/pluginnotificationtask.cpp b/lib/methods/pluginnotificationtask.cpp
index 08ba4e2eb..8b8539139 100644
--- a/lib/methods/pluginnotificationtask.cpp
+++ b/lib/methods/pluginnotificationtask.cpp
@@ -15,12 +15,12 @@
using namespace icinga;
-REGISTER_FUNCTION_NONCONST(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc, "notification:user:cr:itype:author:comment:resolvedMacros:useResolvedMacros");
+REGISTER_FUNCTION_NONCONST(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc, "notification:user:cr:nr:itype:author:comment:resolvedMacros:useResolvedMacros");
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
- const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
- const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
- bool useResolvedMacros)
+ const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+ int itype, const String& author, const String& comment,
+ const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
REQUIRE_NOT_NULL(notification);
REQUIRE_NOT_NULL(user);
@@ -55,16 +55,28 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers,
resolvedMacros, useResolvedMacros, timeout,
- std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2));
+ std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, notification, nr, _1, _2));
}
-void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& commandLine, const ProcessResult& pr)
+void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable,
+ const Notification::Ptr& notification, const NotificationResult::Ptr& nr, const Value& commandLine, const ProcessResult& pr)
{
if (pr.ExitStatus != 0) {
Process::Arguments parguments = Process::PrepareCommand(commandLine);
Log(LogWarning, "PluginNotificationTask")
- << "Notification command for object '" << checkable->GetName() << "' (PID: " << pr.PID
+ << "Notification command for checkable '" << checkable->GetName()
+ << "' and notification '" << notification->GetName() << "' (PID: " << pr.PID
<< ", arguments: " << Process::PrettyPrintArguments(parguments) << ") terminated with exit code "
<< pr.ExitStatus << ", output: " << pr.Output;
}
+
+ String output = pr.Output.Trim();
+
+ nr->SetCommand(commandLine);
+ nr->SetOutput(output);
+ nr->SetExitStatus(pr.ExitStatus);
+ nr->SetExecutionStart(pr.ExecutionStart);
+ nr->SetExecutionEnd(pr.ExecutionEnd);
+
+ notification->ProcessNotificationResult(nr);
}
diff --git a/lib/methods/pluginnotificationtask.hpp b/lib/methods/pluginnotificationtask.hpp
index 66d653924..6a741b73b 100644
--- a/lib/methods/pluginnotificationtask.hpp
+++ b/lib/methods/pluginnotificationtask.hpp
@@ -20,14 +20,15 @@ class PluginNotificationTask
{
public:
static void ScriptFunc(const Notification::Ptr& notification,
- const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
- const String& author, const String& comment,
+ const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
+ int itype, const String& author, const String& comment,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
private:
PluginNotificationTask();
static void ProcessFinishedHandler(const Checkable::Ptr& checkable,
+ const Notification::Ptr& notification, const NotificationResult::Ptr& nr,
const Value& commandLine, const ProcessResult& pr);
};
diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp
index 59fc7dcc4..55199d717 100644
--- a/lib/perfdata/gelfwriter.cpp
+++ b/lib/perfdata/gelfwriter.cpp
@@ -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();
diff --git a/lib/perfdata/gelfwriter.hpp b/lib/perfdata/gelfwriter.hpp
index 6e222d214..41680cb34 100644
--- a/lib/perfdata/gelfwriter.hpp
+++ b/lib/perfdata/gelfwriter.hpp
@@ -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);