};
void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
- const MacroProcessor::ResolverList& macroResolvers,
+ const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
const boost::function<void(const Value& commandLine, const ProcessResult&)>& callback)
{
Value raw_command = commandObj->GetCommandLine();
Value command;
if (!raw_arguments || raw_command.IsObjectType<Array>())
- command = MacroProcessor::ResolveMacros(raw_command, macroResolvers, checkable->GetLastCheckResult(), NULL, Utility::EscapeShellArg);
+ command = MacroProcessor::ResolveMacros(raw_command, macroResolvers, cr, NULL, Utility::EscapeShellArg);
else {
Array::Ptr arr = make_shared<Array>();
arr->Add(raw_command);
if (!set_if.IsEmpty()) {
String missingMacro;
String set_if_resolved = MacroProcessor::ResolveMacros(set_if, macroResolvers,
- checkable->GetLastCheckResult(), &missingMacro);
+ cr, &missingMacro);
if (!missingMacro.IsEmpty() || !Convert::ToLong(set_if_resolved))
continue;
String missingMacro;
arg.Value = MacroProcessor::ResolveMacros(argval, macroResolvers,
- checkable->GetLastCheckResult(), &missingMacro);
+ cr, &missingMacro);
if (!missingMacro.IsEmpty()) {
if (required) {
BOOST_FOREACH(const Dictionary::Pair& kv, env) {
String name = kv.second;
- Value value = MacroProcessor::ResolveMacros(name, macroResolvers, checkable->GetLastCheckResult());
+ Value value = MacroProcessor::ResolveMacros(name, macroResolvers, cr);
envMacros->Set(kv.first, value);
}
{
public:
static void ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
- const MacroProcessor::ResolverList& macroResolvers,
+ const CheckResult::Ptr& cr, const MacroProcessor::ResolverList& macroResolvers,
const boost::function<void(const Value& commandLine, const ProcessResult&)>& callback = boost::function<void(const Value& commandLine, const ProcessResult&)>());
static ServiceState ExitStatusToState(int exitStatus);
resolvers.push_back(std::make_pair("command", commandObj));
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- PluginUtility::ExecuteCommand(commandObj, checkable, resolvers, boost::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2));
+ PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers, boost::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2));
}
void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr)
resolvers.push_back(std::make_pair("command", commandObj));
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- PluginUtility::ExecuteCommand(commandObj, checkable, resolvers);
+ PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers);
}
resolvers.push_back(std::make_pair("command", commandObj));
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- PluginUtility::ExecuteCommand(commandObj, checkable, resolvers, boost::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2));
+ PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers, boost::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2));
}
void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr)