Move /status/Collection to /status

fixes #10210
This commit is contained in:
Jean-Marcel Flach 2015-09-24 15:26:57 +02:00
parent 8c997255a9
commit d8eca3d0c2
2 changed files with 7 additions and 21 deletions

View File

@ -66,7 +66,14 @@ bool StatusHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request
typedef std::pair<String, StatsFunction::Ptr> kv_pair; typedef std::pair<String, StatsFunction::Ptr> kv_pair;
BOOST_FOREACH(const kv_pair& kv, StatsFunctionRegistry::GetInstance()->GetItems()) { BOOST_FOREACH(const kv_pair& kv, StatsFunctionRegistry::GetInstance()->GetItems()) {
resultInner = new Dictionary(); resultInner = new Dictionary();
Dictionary::Ptr funcStatus = new Dictionary();
Array::Ptr funcPData = new Array();
kv.second->Invoke(funcStatus, funcPData);
resultInner->Set("name", kv.first); resultInner->Set("name", kv.first);
resultInner->Set("status", funcPData);
resultInner->Set("perfdata", funcPData);
results->Add(resultInner); results->Add(resultInner);
} }
} }
@ -79,23 +86,3 @@ bool StatusHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request
return true; return true;
} }
REGISTER_STATSFUNCTION(Collection, &StatusHandler::StatsFunc);
void StatusHandler::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
typedef std::pair<String, StatsFunction::Ptr> kv_pair;
BOOST_FOREACH(const kv_pair& kv, StatsFunctionRegistry::GetInstance()->GetItems()) {
if (kv.first == "Collection") //TODO Find a better name
continue;
Dictionary::Ptr funcStatus = new Dictionary();
Array::Ptr funcPData = new Array();
kv.second->Invoke(funcStatus, funcPData);
Dictionary::Ptr result = new Dictionary();
result->Set("status", funcStatus);
result->Set("perfdata", funcPData);
status->Set(kv.first, result);
}
}

View File

@ -31,7 +31,6 @@ public:
DECLARE_PTR_TYPEDEFS(StatusHandler); DECLARE_PTR_TYPEDEFS(StatusHandler);
virtual bool HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response) override; virtual bool HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response) override;
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
}; };
} }