Fix check behavior on restart

This patch changes the way checkresults are handled during a restart.

  1. Check results coming in during a shutdown are ignored.
  2. Upon start, checks which should have ran (next_check in the past),
  are re-scheduled within the first minute.

This new behavior means there will be no more "Unknown - Terminated"
checkresults during a restart and checks with high check_interval will
be run earlier if they were already scheduled to run. The downside is
that after Icinga2 was down for a while, there will be a lot of checks
within the first minute. Our max concurrent check should take care of
this though.
This commit is contained in:
Jean Flach 2018-04-10 15:50:45 +02:00
parent d784a2a899
commit 1a9c1591c0
2 changed files with 6 additions and 5 deletions

View File

@ -107,7 +107,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
m_CheckRunning = false;
}
if (!cr)
if (!cr || !IsActive())
return;
double now = Utility::GetTime();
@ -428,8 +428,6 @@ void Checkable::ExecuteCheck()
double scheduled_start = GetNextCheck();
double before_check = Utility::GetTime();
UpdateNextCheck();
bool reachable = IsReachable();
{

View File

@ -73,8 +73,11 @@ void Checkable::Start(bool runtimeCreated)
{
double now = Utility::GetTime();
if (GetNextCheck() < now + 300)
UpdateNextCheck();
if (GetNextCheck() < now + 60) {
double delta = std::min(GetCheckInterval(), 60.0);
delta *= (double)std::rand() / RAND_MAX;
SetNextCheck(now + delta);
}
ObjectImpl<Checkable>::Start(runtimeCreated);
}