PluginCheckTask::ScriptFunc(): take CheckResultProducer::Ptr

This commit is contained in:
Alexander A. Klimov 2025-04-02 13:22:19 +02:00
parent fca4b185c1
commit a14ac3f41e
2 changed files with 10 additions and 9 deletions

View File

@ -14,10 +14,10 @@
using namespace icinga; using namespace icinga;
REGISTER_FUNCTION_NONCONST(Internal, PluginCheck, &PluginCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros"); REGISTER_FUNCTION_NONCONST(Internal, PluginCheck, &PluginCheckTask::ScriptFunc, "checkable:cr:producer:resolvedMacros:useResolvedMacros");
void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros) const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{ {
REQUIRE_NOT_NULL(checkable); REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr); REQUIRE_NOT_NULL(cr);
@ -48,8 +48,8 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
if (Checkable::ExecuteCommandProcessFinishedHandler) { if (Checkable::ExecuteCommandProcessFinishedHandler) {
callback = Checkable::ExecuteCommandProcessFinishedHandler; callback = Checkable::ExecuteCommandProcessFinishedHandler;
} else { } else {
callback = [checkable, cr](const Value& commandLine, const ProcessResult& pr) { callback = [checkable, cr, producer](const Value& commandLine, const ProcessResult& pr) {
ProcessFinishedHandler(checkable, cr, commandLine, pr); ProcessFinishedHandler(checkable, cr, producer, commandLine, pr);
}; };
} }
@ -62,7 +62,8 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
} }
} }
void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr) void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const CheckResultProducer::Ptr& producer, const Value& commandLine, const ProcessResult& pr)
{ {
Checkable::CurrentConcurrentChecks.fetch_sub(1); Checkable::CurrentConcurrentChecks.fetch_sub(1);
Checkable::DecreasePendingChecks(); Checkable::DecreasePendingChecks();
@ -93,5 +94,5 @@ void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, co
cr->SetExecutionStart(pr.ExecutionStart); cr->SetExecutionStart(pr.ExecutionStart);
cr->SetExecutionEnd(pr.ExecutionEnd); cr->SetExecutionEnd(pr.ExecutionEnd);
checkable->ProcessCheckResult(cr); checkable->ProcessCheckResult(cr, producer);
} }

View File

@ -19,13 +19,13 @@ class PluginCheckTask
{ {
public: public:
static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr, static void ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros); const CheckResultProducer::Ptr& producer, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros);
private: private:
PluginCheckTask(); PluginCheckTask();
static void ProcessFinishedHandler(const Checkable::Ptr& service, static void ProcessFinishedHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr); const CheckResultProducer::Ptr& producer, const Value& commandLine, const ProcessResult& pr);
}; };
} }