Skip to content

Commit

Permalink
Fix 100% CPU usage issue and incorrect pending checks accounting in C…
Browse files Browse the repository at this point in the history
…heckerComponent::CheckThreadProc

fixes #11806
  • Loading branch information
gunnarbeutner committed May 19, 2016
1 parent 597d1c3 commit 232c299
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/checker/checkercomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
5 changes: 3 additions & 2 deletions lib/methods/pluginchecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 232c299

Please sign in to comment.