[icinga-checkins] icinga.org: icinga2/feature/perfdata-quotes-5031: Remove quotes from perfdata keys.

git at icinga.org git at icinga.org
Wed Nov 13 15:44:58 CET 2013


Module: icinga2
Branch: feature/perfdata-quotes-5031
Commit: 2dacc047ece31542ce1654cec428cb2cee358c85
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2dacc047ece31542ce1654cec428cb2cee358c85

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Nov 13 15:42:58 2013 +0100

Remove quotes from perfdata keys.

Fixes #5031

---

 lib/icinga/pluginutility.cpp |    3 +++
 test/icinga-perfdata.cpp     |    6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/lib/icinga/pluginutility.cpp b/lib/icinga/pluginutility.cpp
index b01a0aa..98f6284 100644
--- a/lib/icinga/pluginutility.cpp
+++ b/lib/icinga/pluginutility.cpp
@@ -97,6 +97,9 @@ Value PluginUtility::ParsePerfdata(const String& perfdata)
 
 			String key = perfdata.SubStr(begin, eqp - begin);
 
+			if (key.GetLength() > 2 && key[0] == '\'' && key[key.GetLength() - 1] == '\'')
+				key = key.SubStr(1, key.GetLength() - 2);
+
 			size_t spq = perfdata.FindFirstOf(' ', eqp);
 
 			if (spq == String::NPos)
diff --git a/test/icinga-perfdata.cpp b/test/icinga-perfdata.cpp
index 0481298..6794806 100644
--- a/test/icinga-perfdata.cpp
+++ b/test/icinga-perfdata.cpp
@@ -39,6 +39,12 @@ BOOST_AUTO_TEST_CASE(simple)
 	BOOST_CHECK(str == "test=123456");
 }
 
+BOOST_AUTO_TEST_CASE(quotes)
+{
+	Dictionary::Ptr pd = PluginUtility::ParsePerfdata("'hello world'=123456");
+	BOOST_CHECK(pd->Get("hello world") == 123456);
+}
+
 BOOST_AUTO_TEST_CASE(multiple)
 {
 	Dictionary::Ptr pd = PluginUtility::ParsePerfdata("testA=123456 testB=123456");





More information about the icinga-checkins mailing list