From a323bb3c1ce70d2248cebe8ee33d775a934a23bb Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 20 Nov 2024 14:58:44 +0100 Subject: [PATCH] IcingaCheckTask: Add available I/O cpu semaphores as a perfdata --- lib/base/io-engine.cpp | 5 +++++ lib/base/io-engine.hpp | 2 ++ lib/methods/icingachecktask.cpp | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/base/io-engine.cpp b/lib/base/io-engine.cpp index 26125feb310..82a2035ca66 100644 --- a/lib/base/io-engine.cpp +++ b/lib/base/io-engine.cpp @@ -85,6 +85,11 @@ boost::asio::io_context& IoEngine::GetIoContext() return m_IoContext; } +int_fast32_t IoEngine::GetCpuSemaphore() const +{ + return m_CpuBoundSemaphore; +} + IoEngine::IoEngine() : m_IoContext(), m_KeepAlive(boost::asio::make_work_guard(m_IoContext)), m_Threads(decltype(m_Threads)::size_type(Configuration::Concurrency * 2u)), m_AlreadyExpiredTimer(m_IoContext) { m_AlreadyExpiredTimer.expires_at(boost::posix_time::neg_infin); diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index 326f04fdc47..e54098949a1 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -83,6 +83,8 @@ class IoEngine boost::asio::io_context& GetIoContext(); + int_fast32_t GetCpuSemaphore() const; + static inline size_t GetCoroutineStackSize() { #ifdef _WIN32 // Increase the stack size for Windows coroutines to prevent exception corruption. diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index d3eae1f33f2..1dd689b9187 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -9,7 +9,7 @@ #include "icinga/checkable.hpp" #include "remote/apilistener.hpp" #include "base/application.hpp" -#include "base/objectlock.hpp" +#include "base/io-engine.hpp" #include "base/utility.hpp" #include "base/perfdatavalue.hpp" #include "base/function.hpp" @@ -81,6 +81,8 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes perfdata->Add(new PerfdataValue("current_concurrent_checks", Checkable::CurrentConcurrentChecks.load())); perfdata->Add(new PerfdataValue("remote_check_queue", ClusterEvents::GetCheckRequestQueueSize())); + perfdata->Add(new PerfdataValue("num_free_io_cpu_slots", IoEngine::Get().GetCpuSemaphore())); + CheckableCheckStatistics scs = CIB::CalculateServiceCheckStats(); perfdata->Add(new PerfdataValue("min_latency", scs.min_latency));