]> granicus.if.org Git - icinga2/commitdiff
Correct escaping of metric and tag names for OpenTSDB perfdata plugin
authorTobias von der Krone <tobias.vonderkrone@profitbricks.com>
Fri, 17 Jul 2015 16:37:46 +0000 (18:37 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 20 Jul 2015 05:59:13 +0000 (07:59 +0200)
fixes #9665

lib/perfdata/opentsdbwriter.cpp

index acbd718079aacf6b7414349f51a497cd9b5501b8..44f5751771669a7015096618f4ce23dd8c32f80a 100644 (file)
@@ -107,16 +107,16 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
        else
                host = static_pointer_cast<Host>(checkable);
 
-       String hostName = host->GetName();
-
        String metric;
        std::map<String, String> 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::map<String, S
                        }
                }
 
-               String escaped_key = pdv->GetLabel();
-               EscapeMetric(escaped_key);
+               String escaped_key = EscapeMetric(pdv->GetLabel());
                boost::algorithm::replace_all(escaped_key, "::", ".");
 
                SendMetric(metric + "." + escaped_key, tags, pdv->GetValue());