[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: status.dat: Escape new-lines in multi-line plugin output

git at icinga.org git at icinga.org
Mon Jun 24 15:19:45 CEST 2013


Module: icinga2
Branch: feature/configconvert-2743
Commit: fe35791b1b0b00df05f94423e1704187b99bedab
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=fe35791b1b0b00df05f94423e1704187b99bedab

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Jun 24 11:35:56 2013 +0200

status.dat: Escape new-lines in multi-line plugin output

Fixes #3671

---

 components/compat/compatcomponent.cpp |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp
index 06f6d93..3a2d2f5 100644
--- a/components/compat/compatcomponent.cpp
+++ b/components/compat/compatcomponent.cpp
@@ -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();





More information about the icinga-checkins mailing list