Fix 100% CPU usage issue and incorrect pending checks accounting in CheckerComponent::CheckThreadProc

fixes #11806
This commit is contained in:
Gunnar Beutner 2016-05-18 14:30:36 +02:00
parent bb69540b32
commit b99b373b6f
2 changed files with 7 additions and 3 deletions

View File

@ -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));

View File

@ -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)