| 602 | } |
| 603 | |
| 604 | void 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 | |
| 640 | int icinga::ServiceStateToFilter(ServiceState state) |
| 641 | { |
no test coverage detected