Use the right CheckResult object for commands.

Fixes #6260
This commit is contained in:
Gunnar Beutner 2014-05-22 08:59:46 +02:00
parent d0bc351f82
commit 99ce7981da
5 changed files with 9 additions and 9 deletions

View File

@ -60,7 +60,7 @@ private:
};
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();
@ -68,7 +68,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
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);
@ -101,7 +101,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
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;
@ -115,7 +115,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
String missingMacro;
arg.Value = MacroProcessor::ResolveMacros(argval, macroResolvers,
checkable->GetLastCheckResult(), &missingMacro);
cr, &missingMacro);
if (!missingMacro.IsEmpty()) {
if (required) {
@ -162,7 +162,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
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);
}

View File

@ -40,7 +40,7 @@ class I2_ICINGA_API PluginUtility
{
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);

View File

@ -50,7 +50,7 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
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)

View File

@ -48,5 +48,5 @@ void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable)
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);
}

View File

@ -62,7 +62,7 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, c
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)