mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
parent
32ca25c7ef
commit
83e20ba02e
@ -236,42 +236,11 @@ Value HostsTable::CheckCommandExpandedAccessor(const Value& row)
|
|||||||
if (!hc)
|
if (!hc)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
CheckCommand::Ptr commandObj = hc->GetCheckCommand();
|
CheckCommand::Ptr checkcommand = hc->GetCheckCommand();
|
||||||
|
if (checkcommand)
|
||||||
|
return checkcommand->GetName(); /* this is the name without '!' args */
|
||||||
|
|
||||||
if (!commandObj)
|
return Empty;
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Value raw_command = commandObj->GetCommandLine();
|
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
|
||||||
resolvers.push_back(hc);
|
|
||||||
resolvers.push_back(host);
|
|
||||||
resolvers.push_back(commandObj);
|
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
|
||||||
|
|
||||||
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
String buf;
|
|
||||||
if (commandLine.IsObjectType<Array>()) {
|
|
||||||
Array::Ptr args = commandLine;
|
|
||||||
|
|
||||||
ObjectLock olock(args);
|
|
||||||
String arg;
|
|
||||||
BOOST_FOREACH(arg, args) {
|
|
||||||
// This is obviously incorrect for non-trivial cases.
|
|
||||||
String argitem = " \"" + arg + "\"";
|
|
||||||
boost::algorithm::replace_all(argitem, "\n", "\\n");
|
|
||||||
buf += argitem;
|
|
||||||
}
|
|
||||||
} else if (!commandLine.IsEmpty()) {
|
|
||||||
String args = Convert::ToString(commandLine);
|
|
||||||
boost::algorithm::replace_all(args, "\n", "\\n");
|
|
||||||
buf += args;
|
|
||||||
} else {
|
|
||||||
buf += "<internal>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value HostsTable::EventHandlerAccessor(const Value& row)
|
Value HostsTable::EventHandlerAccessor(const Value& row)
|
||||||
|
@ -200,42 +200,12 @@ Value ServicesTable::CheckCommandExpandedAccessor(const Value& row)
|
|||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
CheckCommand::Ptr commandObj = service->GetCheckCommand();
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
||||||
|
|
||||||
if (!commandObj)
|
if (checkcommand)
|
||||||
return Empty;
|
return checkcommand->GetName(); /* this is the name without '!' args */
|
||||||
|
|
||||||
Value raw_command = commandObj->GetCommandLine();
|
return Empty;
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
|
||||||
resolvers.push_back(service);
|
|
||||||
resolvers.push_back(service->GetHost());
|
|
||||||
resolvers.push_back(commandObj);
|
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
|
||||||
|
|
||||||
Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
|
||||||
|
|
||||||
String buf;
|
|
||||||
if (commandLine.IsObjectType<Array>()) {
|
|
||||||
Array::Ptr args = commandLine;
|
|
||||||
|
|
||||||
ObjectLock olock(args);
|
|
||||||
String arg;
|
|
||||||
BOOST_FOREACH(arg, args) {
|
|
||||||
// This is obviously incorrect for non-trivial cases.
|
|
||||||
String argitem = " \"" + arg + "\"";
|
|
||||||
boost::algorithm::replace_all(argitem, "\n", "\\n");
|
|
||||||
buf += argitem;
|
|
||||||
}
|
|
||||||
} else if (!commandLine.IsEmpty()) {
|
|
||||||
String args = Convert::ToString(commandLine);
|
|
||||||
boost::algorithm::replace_all(args, "\n", "\\n");
|
|
||||||
buf += args;
|
|
||||||
} else {
|
|
||||||
buf += "<internal>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::EventHandlerAccessor(const Value& row)
|
Value ServicesTable::EventHandlerAccessor(const Value& row)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user