]> granicus.if.org Git - icinga2/commitdiff
Wait until the next check result if it's expected to arrive soon before re-sending...
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Wed, 3 Jul 2019 13:12:58 +0000 (15:12 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 9 Jul 2019 14:38:50 +0000 (16:38 +0200)
refs #5919

lib/icinga/checkable-notification.cpp

index c00c323704f3d6dea66749e3167f302fc819dfc4..a6475b87f0c7483d31388653a9f4cab004b1c33c 100644 (file)
@@ -136,6 +136,26 @@ static void FireSuppressedNotifications(Checkable* checkable)
                                        still_suppressed = checkable->IsInDowntime();
                                }
 
+                               if (!still_suppressed && checkable->GetEnableActiveChecks()) {
+                                       /* If e.g. the downtime just ended, but the service is still not ok, we would re-send the stashed problem notification.
+                                        * But if the next check result recovers the service soon, we would send a recovery notification soon after the problem one.
+                                        * This is not desired, especially for lots of services at once.
+                                        * Because of that if there's likely to be a check result soon,
+                                        * we delay the re-sending of the stashed notification until the next check.
+                                        * That check either doesn't change anything and we finally re-send the stashed problem notification
+                                        * or recovers the service and we drop the stashed notification. */
+
+                                       /* One minute unless the check interval is too short so the next check will always run during the next minute. */
+                                       auto threshold (checkable->GetCheckInterval() - 10);
+
+                                       if (threshold > 60)
+                                               threshold = 60;
+                                       else if (threshold < 0)
+                                               threshold = 0;
+
+                                       still_suppressed = checkable->GetNextCheck() <= Utility::GetTime() + threshold;
+                               }
+
                                if (!still_suppressed) {
                                        Checkable::OnNotificationsRequested(checkable, type, cr, "", "", nullptr);