mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-31 01:24:19 +02:00
Provide collected cluster stats via /v1/status
This commit is contained in:
parent
186b0bdff5
commit
78c26f055a
@ -24,6 +24,7 @@
|
||||
#include "base/function.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/scriptglobal.hpp"
|
||||
#include "base/statsfunction.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/value.hpp"
|
||||
#include "remote/apifunction.hpp"
|
||||
@ -38,6 +39,8 @@ using namespace icinga;
|
||||
|
||||
REGISTER_APIFUNCTION(ClusterStats, event, &StatsReporter::ClusterStatsAPIHandler);
|
||||
|
||||
REGISTER_STATSFUNCTION(ClusterStats, &StatsReporter::StatsFunc);
|
||||
|
||||
StatsReporter StatsReporter::m_Instance;
|
||||
|
||||
StatsReporter::StatsReporter()
|
||||
@ -185,3 +188,8 @@ void StatsReporter::ClusterStatsHandler(const String& endpoint, const Dictionary
|
||||
boost::mutex::scoped_lock lock (m_Mutex);
|
||||
m_SecondaryStats[endpoint] = stats;
|
||||
}
|
||||
|
||||
void StatsReporter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
||||
{
|
||||
status->Set("cluster", m_Instance.GenerateStats());
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef STATSREPORTER_H
|
||||
#define STATSREPORTER_H
|
||||
|
||||
#include "base/array.hpp"
|
||||
#include "base/dictionary.hpp"
|
||||
#include "base/string.hpp"
|
||||
#include "base/timer.hpp"
|
||||
@ -40,6 +41,7 @@ class StatsReporter
|
||||
{
|
||||
public:
|
||||
static Value ClusterStatsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
|
||||
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
||||
|
||||
private:
|
||||
StatsReporter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user