mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 06:05:01 +02:00
parent
d0bc351f82
commit
99ce7981da
@ -60,7 +60,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
|
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)
|
const boost::function<void(const Value& commandLine, const ProcessResult&)>& callback)
|
||||||
{
|
{
|
||||||
Value raw_command = commandObj->GetCommandLine();
|
Value raw_command = commandObj->GetCommandLine();
|
||||||
@ -68,7 +68,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
|
|||||||
|
|
||||||
Value command;
|
Value command;
|
||||||
if (!raw_arguments || raw_command.IsObjectType<Array>())
|
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 {
|
else {
|
||||||
Array::Ptr arr = make_shared<Array>();
|
Array::Ptr arr = make_shared<Array>();
|
||||||
arr->Add(raw_command);
|
arr->Add(raw_command);
|
||||||
@ -101,7 +101,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
|
|||||||
if (!set_if.IsEmpty()) {
|
if (!set_if.IsEmpty()) {
|
||||||
String missingMacro;
|
String missingMacro;
|
||||||
String set_if_resolved = MacroProcessor::ResolveMacros(set_if, macroResolvers,
|
String set_if_resolved = MacroProcessor::ResolveMacros(set_if, macroResolvers,
|
||||||
checkable->GetLastCheckResult(), &missingMacro);
|
cr, &missingMacro);
|
||||||
|
|
||||||
if (!missingMacro.IsEmpty() || !Convert::ToLong(set_if_resolved))
|
if (!missingMacro.IsEmpty() || !Convert::ToLong(set_if_resolved))
|
||||||
continue;
|
continue;
|
||||||
@ -115,7 +115,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
|
|||||||
|
|
||||||
String missingMacro;
|
String missingMacro;
|
||||||
arg.Value = MacroProcessor::ResolveMacros(argval, macroResolvers,
|
arg.Value = MacroProcessor::ResolveMacros(argval, macroResolvers,
|
||||||
checkable->GetLastCheckResult(), &missingMacro);
|
cr, &missingMacro);
|
||||||
|
|
||||||
if (!missingMacro.IsEmpty()) {
|
if (!missingMacro.IsEmpty()) {
|
||||||
if (required) {
|
if (required) {
|
||||||
@ -162,7 +162,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
|
|||||||
BOOST_FOREACH(const Dictionary::Pair& kv, env) {
|
BOOST_FOREACH(const Dictionary::Pair& kv, env) {
|
||||||
String name = kv.second;
|
String name = kv.second;
|
||||||
|
|
||||||
Value value = MacroProcessor::ResolveMacros(name, macroResolvers, checkable->GetLastCheckResult());
|
Value value = MacroProcessor::ResolveMacros(name, macroResolvers, cr);
|
||||||
|
|
||||||
envMacros->Set(kv.first, value);
|
envMacros->Set(kv.first, value);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class I2_ICINGA_API PluginUtility
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void ExecuteCommand(const Command::Ptr& commandObj, const Checkable::Ptr& checkable,
|
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&)>());
|
const boost::function<void(const Value& commandLine, const ProcessResult&)>& callback = boost::function<void(const Value& commandLine, const ProcessResult&)>());
|
||||||
|
|
||||||
static ServiceState ExitStatusToState(int exitStatus);
|
static ServiceState ExitStatusToState(int exitStatus);
|
||||||
|
@ -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("command", commandObj));
|
||||||
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
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)
|
void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr)
|
||||||
|
@ -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("command", commandObj));
|
||||||
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
||||||
|
|
||||||
PluginUtility::ExecuteCommand(commandObj, checkable, resolvers);
|
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), resolvers);
|
||||||
}
|
}
|
||||||
|
@ -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("command", commandObj));
|
||||||
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
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)
|
void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& command, const ProcessResult& pr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user