]> granicus.if.org Git - icinga2/commitdiff
status.dat: Escape new-lines in multi-line plugin output
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 24 Jun 2013 09:35:56 +0000 (11:35 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 24 Jun 2013 09:35:56 +0000 (11:35 +0200)
Fixes #3671

components/compat/compatcomponent.cpp

index 06f6d9309939158d0b9698af0d49efee2b63e2c4..3a2d2f509ad3d5f8453968162a995d30b9e09718 100644 (file)
@@ -32,6 +32,7 @@
 #include <boost/foreach.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <boost/exception/diagnostic_information.hpp>
+#include <boost/algorithm/string/replace.hpp>
 #include <fstream>
 
 using namespace icinga;
@@ -343,8 +344,12 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
 
        if (cr) {
                output = cr->Get("output");
+               boost::algorithm::replace_all(output, "\n", "\\n");
+
                schedule_end = cr->Get("schedule_end");
+
                perfdata = cr->Get("performance_data_raw");
+               boost::algorithm::replace_all(perfdata, "\n", "\\n");
        }
 
        int state = service->GetState();