]> granicus.if.org Git - icinga2/commitdiff
Fix performance data for API events
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 28 Oct 2014 14:24:35 +0000 (15:24 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 28 Oct 2014 14:24:35 +0000 (15:24 +0100)
fixes #7473

lib/icinga/apievents.cpp

index a26c52948b5fc03cc6d23d84ec12a359c0a94630..aa6ecc3f077f0a85652c34fe2b8bc100d374c0b6 100644 (file)
@@ -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>();       
+       CheckResult::Ptr cr = make_shared<CheckResult>();
+
+       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<Array>();
+
+       ObjectLock olock(vperf);
+       BOOST_FOREACH(const Value& vp, vperf) {
+               Value p;
+
+               if (vp.IsObjectType<Dictionary>()) {
+                       PerfdataValue::Ptr val = make_shared<PerfdataValue>();
+                       Deserialize(val, vp, true);
+                       rperf->Add(val);
+               } else
+                       rperf->Add(vp);
+       }
+
+       cr->SetPerformanceData(rperf);
+
        Host::Ptr host = Host::GetByName(params->Get("host"));
 
        if (!host)