Skip to content

Commit

Permalink
IcingaCheckTask: Add available I/O cpu semaphores as a perfdata
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Nov 20, 2024
1 parent 3218908 commit 729bafd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/base/io-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lib/base/io-engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion lib/methods/icingachecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 729bafd

Please sign in to comment.