From 29ad90a469653d1e6494f5197181bcf4bdb6e77c Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 28 Oct 2014 15:24:35 +0100 Subject: [PATCH] Fix performance data for API events fixes #7473 --- lib/icinga/apievents.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/icinga/apievents.cpp b/lib/icinga/apievents.cpp index a26c52948..aa6ecc3f0 100644 --- a/lib/icinga/apievents.cpp +++ b/lib/icinga/apievents.cpp @@ -19,6 +19,7 @@ #include "icinga/apievents.hpp" #include "icinga/service.hpp" +#include "icinga/perfdatavalue.hpp" #include "remote/apilistener.hpp" #include "remote/endpoint.hpp" #include "remote/messageorigin.hpp" @@ -133,9 +134,30 @@ Value ApiEvents::CheckResultAPIHandler(const MessageOrigin& origin, const Dictio if (!params) return Empty; - CheckResult::Ptr cr = make_shared(); + CheckResult::Ptr cr = make_shared(); + + Dictionary::Ptr vcr = params->Get("cr"); + Array::Ptr vperf = vcr->Get("performance_data"); + vcr->Remove("performance_data"); + Deserialize(cr, params->Get("cr"), true); + Array::Ptr rperf = make_shared(); + + ObjectLock olock(vperf); + BOOST_FOREACH(const Value& vp, vperf) { + Value p; + + if (vp.IsObjectType()) { + PerfdataValue::Ptr val = make_shared(); + Deserialize(val, vp, true); + rperf->Add(val); + } else + rperf->Add(vp); + } + + cr->SetPerformanceData(rperf); + Host::Ptr host = Host::GetByName(params->Get("host")); if (!host)