MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Execute

Method Execute

lib/icinga/externalcommandprocessor.cpp:31–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29boost::signals2::signal<void(double, const String&, const std::vector<String>&)> ExternalCommandProcessor::OnNewExternalCommand;
30
31void ExternalCommandProcessor::Execute(const WaitGroup::Ptr& producer, const String& line)
32{
33 if (line.IsEmpty())
34 return;
35
36 if (line[0] != '[')
37 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing timestamp in command: " + line));
38
39 size_t pos = line.FindFirstOf("]");
40
41 if (pos == String::NPos)
42 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing timestamp in command: " + line));
43
44 String timestamp = line.SubStr(1, pos - 1);
45 String args = line.SubStr(pos + 2, String::NPos);
46
47 double ts = Convert::ToDouble(timestamp);
48
49 if (ts == 0)
50 BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid timestamp in command: " + line));
51
52 std::vector<String> argv = args.Split(";");
53
54 if (argv.empty())
55 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line));
56
57 std::vector<String> argvExtra(argv.begin() + 1, argv.end());
58 Execute(producer, ts, argv[0], argvExtra);
59}
60
61void ExternalCommandProcessor::Execute(const WaitGroup::Ptr& producer, double time, const String& command, const std::vector<String>& arguments)
62{

Callers

nothing calls this directly

Calls 9

FindFirstOfMethod · 0.80
SubStrMethod · 0.80
SplitMethod · 0.80
findMethod · 0.80
IsEmptyMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected