From 86a8fbb1819141662fcbb2d3f845dbabc0218a47 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 3 Jul 2019 15:12:58 +0200 Subject: [PATCH] Wait until the next check result if it's expected to arrive soon before re-sending a suppressed notification refs #5919 --- lib/icinga/checkable-notification.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/icinga/checkable-notification.cpp b/lib/icinga/checkable-notification.cpp index c00c323704f..a6475b87f0c 100644 --- a/lib/icinga/checkable-notification.cpp +++ b/lib/icinga/checkable-notification.cpp @@ -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);