From 4f39e10a052151fd9ee4babe76ac01d34fc8ae68 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 3 Sep 2012 12:36:35 +0200 Subject: [PATCH] Log missed checks. --- components/checker/checkercomponent.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index 648373735..2a60ef5e4 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -58,6 +58,8 @@ void CheckerComponent::CheckTimerHandler(void) double now = Utility::GetTime(); long tasks = 0; + int missedServices = 0, missedChecks = 0; + while (!m_IdleServices.empty()) { typedef nth_index::type CheckTimeView; CheckTimeView& idx = boost::get<1>(m_IdleServices); @@ -70,6 +72,18 @@ void CheckerComponent::CheckTimerHandler(void) idx.erase(it); + Dictionary::Ptr cr = service->GetLastCheckResult(); + + if (cr) { + double lastCheck = cr->Get("execution_end"); + int missed = (Utility::GetTime() - lastCheck) / service->GetCheckInterval(); + + if (missed > 0) { + missedChecks += missed; + missedServices++; + } + } + Logger::Write(LogDebug, "checker", "Executing service check for '" + service->GetName() + "'"); m_PendingServices.insert(service); @@ -87,6 +101,12 @@ void CheckerComponent::CheckTimerHandler(void) Logger::Write(LogDebug, "checker", "CheckTimerHandler: past loop."); + if (missedServices > 0) { + stringstream msgbuf; + msgbuf << "Missed " << missedChecks << " checks for " << missedServices << " services";; + Logger::Write(LogWarning, "checker", msgbuf.str()); + } + stringstream msgbuf; msgbuf << "CheckTimerHandler: created " << tasks << " tasks"; Logger::Write(LogInformation, "checker", msgbuf.str());