]> granicus.if.org Git - icinga2/commitdiff
Livestatus: Fix check_command_expanded column.
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 11 Dec 2013 09:18:23 +0000 (10:18 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 11 Dec 2013 09:18:23 +0000 (10:18 +0100)
Fixes #5296

components/livestatus/hoststable.cpp
components/livestatus/servicestable.cpp

index ee9c401eff57d73f5882b3e6d04e808a04a257bd..5f9d4887e7495aa9845486b2642c90439af3efed 100644 (file)
@@ -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<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>";
-       }
+       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)
index 4a47da1b6f2112621dc79edd3e75fe834e282fbe..db1bec34997b45ca40b2ec8664f51b099b8eaf42 100644 (file)
@@ -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<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>";
-        }
+       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)