Skip to content

Commit 30016a6

Browse files
committed
Provide collected cluster stats via /v1/status
1 parent 1b21e4b commit 30016a6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/remote/statsreporter.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "base/function.hpp"
2525
#include "base/objectlock.hpp"
2626
#include "base/scriptglobal.hpp"
27+
#include "base/statsfunction.hpp"
2728
#include "base/utility.hpp"
2829
#include "base/value.hpp"
2930
#include "remote/apifunction.hpp"
@@ -39,6 +40,8 @@ using namespace icinga;
3940

4041
REGISTER_APIFUNCTION(ClusterStats, event, &StatsReporter::ClusterStatsAPIHandler);
4142

43+
REGISTER_STATSFUNCTION(ClusterStats, &StatsReporter::StatsFunc);
44+
4245
StatsReporter StatsReporter::m_Instance;
4346

4447
StatsReporter::StatsReporter()
@@ -182,3 +185,8 @@ void StatsReporter::ClusterStatsHandler(const String& endpoint, const Dictionary
182185
boost::mutex::scoped_lock lock (m_Mutex);
183186
m_SecondaryStats[endpoint] = stats;
184187
}
188+
189+
void StatsReporter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
190+
{
191+
status->Set("cluster", m_Instance.GenerateStats());
192+
}

lib/remote/statsreporter.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef STATSREPORTER_H
2121
#define STATSREPORTER_H
2222

23+
#include "base/array.hpp"
2324
#include "base/dictionary.hpp"
2425
#include "base/string.hpp"
2526
#include "base/timer.hpp"
@@ -40,6 +41,7 @@ class StatsReporter
4041
{
4142
public:
4243
static Value ClusterStatsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
44+
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
4345

4446
private:
4547
StatsReporter();

0 commit comments

Comments
 (0)