mirror of https://github.com/Icinga/icinga2.git
Correct escaping of metric and tag names for OpenTSDB perfdata plugin
fixes #9665
This commit is contained in:
parent
548e8cab7d
commit
d4b31bbd0a
|
@ -106,16 +106,16 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
|
||||||
else
|
else
|
||||||
host = static_pointer_cast<Host>(checkable);
|
host = static_pointer_cast<Host>(checkable);
|
||||||
|
|
||||||
String hostName = host->GetName();
|
|
||||||
|
|
||||||
String metric;
|
String metric;
|
||||||
std::map<String, String> tags;
|
std::map<String, String> tags;
|
||||||
tags["host"] = hostName;
|
|
||||||
|
String escaped_hostName = EscapeMetric(host->GetName());
|
||||||
|
tags["host"] = escaped_hostName;
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
String serviceName = service->GetShortName();
|
String serviceName = service->GetShortName();
|
||||||
EscapeMetric(serviceName);
|
String escaped_serviceName = EscapeMetric(serviceName);
|
||||||
metric = "icinga.service." + serviceName;
|
metric = "icinga.service." + escaped_serviceName;
|
||||||
|
|
||||||
SendMetric(metric + ".state", tags, service->GetState());
|
SendMetric(metric + ".state", tags, service->GetState());
|
||||||
} else {
|
} else {
|
||||||
|
@ -134,8 +134,8 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
|
||||||
if (service) {
|
if (service) {
|
||||||
tags["type"] = "service";
|
tags["type"] = "service";
|
||||||
String serviceName = service->GetShortName();
|
String serviceName = service->GetShortName();
|
||||||
EscapeTag(serviceName);
|
String escaped_serviceName = EscapeTag(serviceName);
|
||||||
tags["service"] = serviceName;
|
tags["service"] = escaped_serviceName;
|
||||||
} else {
|
} else {
|
||||||
tags["type"] = "host";
|
tags["type"] = "host";
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,7 @@ void OpenTsdbWriter::SendPerfdata(const String& metric, const std::map<String, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String escaped_key = pdv->GetLabel();
|
String escaped_key = EscapeMetric(pdv->GetLabel());
|
||||||
EscapeMetric(escaped_key);
|
|
||||||
boost::algorithm::replace_all(escaped_key, "::", ".");
|
boost::algorithm::replace_all(escaped_key, "::", ".");
|
||||||
|
|
||||||
SendMetric(metric + "." + escaped_key, tags, pdv->GetValue());
|
SendMetric(metric + "." + escaped_key, tags, pdv->GetValue());
|
||||||
|
|
Loading…
Reference in New Issue