]> granicus.if.org Git - icinga2/commitdiff
Fix 100% CPU usage issue and incorrect pending checks accounting in CheckerComponent...
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 18 May 2016 12:30:36 +0000 (14:30 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 19 May 2016 11:15:00 +0000 (13:15 +0200)
fixes #11806

lib/checker/checkercomponent.cpp
lib/methods/pluginchecktask.cpp

index fb9d87188fbd3a114309857f77d00cdaaff22d16..bfb997fb6b2f8188ba684949cfecb274106c8805 100644 (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));
 
index c1b1942d9b60bc7d44390cff8290a6961d7b101f..d53e287f84628cb05ac0ea06ed18d1270ea5daeb 100644 (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)