Checker: don't report missed checks after restarting Icinga

Fixes #3253
This commit is contained in:
Gunnar Beutner 2013-01-23 15:25:00 +01:00
parent 1be64b9290
commit e334f126c8
3 changed files with 24 additions and 2 deletions

View File

@ -90,12 +90,14 @@ void CheckerComponent::CheckTimerHandler(void)
double lastCheck = cr->Get("execution_end"); double lastCheck = cr->Get("execution_end");
int missed = (Utility::GetTime() - lastCheck) / service->GetCheckInterval() - 1; int missed = (Utility::GetTime() - lastCheck) / service->GetCheckInterval() - 1;
if (missed > 0) { if (missed > 0 && !service->GetFirstCheck()) {
missedChecks += missed; missedChecks += missed;
missedServices++; missedServices++;
} }
} }
service->SetFirstCheck(false);
Logger::Write(LogDebug, "checker", "Executing service check for '" + service->GetName() + "'"); Logger::Write(LogDebug, "checker", "Executing service check for '" + service->GetName() + "'");
m_PendingServices.insert(service); m_PendingServices.insert(service);

View File

@ -34,6 +34,7 @@ static AttributeDescription serviceAttributes[] = {
{ "checkers", Attribute_Config }, { "checkers", Attribute_Config },
{ "scheduling_offset", Attribute_Transient }, { "scheduling_offset", Attribute_Transient },
{ "first_check", Attribute_Transient },
{ "next_check", Attribute_Replicated }, { "next_check", Attribute_Replicated },
{ "checker", Attribute_Replicated }, { "checker", Attribute_Replicated },
{ "check_attempt", Attribute_Replicated }, { "check_attempt", Attribute_Replicated },
@ -225,6 +226,22 @@ long Service::GetSchedulingOffset(void)
return value; return value;
} }
void Service::SetFirstCheck(bool first)
{
Set("first_check", first ? 1 : 0);
}
bool Service::GetFirstCheck(void) const
{
Value value = Get("first_check");
if (value.IsEmpty())
return true;
return static_cast<long>(value);
}
void Service::SetNextCheck(double nextCheck) void Service::SetNextCheck(double nextCheck)
{ {
Set("next_check", nextCheck); Set("next_check", nextCheck);

View File

@ -101,6 +101,9 @@ public:
long GetSchedulingOffset(void); long GetSchedulingOffset(void);
void SetSchedulingOffset(long offset); void SetSchedulingOffset(long offset);
void SetFirstCheck(bool first);
bool GetFirstCheck(void) const;
void SetNextCheck(double nextCheck); void SetNextCheck(double nextCheck);
double GetNextCheck(void); double GetNextCheck(void);
void UpdateNextCheck(void); void UpdateNextCheck(void);