| 75 | } |
| 76 | |
| 77 | static inline |
| 78 | void FireSuppressedNotifications(const Notification::Ptr& notification) |
| 79 | { |
| 80 | int suppressedTypes (notification->GetSuppressedNotifications()); |
| 81 | if (!suppressedTypes) |
| 82 | return; |
| 83 | |
| 84 | int subtract = 0; |
| 85 | auto checkable (notification->GetCheckable()); |
| 86 | |
| 87 | auto tp (notification->GetPeriod()); |
| 88 | |
| 89 | if ((!tp || tp->IsInside(Utility::GetTime())) && !checkable->IsLikelyToBeCheckedSoon()) { |
| 90 | for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) { |
| 91 | if (!(suppressedTypes & type) || checkable->NotificationReasonSuppressed(type)) { |
| 92 | continue; |
| 93 | } |
| 94 | |
| 95 | if (!checkable->NotificationReasonApplies(type)) { |
| 96 | subtract |= type; |
| 97 | continue; |
| 98 | } |
| 99 | |
| 100 | auto notificationName (notification->GetName()); |
| 101 | |
| 102 | Log(LogNotice, "NotificationComponent") |
| 103 | << "Attempting to re-send previously suppressed notification '" << notificationName << "'."; |
| 104 | |
| 105 | subtract |= type; |
| 106 | SubtractSuppressedNotificationTypes(notification, subtract); |
| 107 | subtract = 0; |
| 108 | |
| 109 | try { |
| 110 | notification->BeginExecuteNotification(type, checkable->GetLastCheckResult(), false, false); |
| 111 | } catch (const std::exception& ex) { |
| 112 | Log(LogWarning, "NotificationComponent") |
| 113 | << "Exception occurred during notification for object '" |
| 114 | << notificationName << "': " << DiagnosticInformation(ex, false); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (subtract) { |
| 120 | SubtractSuppressedNotificationTypes(notification, subtract); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Periodically sends notifications. |
no test coverage detected