diff --git a/lib/db_ido/idochecktask.cpp b/lib/db_ido/idochecktask.cpp index d3b456963..3b5856a65 100644 --- a/lib/db_ido/idochecktask.cpp +++ b/lib/db_ido/idochecktask.cpp @@ -1,7 +1,6 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ #include "db_ido/idochecktask.hpp" -#include "icinga/envresolver.hpp" #include "icinga/host.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" @@ -61,8 +60,6 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String idoType = MacroProcessor::ResolveMacros("$ido_type$", resolvers, checkable->GetLastCheckResult(), nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros); diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index 2b9de044d..1e3fe851f 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -2,7 +2,6 @@ #include "icinga/apiactions.hpp" #include "icinga/checkable.hpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/servicegroup.hpp" #include "icinga/hostgroup.hpp" @@ -668,8 +667,6 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object, cons resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String resolved_endpoint = MacroProcessor::ResolveMacros( endpoint, resolvers, checkable->GetLastCheckResult(), diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index 8f9b19b3b..97f0affe0 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -3,6 +3,8 @@ #include "icinga/macroprocessor.hpp" #include "icinga/macroresolver.hpp" #include "icinga/customvarobject.hpp" +#include "icinga/envresolver.hpp" +#include "icinga/icingaapplication.hpp" #include "base/array.hpp" #include "base/objectlock.hpp" #include "base/logger.hpp" @@ -73,6 +75,16 @@ Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolv return result; } +static const EnvResolver::Ptr l_EnvResolver = new EnvResolver(); + +static MacroProcessor::ResolverList GetDefaultResolvers() +{ + return { + { "icinga", IcingaApplication::GetInstance() }, + { "env", l_EnvResolver, false } + }; +} + bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resolvers, const CheckResult::Ptr& cr, Value *result, bool *recursive_macro) { @@ -88,80 +100,84 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol tokens.erase(tokens.begin()); } - for (const ResolverSpec& resolver : resolvers) { - if (!objName.IsEmpty() && objName != resolver.Name) - continue; + const auto defaultResolvers (GetDefaultResolvers()); - if (objName.IsEmpty()) { - if (!resolver.ResolveShortMacros) + for (auto resolverList : {&resolvers, &defaultResolvers}) { + for (auto& resolver : *resolverList) { + if (!objName.IsEmpty() && objName != resolver.Name) continue; - CustomVarObject::Ptr dobj = dynamic_pointer_cast(resolver.Obj); - - if (dobj) { - Dictionary::Ptr vars = dobj->GetVars(); - - if (vars && vars->Contains(macro)) { - *result = vars->Get(macro); - *recursive_macro = true; - return true; - } - } - } - - auto *mresolver = dynamic_cast(resolver.Obj.get()); - - if (mresolver && mresolver->ResolveMacro(boost::algorithm::join(tokens, "."), cr, result)) - return true; - - Value ref = resolver.Obj; - bool valid = true; - - for (const String& token : tokens) { - if (ref.IsObjectType()) { - Dictionary::Ptr dict = ref; - if (dict->Contains(token)) { - ref = dict->Get(token); + if (objName.IsEmpty()) { + if (!resolver.ResolveShortMacros) continue; - } else { - valid = false; - break; + + CustomVarObject::Ptr dobj = dynamic_pointer_cast(resolver.Obj); + + if (dobj) { + Dictionary::Ptr vars = dobj->GetVars(); + + if (vars && vars->Contains(macro)) { + *result = vars->Get(macro); + *recursive_macro = true; + return true; + } } - } else if (ref.IsObject()) { - Object::Ptr object = ref; - - Type::Ptr type = object->GetReflectionType(); - - if (!type) { - valid = false; - break; - } - - int field = type->GetFieldId(token); - - if (field == -1) { - valid = false; - break; - } - - ref = object->GetField(field); - - Field fieldInfo = type->GetFieldInfo(field); - - if (strcmp(fieldInfo.TypeName, "Timestamp") == 0) - ref = static_cast(ref); } - } - if (valid) { - if (tokens[0] == "vars" || - tokens[0] == "action_url" || - tokens[0] == "notes_url" || - tokens[0] == "notes") - *recursive_macro = true; + auto *mresolver = dynamic_cast(resolver.Obj.get()); - *result = ref; - return true; + if (mresolver && mresolver->ResolveMacro(boost::algorithm::join(tokens, "."), cr, result)) + return true; + + Value ref = resolver.Obj; + bool valid = true; + + for (const String& token : tokens) { + if (ref.IsObjectType()) { + Dictionary::Ptr dict = ref; + if (dict->Contains(token)) { + ref = dict->Get(token); + continue; + } else { + valid = false; + break; + } + } else if (ref.IsObject()) { + Object::Ptr object = ref; + + Type::Ptr type = object->GetReflectionType(); + + if (!type) { + valid = false; + break; + } + + int field = type->GetFieldId(token); + + if (field == -1) { + valid = false; + break; + } + + ref = object->GetField(field); + + Field fieldInfo = type->GetFieldInfo(field); + + if (strcmp(fieldInfo.TypeName, "Timestamp") == 0) + ref = static_cast(ref); + } + } + + if (valid) { + if (tokens[0] == "vars" || + tokens[0] == "action_url" || + tokens[0] == "notes_url" || + tokens[0] == "notes") + *recursive_macro = true; + + *result = ref; + return true; + } } } @@ -173,9 +189,12 @@ Value MacroProcessor::EvaluateFunction(const Function::Ptr& func, const Resolver const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel) { Dictionary::Ptr resolvers_this = new Dictionary(); + const auto defaultResolvers (GetDefaultResolvers()); - for (const ResolverSpec& resolver : resolvers) { - resolvers_this->Set(resolver.Name, resolver.Obj); + for (auto resolverList : {&resolvers, &defaultResolvers}) { + for (auto& resolver: *resolverList) { + resolvers_this->Set(resolver.Name, resolver.Obj); + } } auto internalResolveMacrosShim = [resolvers, cr, resolvedMacros, useResolvedMacros, recursionLevel](const std::vector& args) { diff --git a/lib/icingadb/icingadbchecktask.cpp b/lib/icingadb/icingadbchecktask.cpp index 4e2bb5f16..f7c596457 100644 --- a/lib/icingadb/icingadbchecktask.cpp +++ b/lib/icingadb/icingadbchecktask.cpp @@ -1,7 +1,6 @@ /* Icinga 2 | (c) 2022 Icinga GmbH | GPLv2+ */ #include "icingadb/icingadbchecktask.hpp" -#include "icinga/envresolver.hpp" #include "icinga/host.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" @@ -62,8 +61,6 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); auto resolve ([&](const String& macro) { return MacroProcessor::ResolveMacros(macro, resolvers, checkable->GetLastCheckResult(), diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index edf921c72..d90f4a56e 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -3,7 +3,6 @@ #include "livestatus/hoststable.hpp" #include "livestatus/hostgroupstable.hpp" #include "livestatus/endpointstable.hpp" -#include "icinga/envresolver.hpp" #include "icinga/host.hpp" #include "icinga/service.hpp" #include "icinga/hostgroup.hpp" @@ -11,7 +10,6 @@ #include "icinga/eventcommand.hpp" #include "icinga/timeperiod.hpp" #include "icinga/macroprocessor.hpp" -#include "icinga/icingaapplication.hpp" #include "icinga/compatutility.hpp" #include "icinga/pluginutility.hpp" #include "base/configtype.hpp" @@ -316,8 +314,6 @@ Value HostsTable::NotesExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "host", host }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers); @@ -342,8 +338,6 @@ Value HostsTable::NotesUrlExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "host", host }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(host->GetNotesUrl(), resolvers); @@ -368,8 +362,6 @@ Value HostsTable::ActionUrlExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "host", host }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(host->GetActionUrl(), resolvers); @@ -426,8 +418,6 @@ Value HostsTable::IconImageExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "host", host }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(host->GetIconImage(), resolvers); diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index f472e0ff0..681445aaf 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -9,11 +9,9 @@ #include "icinga/servicegroup.hpp" #include "icinga/hostgroup.hpp" #include "icinga/checkcommand.hpp" -#include "icinga/envresolver.hpp" #include "icinga/eventcommand.hpp" #include "icinga/timeperiod.hpp" #include "icinga/macroprocessor.hpp" -#include "icinga/icingaapplication.hpp" #include "icinga/compatutility.hpp" #include "icinga/pluginutility.hpp" #include "base/configtype.hpp" @@ -373,8 +371,6 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "service", service }, { "host", service->GetHost() }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers); @@ -400,8 +396,6 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "service", service }, { "host", service->GetHost() }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers); @@ -427,8 +421,6 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "service", service }, { "host", service->GetHost() }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers); @@ -454,8 +446,6 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row) MacroProcessor::ResolverList resolvers { { "service", service }, { "host", service->GetHost() }, - { "icinga", IcingaApplication::GetInstance() }, - { "env", new EnvResolver(), false } }; return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers); diff --git a/lib/methods/clusterzonechecktask.cpp b/lib/methods/clusterzonechecktask.cpp index 838d94422..fd52534c3 100644 --- a/lib/methods/clusterzonechecktask.cpp +++ b/lib/methods/clusterzonechecktask.cpp @@ -2,7 +2,6 @@ #include "methods/clusterzonechecktask.hpp" #include "icinga/checkcommand.hpp" -#include "icinga/envresolver.hpp" #include "icinga/macroprocessor.hpp" #include "remote/apilistener.hpp" #include "remote/endpoint.hpp" @@ -64,8 +63,6 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", command); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(), nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros); diff --git a/lib/methods/dummychecktask.cpp b/lib/methods/dummychecktask.cpp index 2f9a27286..905a022c3 100644 --- a/lib/methods/dummychecktask.cpp +++ b/lib/methods/dummychecktask.cpp @@ -4,8 +4,6 @@ # include #endif /* _WIN32 */ #include "methods/dummychecktask.hpp" -#include "icinga/envresolver.hpp" -#include "icinga/icingaapplication.hpp" #include "icinga/pluginutility.hpp" #include "base/utility.hpp" #include "base/perfdatavalue.hpp" @@ -38,8 +36,6 @@ void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", command); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); int dummyState = MacroProcessor::ResolveMacros("$dummy_state$", resolvers, checkable->GetLastCheckResult(), nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros); diff --git a/lib/methods/icingachecktask.cpp b/lib/methods/icingachecktask.cpp index 5662f9cbd..d3eae1f33 100644 --- a/lib/methods/icingachecktask.cpp +++ b/lib/methods/icingachecktask.cpp @@ -2,11 +2,9 @@ #include "methods/icingachecktask.hpp" #include "icinga/cib.hpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" -#include "icinga/icingaapplication.hpp" #include "icinga/clusterevents.hpp" #include "icinga/checkable.hpp" #include "remote/apilistener.hpp" @@ -42,8 +40,6 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", command); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String missingIcingaMinVersion; diff --git a/lib/methods/pluginchecktask.cpp b/lib/methods/pluginchecktask.cpp index 2710c01c1..b4749fbfd 100644 --- a/lib/methods/pluginchecktask.cpp +++ b/lib/methods/pluginchecktask.cpp @@ -1,11 +1,9 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ #include "methods/pluginchecktask.hpp" -#include "icinga/envresolver.hpp" #include "icinga/pluginutility.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" -#include "icinga/icingaapplication.hpp" #include "base/configtype.hpp" #include "base/logger.hpp" #include "base/function.hpp" @@ -38,8 +36,6 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); int timeout = commandObj->GetTimeout(); diff --git a/lib/methods/plugineventtask.cpp b/lib/methods/plugineventtask.cpp index 76204d6ec..00efb6ce4 100644 --- a/lib/methods/plugineventtask.cpp +++ b/lib/methods/plugineventtask.cpp @@ -1,11 +1,9 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ #include "methods/plugineventtask.hpp" -#include "icinga/envresolver.hpp" #include "icinga/eventcommand.hpp" #include "icinga/macroprocessor.hpp" #include "icinga/pluginutility.hpp" -#include "icinga/icingaapplication.hpp" #include "base/configtype.hpp" #include "base/logger.hpp" #include "base/function.hpp" @@ -37,8 +35,6 @@ void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable, resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); int timeout = commandObj->GetTimeout(); std::function callback; diff --git a/lib/methods/pluginnotificationtask.cpp b/lib/methods/pluginnotificationtask.cpp index 09880e973..a20c971a1 100644 --- a/lib/methods/pluginnotificationtask.cpp +++ b/lib/methods/pluginnotificationtask.cpp @@ -1,13 +1,11 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ #include "methods/pluginnotificationtask.hpp" -#include "icinga/envresolver.hpp" #include "icinga/notification.hpp" #include "icinga/notificationcommand.hpp" #include "icinga/pluginutility.hpp" #include "icinga/service.hpp" #include "icinga/macroprocessor.hpp" -#include "icinga/icingaapplication.hpp" #include "base/function.hpp" #include "base/logger.hpp" #include "base/utility.hpp" @@ -54,8 +52,6 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); int timeout = commandObj->GetTimeout(); std::function callback; diff --git a/lib/methods/sleepchecktask.cpp b/lib/methods/sleepchecktask.cpp index 61bb91794..af6b0638e 100644 --- a/lib/methods/sleepchecktask.cpp +++ b/lib/methods/sleepchecktask.cpp @@ -1,8 +1,6 @@ /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ #include "methods/sleepchecktask.hpp" -#include "icinga/envresolver.hpp" -#include "icinga/icingaapplication.hpp" #include "icinga/pluginutility.hpp" #include "base/utility.hpp" #include "base/convert.hpp" @@ -34,8 +32,6 @@ void SleepCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); resolvers.emplace_back("command", commandObj); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); double sleepTime = MacroProcessor::ResolveMacros("$sleep_time$", resolvers, checkable->GetLastCheckResult(), nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros); diff --git a/lib/perfdata/graphitewriter.cpp b/lib/perfdata/graphitewriter.cpp index 4ea12dcdf..19e1209bd 100644 --- a/lib/perfdata/graphitewriter.cpp +++ b/lib/perfdata/graphitewriter.cpp @@ -2,7 +2,6 @@ #include "perfdata/graphitewriter.hpp" #include "perfdata/graphitewriter-ti.cpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" @@ -294,8 +293,6 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable, if (service) resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String prefix; diff --git a/lib/perfdata/influxdbcommonwriter.cpp b/lib/perfdata/influxdbcommonwriter.cpp index 1490ffb10..0303af09f 100644 --- a/lib/perfdata/influxdbcommonwriter.cpp +++ b/lib/perfdata/influxdbcommonwriter.cpp @@ -3,7 +3,6 @@ #include "perfdata/influxdbcommonwriter.hpp" #include "perfdata/influxdbcommonwriter-ti.cpp" #include "remote/url.hpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/macroprocessor.hpp" #include "icinga/icingaapplication.hpp" @@ -225,8 +224,6 @@ void InfluxdbCommonWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, if (service) resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); String prefix; diff --git a/lib/perfdata/opentsdbwriter.cpp b/lib/perfdata/opentsdbwriter.cpp index 4291a4fe5..e34a2e09e 100644 --- a/lib/perfdata/opentsdbwriter.cpp +++ b/lib/perfdata/opentsdbwriter.cpp @@ -2,7 +2,6 @@ #include "perfdata/opentsdbwriter.hpp" #include "perfdata/opentsdbwriter-ti.cpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/checkcommand.hpp" #include "icinga/macroprocessor.hpp" @@ -196,9 +195,7 @@ void OpenTsdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C if (service) resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); - + // Resolve macros for the service and host template config line if (config_tmpl_tags) { ObjectLock olock(config_tmpl_tags); diff --git a/lib/perfdata/perfdatawriter.cpp b/lib/perfdata/perfdatawriter.cpp index 711f9e193..0e99c2728 100644 --- a/lib/perfdata/perfdatawriter.cpp +++ b/lib/perfdata/perfdatawriter.cpp @@ -2,7 +2,6 @@ #include "perfdata/perfdatawriter.hpp" #include "perfdata/perfdatawriter-ti.cpp" -#include "icinga/envresolver.hpp" #include "icinga/service.hpp" #include "icinga/macroprocessor.hpp" #include "icinga/icingaapplication.hpp" @@ -117,8 +116,6 @@ void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C if (service) resolvers.emplace_back("service", service); resolvers.emplace_back("host", host); - resolvers.emplace_back("icinga", IcingaApplication::GetInstance()); - resolvers.emplace_back("env", new EnvResolver(), false); if (service) { String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);