mirror of https://github.com/Icinga/icinga2.git
Merge pull request #7356 from Icinga/bugfix/influxdbwriter-clone
InfluxdbWriter: clone less
This commit is contained in:
commit
bea8527083
|
@ -248,24 +248,27 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
||||||
|
|
||||||
// Clone the template and perform an in-place macro expansion of measurement and tag values
|
// Clone the template and perform an in-place macro expansion of measurement and tag values
|
||||||
Dictionary::Ptr tmpl_clean = service ? GetServiceTemplate() : GetHostTemplate();
|
Dictionary::Ptr tmpl_clean = service ? GetServiceTemplate() : GetHostTemplate();
|
||||||
Dictionary::Ptr tmpl = static_pointer_cast<Dictionary>(tmpl_clean->Clone());
|
Dictionary::Ptr tmpl = static_pointer_cast<Dictionary>(tmpl_clean->ShallowClone());
|
||||||
tmpl->Set("measurement", MacroProcessor::ResolveMacros(tmpl->Get("measurement"), resolvers, cr));
|
tmpl->Set("measurement", MacroProcessor::ResolveMacros(tmpl->Get("measurement"), resolvers, cr));
|
||||||
|
|
||||||
Dictionary::Ptr tags = tmpl->Get("tags");
|
Dictionary::Ptr tagsClean = tmpl->Get("tags");
|
||||||
if (tags) {
|
if (tagsClean) {
|
||||||
ObjectLock olock(tags);
|
Dictionary::Ptr tags = new Dictionary();
|
||||||
for (const Dictionary::Pair& pair : tags) {
|
|
||||||
|
{
|
||||||
|
ObjectLock olock(tagsClean);
|
||||||
|
for (const Dictionary::Pair& pair : tagsClean) {
|
||||||
String missing_macro;
|
String missing_macro;
|
||||||
Value value = MacroProcessor::ResolveMacros(pair.second, resolvers, cr, &missing_macro);
|
Value value = MacroProcessor::ResolveMacros(pair.second, resolvers, cr, &missing_macro);
|
||||||
|
|
||||||
if (!missing_macro.IsEmpty()) {
|
if (missing_macro.IsEmpty()) {
|
||||||
tags->Remove(pair.first);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
tags->Set(pair.first, value);
|
tags->Set(pair.first, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl->Set("tags", tags);
|
||||||
|
}
|
||||||
|
|
||||||
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
|
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue