From 83e20ba02ee82643ed5c5d1ab428e76d38fd2271 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 11 Dec 2013 10:18:23 +0100 Subject: [PATCH] Livestatus: Fix check_command_expanded column. Fixes #5296 --- components/livestatus/hoststable.cpp | 39 +++--------------------- components/livestatus/servicestable.cpp | 40 ++++--------------------- 2 files changed, 9 insertions(+), 70 deletions(-) diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index ee9c401ef..5f9d4887e 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -236,42 +236,11 @@ Value HostsTable::CheckCommandExpandedAccessor(const Value& row) if (!hc) return Empty; - CheckCommand::Ptr commandObj = hc->GetCheckCommand(); - - if (!commandObj) - return Empty; - - Value raw_command = commandObj->GetCommandLine(); - - std::vector 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::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 += ""; - } + CheckCommand::Ptr checkcommand = hc->GetCheckCommand(); + if (checkcommand) + return checkcommand->GetName(); /* this is the name without '!' args */ - return buf; + return Empty; } Value HostsTable::EventHandlerAccessor(const Value& row) diff --git a/components/livestatus/servicestable.cpp b/components/livestatus/servicestable.cpp index 4a47da1b6..db1bec349 100644 --- a/components/livestatus/servicestable.cpp +++ b/components/livestatus/servicestable.cpp @@ -200,42 +200,12 @@ Value ServicesTable::CheckCommandExpandedAccessor(const Value& row) if (!service) return Empty; - CheckCommand::Ptr commandObj = service->GetCheckCommand(); - - if (!commandObj) - return Empty; - - Value raw_command = commandObj->GetCommandLine(); - - std::vector 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::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 += ""; - } + CheckCommand::Ptr checkcommand = service->GetCheckCommand(); + + if (checkcommand) + return checkcommand->GetName(); /* this is the name without '!' args */ - return buf; + return Empty; } Value ServicesTable::EventHandlerAccessor(const Value& row) -- 2.40.0