From: Gunnar Beutner Date: Wed, 18 May 2016 12:30:36 +0000 (+0200) Subject: Fix 100% CPU usage issue and incorrect pending checks accounting in CheckerComponent... X-Git-Tag: v2.4.10~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=232c299a7ad657e4590d8f6367f1bb37269e4555;p=icinga2 Fix 100% CPU usage issue and incorrect pending checks accounting in CheckerComponent::CheckThreadProc fixes #11806 --- diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index fb9d87188..bfb997fb6 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -121,7 +121,10 @@ void CheckerComponent::CheckThreadProc(void) double wait = checkable->GetNextCheck() - Utility::GetTime(); - if (wait > 0 || Checkable::GetPendingChecks() >= GetConcurrentChecks()) { + if (Checkable::GetPendingChecks() >= GetConcurrentChecks()) + wait = 0.5; + + if (wait > 0) { /* Wait for the next check. */ m_CV.timed_wait(lock, boost::posix_time::milliseconds(wait * 1000)); diff --git a/lib/methods/pluginchecktask.cpp b/lib/methods/pluginchecktask.cpp index c1b1942d9..d53e287f8 100644 --- a/lib/methods/pluginchecktask.cpp +++ b/lib/methods/pluginchecktask.cpp @@ -52,11 +52,12 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes resolvers.push_back(std::make_pair("command", commandObj)); resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance())); - Checkable::IncreasePendingChecks(); - PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers, resolvedMacros, useResolvedMacros, boost::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2)); + + if (!resolvedMacros || useResolvedMacros) + Checkable::IncreasePendingChecks(); } void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr)