mirror of https://github.com/Icinga/icinga2.git
Icinga DB: include amount of history kept in memory in /v1/status
This commit is contained in:
parent
ad0fe764f7
commit
50fee6aeb9
|
@ -7,6 +7,8 @@
|
||||||
#include "remote/eventqueue.hpp"
|
#include "remote/eventqueue.hpp"
|
||||||
#include "base/configuration.hpp"
|
#include "base/configuration.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
|
#include "base/perfdatavalue.hpp"
|
||||||
|
#include "base/statsfunction.hpp"
|
||||||
#include "base/tlsutility.hpp"
|
#include "base/tlsutility.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "icinga/checkable.hpp"
|
#include "icinga/checkable.hpp"
|
||||||
|
@ -27,6 +29,8 @@ std::once_flag IcingaDB::m_EnvironmentIdOnce;
|
||||||
|
|
||||||
REGISTER_TYPE(IcingaDB);
|
REGISTER_TYPE(IcingaDB);
|
||||||
|
|
||||||
|
REGISTER_STATSFUNCTION(IcingaDB, &IcingaDB::StatsFunc);
|
||||||
|
|
||||||
IcingaDB::IcingaDB()
|
IcingaDB::IcingaDB()
|
||||||
: m_Rcon(nullptr)
|
: m_Rcon(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +42,28 @@ IcingaDB::IcingaDB()
|
||||||
m_PrefixConfigCheckSum = "icinga:checksum:";
|
m_PrefixConfigCheckSum = "icinga:checksum:";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Feature stats interface
|
||||||
|
*
|
||||||
|
* @param status Key value pairs for feature stats
|
||||||
|
*/
|
||||||
|
void IcingaDB::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
||||||
|
{
|
||||||
|
DictionaryData nodes;
|
||||||
|
|
||||||
|
for (auto& icingadb : ConfigType::GetObjectsByType<IcingaDB>()) {
|
||||||
|
auto historyBufferItems (icingadb->m_HistoryBulker.Size());
|
||||||
|
|
||||||
|
nodes.emplace_back(icingadb->GetName(), new Dictionary({
|
||||||
|
{ "history_buffer_items", historyBufferItems }
|
||||||
|
}));
|
||||||
|
|
||||||
|
perfdata->Add(new PerfdataValue("icingadb_" + icingadb->GetName() + "_history_buffer_items", historyBufferItems));
|
||||||
|
}
|
||||||
|
|
||||||
|
status->Set("icingadb", new Dictionary(std::move(nodes)));
|
||||||
|
}
|
||||||
|
|
||||||
void IcingaDB::Validate(int types, const ValidationUtils& utils)
|
void IcingaDB::Validate(int types, const ValidationUtils& utils)
|
||||||
{
|
{
|
||||||
ObjectImpl<IcingaDB>::Validate(types, utils);
|
ObjectImpl<IcingaDB>::Validate(types, utils);
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
IcingaDB();
|
IcingaDB();
|
||||||
|
|
||||||
static void ConfigStaticInitialize();
|
static void ConfigStaticInitialize();
|
||||||
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
||||||
|
|
||||||
void Validate(int types, const ValidationUtils& utils) override;
|
void Validate(int types, const ValidationUtils& utils) override;
|
||||||
virtual void Start(bool runtimeCreated) override;
|
virtual void Start(bool runtimeCreated) override;
|
||||||
|
|
Loading…
Reference in New Issue