mirror of https://github.com/Icinga/icinga2.git
Don't fire suppressed notifications if last parent recovery >= last check result
This commit is contained in:
parent
338d0aaa8c
commit
668bf06424
|
@ -10,6 +10,7 @@
|
|||
#include "base/exception.hpp"
|
||||
#include "base/context.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/lazy-init.hpp"
|
||||
#include "remote/apilistener.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
@ -145,6 +146,28 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
|||
|
||||
int subtract = 0;
|
||||
|
||||
{
|
||||
LazyInit<bool> wasLastParentRecoveryRecent ([&checkable]() {
|
||||
auto cr (checkable->GetLastCheckResult());
|
||||
|
||||
if (!cr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto threshold (cr->GetExecutionStart());
|
||||
|
||||
for (auto& dep : checkable->GetDependencies()) {
|
||||
auto parent (dep->GetParent());
|
||||
ObjectLock oLock (parent);
|
||||
|
||||
if (!parent->GetProblem() && parent->GetLastStateChange() >= threshold) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
|
||||
if (suppressed_types & type) {
|
||||
bool still_applies = checkable->NotificationReasonApplies(type);
|
||||
|
@ -167,7 +190,7 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!still_suppressed && !checkable->IsLikelyToBeCheckedSoon()) {
|
||||
if (!still_suppressed && !checkable->IsLikelyToBeCheckedSoon() && !wasLastParentRecoveryRecent.Get()) {
|
||||
Checkable::OnNotificationsRequested(checkable, type, checkable->GetLastCheckResult(), "", "", nullptr);
|
||||
|
||||
subtract |= type;
|
||||
|
@ -177,6 +200,7 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (subtract) {
|
||||
ObjectLock olock (checkable);
|
||||
|
|
Loading…
Reference in New Issue