From efc7f2cf8d49072083f636938fe89f8e30ffb417 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 14 Aug 2019 17:43:06 +0200 Subject: [PATCH] Correct current_concurrent_checks to actually running checks refs #7416 --- lib/icinga/checkable-check.cpp | 2 ++ lib/icinga/checkable.hpp | 4 ++++ lib/icinga/cib.cpp | 2 +- lib/methods/icingachecktask.cpp | 2 +- lib/methods/pluginchecktask.cpp | 5 ++++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 7b095353a..02bc8fc91 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -23,6 +23,8 @@ boost::signals2::signal Checkable::OnNotificationsRequested; boost::signals2::signal Checkable::OnNextCheckUpdated; +Atomic Checkable::CurrentConcurrentChecks (0); + boost::mutex Checkable::m_StatsMutex; int Checkable::m_PendingChecks = 0; boost::condition_variable Checkable::m_PendingChecksCV; diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index ee7212860..caddd63f4 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -3,6 +3,7 @@ #ifndef CHECKABLE_H #define CHECKABLE_H +#include "base/atomic.hpp" #include "base/timer.hpp" #include "icinga/i2-icinga.hpp" #include "icinga/checkable-ti.hpp" @@ -12,6 +13,7 @@ #include "icinga/downtime.hpp" #include "remote/endpoint.hpp" #include "remote/messageorigin.hpp" +#include namespace icinga { @@ -131,6 +133,8 @@ public: static boost::signals2::signal OnNextCheckUpdated; static boost::signals2::signal OnEventCommandExecuted; + static Atomic CurrentConcurrentChecks; + /* Downtimes */ int GetDowntimeDepth() const final; diff --git a/lib/icinga/cib.cpp b/lib/icinga/cib.cpp index 555079ec9..a48b85078 100644 --- a/lib/icinga/cib.cpp +++ b/lib/icinga/cib.cpp @@ -292,8 +292,8 @@ void CIB::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) { // Checker related stats status->Set("remote_check_queue", ClusterEvents::GetCheckRequestQueueSize()); - status->Set("current_concurrent_checks", Checkable::GetPendingChecks()); status->Set("current_pending_callbacks", Application::GetTP().GetPending()); + status->Set("current_concurrent_checks", Checkable::CurrentConcurrentChecks.load()); CheckableCheckStatistics scs = CalculateServiceCheckStats(); diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index e27acc2f1..59dfbdf78 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -76,7 +76,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes perfdata->Add(new PerfdataValue("passive_service_checks_15min", CIB::GetPassiveServiceChecksStatistics(60 * 15))); perfdata->Add(new PerfdataValue("current_pending_callbacks", Application::GetTP().GetPending())); - perfdata->Add(new PerfdataValue("current_concurrent_checks", Checkable::GetPendingChecks())); + perfdata->Add(new PerfdataValue("current_concurrent_checks", Checkable::CurrentConcurrentChecks.load())); perfdata->Add(new PerfdataValue("remote_check_queue", ClusterEvents::GetCheckRequestQueueSize())); CheckableCheckStatistics scs = CIB::CalculateServiceCheckStats(); diff --git a/lib/methods/pluginchecktask.cpp b/lib/methods/pluginchecktask.cpp index 15a46e758..212d7447c 100644 --- a/lib/methods/pluginchecktask.cpp +++ b/lib/methods/pluginchecktask.cpp @@ -44,12 +44,15 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes resolvers, resolvedMacros, useResolvedMacros, timeout, std::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2)); - if (!resolvedMacros || useResolvedMacros) + if (!resolvedMacros || useResolvedMacros) { + Checkable::CurrentConcurrentChecks.fetch_add(1); Checkable::IncreasePendingChecks(); + } } void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr) { + Checkable::CurrentConcurrentChecks.fetch_sub(1); Checkable::DecreasePendingChecks(); if (pr.ExitStatus > 3) {