mirror of https://github.com/Icinga/icinga2.git
InfluxdbWriter: clone less
This commit is contained in:
parent
d7b1127730
commit
2acdbd81ff
|
@ -248,23 +248,26 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
|||
|
||||
// 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 = 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));
|
||||
|
||||
Dictionary::Ptr tags = tmpl->Get("tags");
|
||||
if (tags) {
|
||||
ObjectLock olock(tags);
|
||||
for (const Dictionary::Pair& pair : tags) {
|
||||
String missing_macro;
|
||||
Value value = MacroProcessor::ResolveMacros(pair.second, resolvers, cr, &missing_macro);
|
||||
Dictionary::Ptr tagsClean = tmpl->Get("tags");
|
||||
if (tagsClean) {
|
||||
Dictionary::Ptr tags = new Dictionary();
|
||||
|
||||
if (!missing_macro.IsEmpty()) {
|
||||
tags->Remove(pair.first);
|
||||
continue;
|
||||
{
|
||||
ObjectLock olock(tagsClean);
|
||||
for (const Dictionary::Pair& pair : tagsClean) {
|
||||
String missing_macro;
|
||||
Value value = MacroProcessor::ResolveMacros(pair.second, resolvers, cr, &missing_macro);
|
||||
|
||||
if (missing_macro.IsEmpty()) {
|
||||
tags->Set(pair.first, value);
|
||||
}
|
||||
}
|
||||
|
||||
tags->Set(pair.first, value);
|
||||
}
|
||||
|
||||
tmpl->Set("tags", tags);
|
||||
}
|
||||
|
||||
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
|
||||
|
|
Loading…
Reference in New Issue