mirror of
https://github.com/Icinga/icinga2.git
synced 2026-02-03 20:40:17 -05:00
Provide collected cluster stats via /v1/status
This commit is contained in:
parent
9fda7ef503
commit
6ff45b1626
2 changed files with 10 additions and 0 deletions
|
|
@ -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…
Reference in a new issue