void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, const User::Ptr& user, const CheckResult::Ptr& cr, int itype, const String& author, const String& comment) { NotificationCommand::Ptr commandObj = notification->GetNotificationCommand(); NotificationType type = static_cast<NotificationType>(itype); Service::Ptr service = notification->GetService(); Value raw_command = commandObj->GetCommandLine(); StaticMacroResolver::Ptr notificationMacroResolver = make_shared<StaticMacroResolver>(); notificationMacroResolver->Add("NOTIFICATIONTYPE", Notification::NotificationTypeToString(type)); notificationMacroResolver->Add("NOTIFICATIONAUTHOR", author); notificationMacroResolver->Add("NOTIFICATIONAUTHORNAME", author); notificationMacroResolver->Add("NOTIFICATIONCOMMENT", comment); std::vector<MacroResolver::Ptr> resolvers; resolvers.push_back(user); resolvers.push_back(notificationMacroResolver); resolvers.push_back(notification); resolvers.push_back(service); resolvers.push_back(service->GetHost()); resolvers.push_back(commandObj); resolvers.push_back(IcingaApplication::GetInstance()); Value command = MacroProcessor::ResolveMacros(raw_command, resolvers, cr, Utility::EscapeShellCmd, commandObj->GetEscapeMacros()); Dictionary::Ptr envMacros = make_shared<Dictionary>(); Array::Ptr export_macros = commandObj->GetExportMacros(); if (export_macros) { BOOST_FOREACH(const String& macro, export_macros) { String value; if (!MacroProcessor::ResolveMacro(macro, resolvers, cr, &value)) { Log(LogWarning, "icinga", "export_macros for notification '" + notification->GetName() + "' refers to unknown macro '" + macro + "'"); continue; } envMacros->Set(macro, value); } }