From d8eca3d0c25dfb9fd8d69e6be997e8f05a3bd04f Mon Sep 17 00:00:00 2001 From: Jean-Marcel Flach Date: Thu, 24 Sep 2015 15:26:57 +0200 Subject: [PATCH] Move /status/Collection to /status fixes #10210 --- lib/remote/statushandler.cpp | 27 +++++++-------------------- lib/remote/statushandler.hpp | 1 - 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/remote/statushandler.cpp b/lib/remote/statushandler.cpp index c6c9bf982..d3ac9fd08 100644 --- a/lib/remote/statushandler.cpp +++ b/lib/remote/statushandler.cpp @@ -66,7 +66,14 @@ bool StatusHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request typedef std::pair kv_pair; BOOST_FOREACH(const kv_pair& kv, StatsFunctionRegistry::GetInstance()->GetItems()) { 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("status", funcPData); + resultInner->Set("perfdata", funcPData); + results->Add(resultInner); } } @@ -79,23 +86,3 @@ bool StatusHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request return true; } -REGISTER_STATSFUNCTION(Collection, &StatusHandler::StatsFunc); - -void StatusHandler::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) -{ - typedef std::pair 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); - } -} - diff --git a/lib/remote/statushandler.hpp b/lib/remote/statushandler.hpp index 0e3192ae5..2048564e0 100644 --- a/lib/remote/statushandler.hpp +++ b/lib/remote/statushandler.hpp @@ -31,7 +31,6 @@ public: DECLARE_PTR_TYPEDEFS(StatusHandler); virtual bool HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response) override; - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); }; } -- 2.40.0