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

Function FireSuppressedNotifications

lib/notification/notificationcomponent.cpp:77–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static inline
78void 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.

Callers 1

Calls 11

LogClass · 0.85
IsInsideMethod · 0.80
GetCheckableMethod · 0.45
GetPeriodMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected