Skip to content

Commit 206d7cd

Browse files
authored
Merge pull request #10359 from Icinga/do-not-publish-useless-stats
IcingaDB: Don't publish useless data to Redis
2 parents 35520b5 + 6ca0611 commit 206d7cd

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

lib/icingadb/icingadb-stats.cpp

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,15 @@ using namespace icinga;
1212

1313
Dictionary::Ptr IcingaDB::GetStats()
1414
{
15-
Dictionary::Ptr stats = new Dictionary();
16-
17-
//TODO: Figure out if more stats can be useful here.
18-
Namespace::Ptr statsFunctions = ScriptGlobal::Get("StatsFunctions", &Empty);
19-
20-
if (!statsFunctions)
21-
Dictionary::Ptr();
22-
23-
ObjectLock olock(statsFunctions);
24-
25-
for (auto& kv : statsFunctions)
26-
{
27-
Function::Ptr func = kv.second.Val;
28-
29-
if (!func)
30-
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid status function name."));
31-
32-
Dictionary::Ptr status = new Dictionary();
33-
Array::Ptr perfdata = new Array();
34-
func->Invoke({ status, perfdata });
35-
36-
stats->Set(kv.first, new Dictionary({
37-
{ "status", status },
38-
{ "perfdata", Serialize(perfdata, FAState) }
39-
}));
40-
}
41-
42-
typedef Dictionary::Ptr DP;
43-
DP app = DP(DP(DP(stats->Get("IcingaApplication"))->Get("status"))->Get("icingaapplication"))->Get("app");
15+
Dictionary::Ptr status = new Dictionary();
16+
IcingaApplication::StatsFunc(status, nullptr);
4417

18+
Dictionary::Ptr app(Dictionary::Ptr(status->Get("icingaapplication"))->Get("app"));
4519
app->Set("program_start", TimestampToMilliseconds(Application::GetStartTime()));
4620

47-
auto localEndpoint (Endpoint::GetLocalEndpoint());
48-
if (localEndpoint) {
21+
if (auto localEndpoint(Endpoint::GetLocalEndpoint()); localEndpoint) {
4922
app->Set("endpoint_id", GetObjectIdentifier(localEndpoint));
5023
}
5124

52-
return stats;
25+
return new Dictionary{{ "IcingaApplication", new Dictionary{{"status", status}}}};
5326
}

lib/icingadb/icingadb.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class IcingaDB : public ObjectImpl<IcingaDB>
143143
Dictionary::Ptr SerializeState(const Checkable::Ptr& checkable);
144144

145145
/* Stats */
146-
Dictionary::Ptr GetStats();
146+
static Dictionary::Ptr GetStats();
147147

148148
/* utilities */
149149
static String FormatCheckSumBinary(const String& str);

0 commit comments

Comments
 (0)