mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Add all stats similar to /v1/status
This commit is contained in:
parent
d7f6d7994b
commit
fae5b88e48
@ -28,21 +28,33 @@ using namespace icinga;
|
|||||||
|
|
||||||
Dictionary::Ptr RedisWriter::GetStats()
|
Dictionary::Ptr RedisWriter::GetStats()
|
||||||
{
|
{
|
||||||
|
Dictionary::Ptr stats = new Dictionary();
|
||||||
|
|
||||||
//TODO: Figure out if more stats can be useful here.
|
//TODO: Figure out if more stats can be useful here.
|
||||||
Dictionary::Ptr statsFunctions = ScriptGlobal::Get("StatsFunctions", &Empty);
|
Dictionary::Ptr statsFunctions = ScriptGlobal::Get("StatsFunctions", &Empty);
|
||||||
|
|
||||||
if (!statsFunctions)
|
if (!statsFunctions)
|
||||||
Dictionary::Ptr();
|
Dictionary::Ptr();
|
||||||
|
|
||||||
Function::Ptr func = statsFunctions->Get("CIB");
|
ObjectLock olock(statsFunctions);
|
||||||
|
|
||||||
Dictionary::Ptr status = new Dictionary();
|
for (const Dictionary::Pair& kv : statsFunctions)
|
||||||
Array::Ptr perfdata = new Array();
|
{
|
||||||
|
Function::Ptr func = kv.second;
|
||||||
|
|
||||||
func->Invoke({ status, perfdata });
|
if (!func)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid status function name."));
|
||||||
|
|
||||||
// String jsonStats = JsonEncode(status);
|
Dictionary::Ptr status = new Dictionary();
|
||||||
|
Array::Ptr perfdata = new Array();
|
||||||
|
func->Invoke({ status, perfdata });
|
||||||
|
|
||||||
return status;
|
stats->Set(kv.first, new Dictionary({
|
||||||
|
{ "status", status },
|
||||||
|
{ "perfdata", Serialize(perfdata, FAState) }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user