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

Method ExecuteFromFile

lib/icinga/externalcommandprocessor.cpp:251–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void ExternalCommandProcessor::ExecuteFromFile(const WaitGroup::Ptr& producer, const String& line, std::deque<std::vector<String>>& file_queue)
252{
253 if (line.IsEmpty())
254 return;
255
256 if (line[0] != '[')
257 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing timestamp in command: " + line));
258
259 size_t pos = line.FindFirstOf("]");
260
261 if (pos == String::NPos)
262 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing timestamp in command: " + line));
263
264 String timestamp = line.SubStr(1, pos - 1);
265 String args = line.SubStr(pos + 2, String::NPos);
266
267 double ts = Convert::ToDouble(timestamp);
268
269 if (ts == 0)
270 BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid timestamp in command: " + line));
271
272 std::vector<String> argv = args.Split(";");
273
274 if (argv.empty())
275 BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line));
276
277 std::vector<String> argvExtra(argv.begin() + 1, argv.end());
278
279 if (argv[0] == "PROCESS_FILE") {
280 Log(LogDebug, "ExternalCommandProcessor")
281 << "Enqueing external command file " << argvExtra[0];
282 file_queue.push_back(argvExtra);
283 } else {
284 Execute(producer, ts, argv[0], argvExtra);
285 }
286}
287
288void ExternalCommandProcessor::ProcessHostCheckResult(const WaitGroup::Ptr& producer, double time, const std::vector<String>& arguments)
289{

Callers

nothing calls this directly

Calls 9

LogClass · 0.85
FindFirstOfMethod · 0.80
SubStrMethod · 0.80
SplitMethod · 0.80
push_backMethod · 0.80
IsEmptyMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected