Skip to content

Commit 663916c

Browse files
committed
Provide collected cluster stats via /v1/status
1 parent 8280a3b commit 663916c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/remote/statsreporter.cpp

Lines changed: 8 additions & 0 deletions
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"
@@ -38,6 +39,8 @@ using namespace icinga;
3839

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

42+
REGISTER_STATSFUNCTION(ClusterStats, &StatsReporter::StatsFunc);
43+
4144
StatsReporter StatsReporter::m_Instance;
4245

4346
StatsReporter::StatsReporter()
@@ -185,3 +188,8 @@ void StatsReporter::ClusterStatsHandler(const String& endpoint, const Dictionary
185188
boost::mutex::scoped_lock lock (m_Mutex);
186189
m_SecondaryStats[endpoint] = stats;
187190
}
191+
192+
void StatsReporter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
193+
{
194+
status->Set("cluster", m_Instance.GenerateStats());
195+
}

lib/remote/statsreporter.hpp

Lines changed: 2 additions & 0 deletions
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)