diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index fc0a4a6ae..94ae0ede7 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -220,13 +220,6 @@ bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr return true; } - Dictionary::Ptr vars = GetVars(); - - if (vars && vars->Contains(macro)) { - *result = vars->Get(macro); - return true; - } - if (macro.Contains("num_services")) { ServiceStatistics ss = CIB::CalculateServiceStats(); diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index 97f0affe0..724a4f965 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -111,17 +111,24 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol if (!resolver.ResolveShortMacros) continue; + Dictionary::Ptr vars; CustomVarObject::Ptr dobj = dynamic_pointer_cast(resolver.Obj); if (dobj) { - Dictionary::Ptr vars = dobj->GetVars(); + vars = dobj->GetVars(); + } else { + auto app (dynamic_pointer_cast(resolver.Obj)); - if (vars && vars->Contains(macro)) { - *result = vars->Get(macro); - *recursive_macro = true; - return true; + if (app) { + vars = app->GetVars(); } } + + if (vars && vars->Contains(macro)) { + *result = vars->Get(macro); + *recursive_macro = true; + return true; + } } auto *mresolver = dynamic_cast(resolver.Obj.get());