mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
Merge pull request #7737 from Icinga/bugfix/revert-notification-result
Revert NotificationResult
This commit is contained in:
commit
cb21086d6c
@ -1190,16 +1190,3 @@ Icinga 2 parses performance data strings returned by check plugins and makes the
|
|||||||
warn | Value | Warning threshold value.
|
warn | Value | Warning threshold value.
|
||||||
min | Value | Minimum value returned by the check.
|
min | Value | Minimum value returned by the check.
|
||||||
max | Value | Maximum value returned by the check.
|
max | Value | Maximum value returned by the check.
|
||||||
|
|
||||||
### NotificationResult <a id="advanced-value-types-notificationresult"></a>
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
@ -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";
|
<< "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::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, _9));
|
Checkable::OnNotificationSentToUser.connect(std::bind(&CompatLogger::NotificationSentHandler, this, _1, _2, _3, _4, _5, _6, _7, _8));
|
||||||
Downtime::OnDowntimeTriggered.connect(std::bind(&CompatLogger::TriggerDowntimeHandler, this, _1));
|
Downtime::OnDowntimeTriggered.connect(std::bind(&CompatLogger::TriggerDowntimeHandler, this, _1));
|
||||||
Downtime::OnDowntimeRemoved.connect(std::bind(&CompatLogger::RemoveDowntimeHandler, this, _1));
|
Downtime::OnDowntimeRemoved.connect(std::bind(&CompatLogger::RemoveDowntimeHandler, this, _1));
|
||||||
Checkable::OnEventCommandExecuted.connect(std::bind(&CompatLogger::EventCommandHandler, this, _1));
|
Checkable::OnEventCommandExecuted.connect(std::bind(&CompatLogger::EventCommandHandler, this, _1));
|
||||||
@ -230,7 +230,7 @@ void CompatLogger::RemoveDowntimeHandler(const Downtime::Ptr& downtime)
|
|||||||
* @threadsafety Always.
|
* @threadsafety Always.
|
||||||
*/
|
*/
|
||||||
void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
|
||||||
const String& author, const String& comment_text, const String& command_name)
|
const String& author, const String& comment_text, const String& command_name)
|
||||||
{
|
{
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
|
@ -36,8 +36,8 @@ private:
|
|||||||
|
|
||||||
void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
|
void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
|
||||||
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
|
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
|
||||||
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr,
|
const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
|
||||||
const NotificationResult::Ptr& nr, const String& author, const String& comment_text, const String& command_name);
|
const String& author, const String& comment_text, const String& command_name);
|
||||||
void FlappingChangedHandler(const Checkable::Ptr& checkable);
|
void FlappingChangedHandler(const Checkable::Ptr& checkable);
|
||||||
void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
|
void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
|
||||||
void TriggerDowntimeHandler(const Downtime::Ptr& downtime);
|
void TriggerDowntimeHandler(const Downtime::Ptr& downtime);
|
||||||
|
@ -56,7 +56,7 @@ void DbEvents::StaticInitialize()
|
|||||||
Checkable::OnStateChange.connect(std::bind(&DbEvents::AddStateChangeHistory, _1, _2, _3));
|
Checkable::OnStateChange.connect(std::bind(&DbEvents::AddStateChangeHistory, _1, _2, _3));
|
||||||
|
|
||||||
Checkable::OnNewCheckResult.connect(std::bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
|
Checkable::OnNewCheckResult.connect(std::bind(&DbEvents::AddCheckResultLogHistory, _1, _2));
|
||||||
Checkable::OnNotificationSentToUser.connect(std::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7, _8));
|
Checkable::OnNotificationSentToUser.connect(std::bind(&DbEvents::AddNotificationSentLogHistory, _1, _2, _3, _4, _5, _6, _7));
|
||||||
Checkable::OnFlappingChanged.connect(std::bind(&DbEvents::AddFlappingChangedLogHistory, _1));
|
Checkable::OnFlappingChanged.connect(std::bind(&DbEvents::AddFlappingChangedLogHistory, _1));
|
||||||
Checkable::OnEnableFlappingChanged.connect(std::bind(&DbEvents::AddEnableFlappingChangedLogHistory, _1));
|
Checkable::OnEnableFlappingChanged.connect(std::bind(&DbEvents::AddEnableFlappingChangedLogHistory, _1));
|
||||||
Downtime::OnDowntimeTriggered.connect(std::bind(&DbEvents::AddTriggerDowntimeLogHistory, _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,
|
void DbEvents::AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
|
||||||
NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
NotificationType notification_type, const CheckResult::Ptr& cr,
|
||||||
const String& author, const String& comment_text)
|
const String& author, const String& comment_text)
|
||||||
{
|
{
|
||||||
CheckCommand::Ptr commandObj = checkable->GetCheckCommand();
|
CheckCommand::Ptr commandObj = checkable->GetCheckCommand();
|
||||||
|
@ -94,8 +94,8 @@ public:
|
|||||||
static void AddTriggerDowntimeLogHistory(const Downtime::Ptr& downtime);
|
static void AddTriggerDowntimeLogHistory(const Downtime::Ptr& downtime);
|
||||||
static void AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime);
|
static void AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime);
|
||||||
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const String& author,
|
||||||
const String& author, const String& comment_text);
|
const String& comment_text);
|
||||||
|
|
||||||
static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
||||||
static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
|
||||||
|
@ -13,7 +13,6 @@ mkclass_target(host.ti host-ti.cpp host-ti.hpp)
|
|||||||
mkclass_target(icingaapplication.ti icingaapplication-ti.cpp icingaapplication-ti.hpp)
|
mkclass_target(icingaapplication.ti icingaapplication-ti.cpp icingaapplication-ti.hpp)
|
||||||
mkclass_target(customvarobject.ti customvarobject-ti.cpp customvarobject-ti.hpp)
|
mkclass_target(customvarobject.ti customvarobject-ti.cpp customvarobject-ti.hpp)
|
||||||
mkclass_target(notificationcommand.ti notificationcommand-ti.cpp notificationcommand-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(notification.ti notification-ti.cpp notification-ti.hpp)
|
||||||
mkclass_target(scheduleddowntime.ti scheduleddowntime-ti.cpp scheduleddowntime-ti.hpp)
|
mkclass_target(scheduleddowntime.ti scheduleddowntime-ti.cpp scheduleddowntime-ti.hpp)
|
||||||
mkclass_target(servicegroup.ti servicegroup-ti.cpp servicegroup-ti.hpp)
|
mkclass_target(servicegroup.ti servicegroup-ti.cpp servicegroup-ti.hpp)
|
||||||
@ -52,7 +51,6 @@ set(icinga_SOURCES
|
|||||||
macroresolver.hpp
|
macroresolver.hpp
|
||||||
notification.cpp notification.hpp notification-ti.hpp notification-apply.cpp
|
notification.cpp notification.hpp notification-ti.hpp notification-apply.cpp
|
||||||
notificationcommand.cpp notificationcommand.hpp notificationcommand-ti.hpp
|
notificationcommand.cpp notificationcommand.hpp notificationcommand-ti.hpp
|
||||||
notificationresult.cpp notificationresult.hpp notificationresult-ti.hpp
|
|
||||||
objectutils.cpp objectutils.hpp
|
objectutils.cpp objectutils.hpp
|
||||||
pluginutility.cpp pluginutility.hpp
|
pluginutility.cpp pluginutility.hpp
|
||||||
scheduleddowntime.cpp scheduleddowntime.hpp scheduleddowntime-ti.hpp scheduleddowntime-apply.cpp
|
scheduleddowntime.cpp scheduleddowntime.hpp scheduleddowntime-ti.hpp scheduleddowntime-apply.cpp
|
||||||
|
@ -18,8 +18,8 @@ boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, c
|
|||||||
const NotificationType&, const CheckResult::Ptr&, const String&, const String&,
|
const NotificationType&, const CheckResult::Ptr&, const String&, const String&,
|
||||||
const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToAllUsers;
|
const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToAllUsers;
|
||||||
boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
|
boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
|
||||||
const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
|
const NotificationType&, const CheckResult::Ptr&, const String&, const String&, const String&,
|
||||||
const String&, const String&, const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToUser;
|
const MessageOrigin::Ptr&)> Checkable::OnNotificationSentToUser;
|
||||||
|
|
||||||
void Checkable::ResetNotificationNumbers()
|
void Checkable::ResetNotificationNumbers()
|
||||||
{
|
{
|
||||||
|
@ -106,8 +106,8 @@ public:
|
|||||||
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
|
static boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&,
|
||||||
const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationsRequested;
|
const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationsRequested;
|
||||||
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
|
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const User::Ptr&,
|
||||||
const NotificationType&, const CheckResult::Ptr&, const NotificationResult::Ptr&, const String&,
|
const NotificationType&, const CheckResult::Ptr&, const String&, const String&, const String&,
|
||||||
const String&, const String&, const MessageOrigin::Ptr&)> OnNotificationSentToUser;
|
const MessageOrigin::Ptr&)> OnNotificationSentToUser;
|
||||||
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&,
|
static boost::signals2::signal<void (const Notification::Ptr&, const Checkable::Ptr&, const std::set<User::Ptr>&,
|
||||||
const NotificationType&, const CheckResult::Ptr&, const String&,
|
const NotificationType&, const CheckResult::Ptr&, const String&,
|
||||||
const String&, const MessageOrigin::Ptr&)> OnNotificationSentToAllUsers;
|
const String&, const MessageOrigin::Ptr&)> OnNotificationSentToAllUsers;
|
||||||
|
@ -700,7 +700,7 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
|
void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
|
||||||
NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr, const String& author, const String& commentText, const String& command,
|
NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const String& command,
|
||||||
const MessageOrigin::Ptr& origin)
|
const MessageOrigin::Ptr& origin)
|
||||||
{
|
{
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
@ -720,7 +720,6 @@ void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notific
|
|||||||
params->Set("user", user->GetName());
|
params->Set("user", user->GetName());
|
||||||
params->Set("type", notificationType);
|
params->Set("type", notificationType);
|
||||||
params->Set("cr", Serialize(cr));
|
params->Set("cr", Serialize(cr));
|
||||||
params->Set("nr", Serialize(nr));
|
|
||||||
params->Set("author", author);
|
params->Set("author", author);
|
||||||
params->Set("text", commentText);
|
params->Set("text", commentText);
|
||||||
params->Set("command", command);
|
params->Set("command", command);
|
||||||
@ -782,14 +781,6 @@ 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")));
|
NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
|
||||||
String author = params->Get("author");
|
String author = params->Get("author");
|
||||||
String text = params->Get("text");
|
String text = params->Get("text");
|
||||||
@ -806,7 +797,7 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or
|
|||||||
|
|
||||||
String command = params->Get("command");
|
String command = params->Get("command");
|
||||||
|
|
||||||
Checkable::OnNotificationSentToUser(notification, checkable, user, type, cr, nr, author, text, command, origin);
|
Checkable::OnNotificationSentToUser(notification, checkable, user, type, cr, author, text, command, origin);
|
||||||
|
|
||||||
return Empty;
|
return Empty;
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,7 @@ public:
|
|||||||
static Value SendNotificationsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
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,
|
static void NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
|
||||||
NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const String& command, const MessageOrigin::Ptr& origin);
|
||||||
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 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,
|
static void NotificationSentToAllUsersHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
|
||||||
|
@ -23,7 +23,6 @@ std::map<String, int> Notification::m_StateFilterMap;
|
|||||||
std::map<String, int> Notification::m_TypeFilterMap;
|
std::map<String, int> Notification::m_TypeFilterMap;
|
||||||
|
|
||||||
boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNextNotificationChanged;
|
boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNextNotificationChanged;
|
||||||
boost::signals2::signal<void (const Notification::Ptr&, const NotificationResult::Ptr&, const MessageOrigin::Ptr&)> Notification::OnNewNotificationResult;
|
|
||||||
|
|
||||||
String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
|
String NotificationNameComposer::MakeName(const String& shortName, const Object::Ptr& context) const
|
||||||
{
|
{
|
||||||
@ -509,14 +508,10 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
|||||||
String commandName = command->GetName();
|
String commandName = command->GetName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NotificationResult::Ptr nr = new NotificationResult();
|
command->Execute(this, user, cr, type, author, text);
|
||||||
|
|
||||||
nr->SetExecutionStart(Utility::GetTime());
|
|
||||||
|
|
||||||
command->Execute(this, user, cr, nr, type, author, text);
|
|
||||||
|
|
||||||
/* required by compatlogger */
|
/* required by compatlogger */
|
||||||
Checkable::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, nr, author, text, command->GetName(), nullptr);
|
Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, commandName, nullptr);
|
||||||
|
|
||||||
Log(LogInformation, "Notification")
|
Log(LogInformation, "Notification")
|
||||||
<< "Completed sending '" << NotificationTypeToString(type)
|
<< "Completed sending '" << NotificationTypeToString(type)
|
||||||
@ -532,36 +527,6 @@ 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)
|
int icinga::ServiceStateToFilter(ServiceState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "icinga/usergroup.hpp"
|
#include "icinga/usergroup.hpp"
|
||||||
#include "icinga/timeperiod.hpp"
|
#include "icinga/timeperiod.hpp"
|
||||||
#include "icinga/checkresult.hpp"
|
#include "icinga/checkresult.hpp"
|
||||||
#include "icinga/notificationresult.hpp"
|
|
||||||
#include "remote/endpoint.hpp"
|
#include "remote/endpoint.hpp"
|
||||||
#include "remote/messageorigin.hpp"
|
#include "remote/messageorigin.hpp"
|
||||||
#include "base/array.hpp"
|
#include "base/array.hpp"
|
||||||
@ -83,8 +82,6 @@ public:
|
|||||||
|
|
||||||
Endpoint::Ptr GetCommandEndpoint() const;
|
Endpoint::Ptr GetCommandEndpoint() const;
|
||||||
|
|
||||||
void ProcessNotificationResult(const NotificationResult::Ptr& nr, const MessageOrigin::Ptr& origin = nullptr);
|
|
||||||
|
|
||||||
// Logging, etc.
|
// Logging, etc.
|
||||||
static String NotificationTypeToString(NotificationType type);
|
static String NotificationTypeToString(NotificationType type);
|
||||||
// Compat, used for notifications, etc.
|
// Compat, used for notifications, etc.
|
||||||
@ -95,7 +92,6 @@ public:
|
|||||||
static String NotificationHostStateToString(HostState state);
|
static String NotificationHostStateToString(HostState state);
|
||||||
|
|
||||||
static boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> OnNextNotificationChanged;
|
static boost::signals2::signal<void (const Notification::Ptr&, const MessageOrigin::Ptr&)> OnNextNotificationChanged;
|
||||||
static boost::signals2::signal<void (const Notification::Ptr&, const NotificationResult::Ptr&, const MessageOrigin::Ptr&)> OnNewNotificationResult;
|
|
||||||
|
|
||||||
void Validate(int types, const ValidationUtils& utils) override;
|
void Validate(int types, const ValidationUtils& utils) override;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
#include "icinga/customvarobject.hpp"
|
#include "icinga/customvarobject.hpp"
|
||||||
#include "icinga/notificationresult.hpp"
|
|
||||||
#include "base/array.hpp"
|
|
||||||
#impl_include "icinga/notificationcommand.hpp"
|
#impl_include "icinga/notificationcommand.hpp"
|
||||||
#impl_include "icinga/service.hpp"
|
#impl_include "icinga/service.hpp"
|
||||||
|
|
||||||
@ -18,7 +16,6 @@ public:
|
|||||||
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
|
||||||
virtual Dictionary::Ptr ParseName(const String& name) const;
|
virtual Dictionary::Ptr ParseName(const String& name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
class Notification : CustomVarObject < NotificationNameComposer
|
class Notification : CustomVarObject < NotificationNameComposer
|
||||||
@ -88,7 +85,6 @@ class Notification : CustomVarObject < NotificationNameComposer
|
|||||||
[state] Timestamp next_notification;
|
[state] Timestamp next_notification;
|
||||||
[state] int notification_number;
|
[state] int notification_number;
|
||||||
[state] Timestamp last_problem_notification;
|
[state] Timestamp last_problem_notification;
|
||||||
[state] NotificationResult::Ptr last_notification_result;
|
|
||||||
|
|
||||||
[config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
|
[config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
|
||||||
navigate {{{
|
navigate {{{
|
||||||
|
@ -8,15 +8,14 @@ using namespace icinga;
|
|||||||
REGISTER_TYPE(NotificationCommand);
|
REGISTER_TYPE(NotificationCommand);
|
||||||
|
|
||||||
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
||||||
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
|
||||||
const NotificationType& type, const String& author, const String& comment,
|
const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
return GetExecute()->Invoke({
|
return GetExecute()->Invoke({
|
||||||
notification,
|
notification,
|
||||||
user,
|
user,
|
||||||
cr,
|
cr,
|
||||||
nr,
|
|
||||||
type,
|
type,
|
||||||
author,
|
author,
|
||||||
comment,
|
comment,
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
DECLARE_OBJECTNAME(NotificationCommand);
|
DECLARE_OBJECTNAME(NotificationCommand);
|
||||||
|
|
||||||
virtual Dictionary::Ptr Execute(const intrusive_ptr<Notification>& notification,
|
virtual Dictionary::Ptr Execute(const intrusive_ptr<Notification>& notification,
|
||||||
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
|
||||||
const NotificationType& type, const String& author, const String& comment,
|
const String& author, const String& comment,
|
||||||
const Dictionary::Ptr& resolvedMacros = nullptr,
|
const Dictionary::Ptr& resolvedMacros = nullptr,
|
||||||
bool useResolvedMacros = false);
|
bool useResolvedMacros = false);
|
||||||
};
|
};
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
/* 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();
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/* 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<NotificationResult>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DECLARE_OBJECT(NotificationResult);
|
|
||||||
|
|
||||||
double CalculateExecutionTime() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* NOTIFICATIONRESULT_H */
|
|
@ -1,24 +0,0 @@
|
|||||||
/* 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -15,12 +15,12 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_FUNCTION_NONCONST(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc, "notification:user:cr:nr:itype:author:comment:resolvedMacros:useResolvedMacros");
|
REGISTER_FUNCTION_NONCONST(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc, "notification:user:cr:itype:author:comment:resolvedMacros:useResolvedMacros");
|
||||||
|
|
||||||
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
|
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
|
||||||
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
|
||||||
int itype, const String& author, const String& comment,
|
const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
|
bool useResolvedMacros)
|
||||||
{
|
{
|
||||||
REQUIRE_NOT_NULL(notification);
|
REQUIRE_NOT_NULL(notification);
|
||||||
REQUIRE_NOT_NULL(user);
|
REQUIRE_NOT_NULL(user);
|
||||||
@ -55,28 +55,16 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
|
|||||||
|
|
||||||
PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers,
|
PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers,
|
||||||
resolvedMacros, useResolvedMacros, timeout,
|
resolvedMacros, useResolvedMacros, timeout,
|
||||||
std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, notification, nr, _1, _2));
|
std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable,
|
void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& commandLine, const ProcessResult& pr)
|
||||||
const Notification::Ptr& notification, const NotificationResult::Ptr& nr, const Value& commandLine, const ProcessResult& pr)
|
|
||||||
{
|
{
|
||||||
if (pr.ExitStatus != 0) {
|
if (pr.ExitStatus != 0) {
|
||||||
Process::Arguments parguments = Process::PrepareCommand(commandLine);
|
Process::Arguments parguments = Process::PrepareCommand(commandLine);
|
||||||
Log(LogWarning, "PluginNotificationTask")
|
Log(LogWarning, "PluginNotificationTask")
|
||||||
<< "Notification command for checkable '" << checkable->GetName()
|
<< "Notification command for object '" << checkable->GetName() << "' (PID: " << pr.PID
|
||||||
<< "' and notification '" << notification->GetName() << "' (PID: " << pr.PID
|
|
||||||
<< ", arguments: " << Process::PrettyPrintArguments(parguments) << ") terminated with exit code "
|
<< ", arguments: " << Process::PrettyPrintArguments(parguments) << ") terminated with exit code "
|
||||||
<< pr.ExitStatus << ", output: " << pr.Output;
|
<< 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);
|
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,14 @@ class PluginNotificationTask
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void ScriptFunc(const Notification::Ptr& notification,
|
static void ScriptFunc(const Notification::Ptr& notification,
|
||||||
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
|
||||||
int itype, const String& author, const String& comment,
|
const String& author, const String& comment,
|
||||||
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginNotificationTask();
|
PluginNotificationTask();
|
||||||
|
|
||||||
static void ProcessFinishedHandler(const Checkable::Ptr& checkable,
|
static void ProcessFinishedHandler(const Checkable::Ptr& checkable,
|
||||||
const Notification::Ptr& notification, const NotificationResult::Ptr& nr,
|
|
||||||
const Value& commandLine, const ProcessResult& pr);
|
const Value& commandLine, const ProcessResult& pr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void GelfWriter::Resume()
|
|||||||
|
|
||||||
/* Register event handlers. */
|
/* Register event handlers. */
|
||||||
Checkable::OnNewCheckResult.connect(std::bind(&GelfWriter::CheckResultHandler, this, _1, _2));
|
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, _9));
|
Checkable::OnNotificationSentToUser.connect(std::bind(&GelfWriter::NotificationToUserHandler, this, _1, _2, _3, _4, _5, _6, _7, _8));
|
||||||
Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
|
Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,18 +347,18 @@ void GelfWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notificationType, CheckResult::Ptr const& cr,
|
||||||
const String& author, const String& commentText, const String& commandName)
|
const String& author, const String& commentText, const String& commandName)
|
||||||
{
|
{
|
||||||
if (IsPaused())
|
if (IsPaused())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_WorkQueue.Enqueue(std::bind(&GelfWriter::NotificationToUserHandlerInternal, this,
|
m_WorkQueue.Enqueue(std::bind(&GelfWriter::NotificationToUserHandlerInternal, this,
|
||||||
notification, checkable, user, notificationType, cr, nr, author, commentText, commandName));
|
notification, checkable, user, notificationType, cr, author, commentText, commandName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GelfWriter::NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
void GelfWriter::NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notificationType, CheckResult::Ptr const& cr,
|
||||||
const String& author, const String& commentText, const String& commandName)
|
const String& author, const String& commentText, const String& commandName)
|
||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
@ -41,10 +41,10 @@ private:
|
|||||||
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
||||||
void CheckResultHandlerInternal(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,
|
void NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr,
|
||||||
const String& author, const String& commentText, const String& commandName);
|
const String& author, const String& commentText, const String& commandName);
|
||||||
void NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
void NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
|
||||||
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
|
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr,
|
||||||
const String& author, const String& comment_text, const String& command_name);
|
const String& author, const String& comment_text, const String& command_name);
|
||||||
void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
||||||
void StateChangeHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
void StateChangeHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user