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

Method ScriptFunc

lib/methods/plugineventtask.cpp:19–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17REGISTER_FUNCTION_NONCONST(Internal, PluginEvent, &PluginEventTask::ScriptFunc, "checkable:resolvedMacros:useResolvedMacros");
18
19void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable,
20 const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
21{
22 REQUIRE_NOT_NULL(checkable);
23
24 EventCommand::Ptr commandObj = EventCommand::ExecuteOverride ? EventCommand::ExecuteOverride : checkable->GetEventCommand();
25
26 Host::Ptr host;
27 Service::Ptr service;
28 tie(host, service) = GetHostService(checkable);
29
30 MacroProcessor::ResolverList resolvers;
31
32 if (MacroResolver::OverrideMacros)
33 resolvers.emplace_back("override", MacroResolver::OverrideMacros);
34
35 if (service)
36 resolvers.emplace_back("service", service);
37 resolvers.emplace_back("host", host);
38 resolvers.emplace_back("command", commandObj);
39
40 int timeout = commandObj->GetTimeout();
41 std::function<void(const Value& commandLine, const ProcessResult&)> callback;
42
43 if (Checkable::ExecuteCommandProcessFinishedHandler) {
44 callback = Checkable::ExecuteCommandProcessFinishedHandler;
45 } else {
46 callback = [checkable](const Value& commandLine, const ProcessResult& pr) { ProcessFinishedHandler(checkable, commandLine, pr); };
47 }
48
49 PluginUtility::ExecuteCommand(commandObj, checkable->GetLastCheckResult(),
50 resolvers, resolvedMacros, useResolvedMacros, timeout, callback);
51}
52
53void PluginEventTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& commandLine, const ProcessResult& pr)
54{

Callers

nothing calls this directly

Calls 3

ExecuteCommandFunction · 0.85
GetEventCommandMethod · 0.80
GetTimeoutMethod · 0.80

Tested by

no test coverage detected