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

Method ScriptFunc

lib/methods/pluginchecktask.cpp:20–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18REGISTER_FUNCTION_NONCONST(Internal, PluginCheck, &PluginCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
19
20void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
21 const WaitGroup::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
22{
23 REQUIRE_NOT_NULL(checkable);
24 REQUIRE_NOT_NULL(cr);
25
26 CheckCommand::Ptr commandObj = CheckCommand::ExecuteOverride ? CheckCommand::ExecuteOverride : checkable->GetCheckCommand();
27
28 Host::Ptr host;
29 Service::Ptr service;
30 tie(host, service) = GetHostService(checkable);
31
32 MacroProcessor::ResolverList resolvers;
33
34 if (MacroResolver::OverrideMacros)
35 resolvers.emplace_back("override", MacroResolver::OverrideMacros);
36
37 if (service)
38 resolvers.emplace_back("service", service);
39 resolvers.emplace_back("host", host);
40 resolvers.emplace_back("command", commandObj);
41
42 int timeout = commandObj->GetTimeout();
43
44 if (!checkable->GetCheckTimeout().IsEmpty())
45 timeout = checkable->GetCheckTimeout();
46
47 std::function<void(const Value& commandLine, const ProcessResult&)> callback;
48
49 if (Checkable::ExecuteCommandProcessFinishedHandler) {
50 callback = Checkable::ExecuteCommandProcessFinishedHandler;
51 } else {
52 callback = [checkable, cr, producer](const Value& commandLine, const ProcessResult& pr) {
53 ProcessFinishedHandler(checkable, cr, producer, commandLine, pr);
54 };
55 }
56
57 PluginUtility::ExecuteCommand(commandObj, checkable->GetLastCheckResult(),
58 resolvers, resolvedMacros, useResolvedMacros, timeout, callback);
59
60 if (!resolvedMacros || useResolvedMacros) {
61 Checkable::CurrentConcurrentChecks.fetch_add(1);
62 Checkable::IncreasePendingChecks();
63 }
64}
65
66void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
67 const WaitGroup::Ptr& producer, const Value& commandLine, const ProcessResult& pr)

Callers

nothing calls this directly

Calls 4

ExecuteCommandFunction · 0.85
GetCheckCommandMethod · 0.80
GetTimeoutMethod · 0.80
IsEmptyMethod · 0.45

Tested by

no test coverage detected