@@ -12,42 +12,15 @@ using namespace icinga;
1212
1313Dictionary::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}
0 commit comments