From: Tobias von der Krone Date: Fri, 17 Jul 2015 16:37:46 +0000 (+0200) Subject: Correct escaping of metric and tag names for OpenTSDB perfdata plugin X-Git-Tag: v2.4.0~491 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80d0d7dc7a0f92a30467d7dd3f90f1b497839814;p=icinga2 Correct escaping of metric and tag names for OpenTSDB perfdata plugin fixes #9665 --- diff --git a/lib/perfdata/opentsdbwriter.cpp b/lib/perfdata/opentsdbwriter.cpp index acbd71807..44f575177 100644 --- a/lib/perfdata/opentsdbwriter.cpp +++ b/lib/perfdata/opentsdbwriter.cpp @@ -107,16 +107,16 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C else host = static_pointer_cast(checkable); - String hostName = host->GetName(); - String metric; std::map tags; - tags["host"] = hostName; + + String escaped_hostName = EscapeMetric(host->GetName()); + tags["host"] = escaped_hostName; if (service) { String serviceName = service->GetShortName(); - EscapeMetric(serviceName); - metric = "icinga.service." + serviceName; + String escaped_serviceName = EscapeMetric(serviceName); + metric = "icinga.service." + escaped_serviceName; SendMetric(metric + ".state", tags, service->GetState()); } else { @@ -135,8 +135,8 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C if (service) { tags["type"] = "service"; String serviceName = service->GetShortName(); - EscapeTag(serviceName); - tags["service"] = serviceName; + String escaped_serviceName = EscapeTag(serviceName); + tags["service"] = escaped_serviceName; } else { tags["type"] = "host"; } @@ -170,8 +170,7 @@ void OpenTsdbWriter::SendPerfdata(const String& metric, const std::mapGetLabel(); - EscapeMetric(escaped_key); + String escaped_key = EscapeMetric(pdv->GetLabel()); boost::algorithm::replace_all(escaped_key, "::", "."); SendMetric(metric + "." + escaped_key, tags, pdv->GetValue());