MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ExecuteNotificationHelper

Method ExecuteNotificationHelper

lib/icinga/notification.cpp:604–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604void Notification::ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, const String& author, const String& text)
605{
606 String notificationName = GetName();
607 String userName = user->GetName();
608 String checkableName = GetCheckable()->GetName();
609
610 NotificationCommand::Ptr command = GetCommand();
611
612 if (!command) {
613 Log(LogDebug, "Notification")
614 << "No command found for notification '" << notificationName << "'. Skipping execution.";
615 return;
616 }
617
618 String commandName = command->GetName();
619
620 try {
621 command->Execute(this, user, cr, type, author, text);
622
623 /* required by compatlogger */
624 Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, commandName, nullptr);
625
626 Log(LogInformation, "Notification")
627 << "Completed sending '" << NotificationTypeToString(type)
628 << "' notification '" << notificationName
629 << "' for checkable '" << checkableName
630 << "' and user '" << userName << "' using command '" << commandName << "'.";
631 } catch (const std::exception& ex) {
632 Log(LogWarning, "Notification")
633 << "Exception occurred during notification '" << notificationName
634 << "' for checkable '" << checkableName
635 << "' and user '" << userName << "' using command '" << commandName << "': "
636 << DiagnosticInformation(ex, false);
637 }
638}
639
640int icinga::ServiceStateToFilter(ServiceState state)
641{

Callers 1

Calls 3

LogClass · 0.85
GetNameMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected