mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
Fix ExecuteCommandProcessFinishedHandler parameters
This commit is contained in:
parent
b9510e72dd
commit
a3027d7177
@ -20,7 +20,7 @@ boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, cons
|
|||||||
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
||||||
|
|
||||||
static Timer::Ptr l_CheckablesFireSuppressedNotifications;
|
static Timer::Ptr l_CheckablesFireSuppressedNotifications;
|
||||||
thread_local std::function<void(const Checkable::Ptr&, const CheckResult::Ptr&, const Value& /* commandLine */, const ProcessResult&)> Checkable::ExecuteCommandProcessFinishedHandler;
|
thread_local std::function<void(const Value& commandLine, const ProcessResult&)> Checkable::ExecuteCommandProcessFinishedHandler;
|
||||||
|
|
||||||
void Checkable::StaticInitialize()
|
void Checkable::StaticInitialize()
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
DECLARE_OBJECTNAME(Checkable);
|
DECLARE_OBJECTNAME(Checkable);
|
||||||
|
|
||||||
static void StaticInitialize();
|
static void StaticInitialize();
|
||||||
static thread_local std::function<void(const Checkable::Ptr&, const CheckResult::Ptr&, const Value& /* commandLine */, const ProcessResult&)> ExecuteCommandProcessFinishedHandler;
|
static thread_local std::function<void(const Value& commandLine, const ProcessResult&)> ExecuteCommandProcessFinishedHandler;
|
||||||
|
|
||||||
Checkable();
|
Checkable();
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkable::ExecuteCommandProcessFinishedHandler = [listener, sourceEndpoint, origin, params] (const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const Value& commandLine, const ProcessResult& pr) -> void {
|
Checkable::ExecuteCommandProcessFinishedHandler = [checkable, listener, sourceEndpoint, origin, params] (const Value& commandLine, const ProcessResult& pr) {
|
||||||
Checkable::CurrentConcurrentChecks.fetch_sub(1);
|
Checkable::CurrentConcurrentChecks.fetch_sub(1);
|
||||||
Checkable::DecreasePendingChecks();
|
Checkable::DecreasePendingChecks();
|
||||||
|
|
||||||
@ -150,6 +150,7 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
|||||||
String output = pr.Output.Trim();
|
String output = pr.Output.Trim();
|
||||||
|
|
||||||
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
||||||
|
CheckResult::Ptr cr = new CheckResult();
|
||||||
cr->SetCommand(commandLine);
|
cr->SetCommand(commandLine);
|
||||||
cr->SetOutput(co.first);
|
cr->SetOutput(co.first);
|
||||||
cr->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
|
cr->SetPerformanceData(PluginUtility::SplitPerfdata(co.second));
|
||||||
@ -174,10 +175,8 @@ void ClusterEvents::ExecuteCheckFromQueue(const MessageOrigin::Ptr& origin, cons
|
|||||||
listener->SyncSendMessage(sourceEndpoint, executedMessage);
|
listener->SyncSendMessage(sourceEndpoint, executedMessage);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
Checkable::ExecuteCommandProcessFinishedHandler = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!listener->GetAcceptCommands()) {
|
if (!listener->GetAcceptCommands()) {
|
||||||
Log(LogWarning, "ApiListener")
|
Log(LogWarning, "ApiListener")
|
||||||
<< "Ignoring command. '" << listener->GetName() << "' does not accept commands.";
|
<< "Ignoring command. '" << listener->GetName() << "' does not accept commands.";
|
||||||
|
@ -44,15 +44,14 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
|||||||
timeout = checkable->GetCheckTimeout();
|
timeout = checkable->GetCheckTimeout();
|
||||||
|
|
||||||
|
|
||||||
|
std::function<void(const Value& commandLine, const ProcessResult&)> callback;
|
||||||
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
if (Checkable::ExecuteCommandProcessFinishedHandler) {
|
||||||
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
|
callback = Checkable::ExecuteCommandProcessFinishedHandler;
|
||||||
resolvers, resolvedMacros, useResolvedMacros, timeout,
|
|
||||||
std::bind(Checkable::ExecuteCommandProcessFinishedHandler, checkable, cr, _1, _2));
|
|
||||||
} else {
|
} else {
|
||||||
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
|
callback = std::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2);
|
||||||
resolvers, resolvedMacros, useResolvedMacros, timeout,
|
|
||||||
std::bind(&PluginCheckTask::ProcessFinishedHandler, checkable, cr, _1, _2));
|
|
||||||
}
|
}
|
||||||
|
PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(),
|
||||||
|
resolvers, resolvedMacros, useResolvedMacros, timeout, callback);
|
||||||
|
|
||||||
if (!resolvedMacros || useResolvedMacros) {
|
if (!resolvedMacros || useResolvedMacros) {
|
||||||
Checkable::CurrentConcurrentChecks.fetch_add(1);
|
Checkable::CurrentConcurrentChecks.fetch_add(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user