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");
int missed = (Utility::GetTime() - lastCheck) / service->GetCheckInterval() - 1;
if (missed > 0) {
if (missed > 0 && !service->GetFirstCheck()) {
missedChecks += missed;
missedServices++;
}
}
service->SetFirstCheck(false);
Logger::Write(LogDebug, "checker", "Executing service check for '" + service->GetName() + "'");
m_PendingServices.insert(service);

View File

@ -34,6 +34,7 @@ static AttributeDescription serviceAttributes[] = {
{ "checkers", Attribute_Config },
{ "scheduling_offset", Attribute_Transient },
{ "first_check", Attribute_Transient },
{ "next_check", Attribute_Replicated },
{ "checker", Attribute_Replicated },
{ "check_attempt", Attribute_Replicated },
@ -225,6 +226,22 @@ long Service::GetSchedulingOffset(void)
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)
{
Set("next_check", nextCheck);

View File

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