mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8436 from Icinga/bugfix/children-recover-too-late
On recovery: re-check children
This commit is contained in:
commit
915a3c3001
|
@ -242,6 +242,20 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
||||||
OnReachabilityChanged(this, cr, children, origin);
|
OnReachabilityChanged(this, cr, children, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recovery) {
|
||||||
|
for (auto& child : children) {
|
||||||
|
if (child->GetProblem() && child->GetEnableActiveChecks()) {
|
||||||
|
auto nextCheck (now + Utility::Random() % 60);
|
||||||
|
|
||||||
|
ObjectLock oLock (child);
|
||||||
|
|
||||||
|
if (nextCheck < child->GetNextCheck()) {
|
||||||
|
child->SetNextCheck(nextCheck);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!reachable)
|
if (!reachable)
|
||||||
SetLastStateUnreachable(cr->GetExecutionEnd());
|
SetLastStateUnreachable(cr->GetExecutionEnd());
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "base/exception.hpp"
|
#include "base/exception.hpp"
|
||||||
#include "base/context.hpp"
|
#include "base/context.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
|
#include "base/lazy-init.hpp"
|
||||||
#include "remote/apilistener.hpp"
|
#include "remote/apilistener.hpp"
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
@ -145,35 +146,58 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
||||||
|
|
||||||
int subtract = 0;
|
int subtract = 0;
|
||||||
|
|
||||||
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
|
{
|
||||||
if (suppressed_types & type) {
|
LazyInit<bool> wasLastParentRecoveryRecent ([&checkable]() {
|
||||||
bool still_applies = checkable->NotificationReasonApplies(type);
|
auto cr (checkable->GetLastCheckResult());
|
||||||
|
|
||||||
if (still_applies) {
|
if (!cr) {
|
||||||
bool still_suppressed;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
auto threshold (cr->GetExecutionStart());
|
||||||
case NotificationProblem:
|
|
||||||
/* Fall through. */
|
for (auto& dep : checkable->GetDependencies()) {
|
||||||
case NotificationRecovery:
|
auto parent (dep->GetParent());
|
||||||
still_suppressed = !checkable->IsReachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsAcknowledged();
|
ObjectLock oLock (parent);
|
||||||
break;
|
|
||||||
case NotificationFlappingStart:
|
if (!parent->GetProblem() && parent->GetLastStateChange() >= threshold) {
|
||||||
/* Fall through. */
|
return true;
|
||||||
case NotificationFlappingEnd:
|
|
||||||
still_suppressed = checkable->IsInDowntime();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!still_suppressed && !checkable->IsLikelyToBeCheckedSoon()) {
|
return false;
|
||||||
Checkable::OnNotificationsRequested(checkable, type, checkable->GetLastCheckResult(), "", "", nullptr);
|
});
|
||||||
|
|
||||||
|
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
|
||||||
|
if (suppressed_types & type) {
|
||||||
|
bool still_applies = checkable->NotificationReasonApplies(type);
|
||||||
|
|
||||||
|
if (still_applies) {
|
||||||
|
bool still_suppressed;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case NotificationProblem:
|
||||||
|
/* Fall through. */
|
||||||
|
case NotificationRecovery:
|
||||||
|
still_suppressed = !checkable->IsReachable(DependencyNotification) || checkable->IsInDowntime() || checkable->IsAcknowledged();
|
||||||
|
break;
|
||||||
|
case NotificationFlappingStart:
|
||||||
|
/* Fall through. */
|
||||||
|
case NotificationFlappingEnd:
|
||||||
|
still_suppressed = checkable->IsInDowntime();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!still_suppressed && !checkable->IsLikelyToBeCheckedSoon() && !wasLastParentRecoveryRecent.Get()) {
|
||||||
|
Checkable::OnNotificationsRequested(checkable, type, checkable->GetLastCheckResult(), "", "", nullptr);
|
||||||
|
|
||||||
|
subtract |= type;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
subtract |= type;
|
subtract |= type;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
subtract |= type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue