From 74209bde406b39a288890437d7e20ea7010edc1b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 13 Mar 2014 14:09:52 +0100 Subject: [PATCH] Reschedule services before running checks. Fixes #5754 --- components/cluster/clusterchecktask.cpp | 6 ++---- components/cluster/clusterchecktask.h | 2 +- lib/icinga/service-check.cpp | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/cluster/clusterchecktask.cpp b/components/cluster/clusterchecktask.cpp index 4b56d7924..c6e73e82c 100644 --- a/components/cluster/clusterchecktask.cpp +++ b/components/cluster/clusterchecktask.cpp @@ -35,7 +35,7 @@ using namespace icinga; REGISTER_SCRIPTFUNCTION(ClusterCheck, &ClusterCheckTask::ScriptFunc); -CheckResult::Ptr ClusterCheckTask::ScriptFunc(const Service::Ptr&) +void ClusterCheckTask::ScriptFunc(const Service::Ptr& service, const CheckResult::Ptr& cr) { /* fetch specific cluster status */ std::pair stats; @@ -63,13 +63,11 @@ CheckResult::Ptr ClusterCheckTask::ScriptFunc(const Service::Ptr&) " Endpoints (" + not_connected_endpoints + ") not connected."; } - CheckResult::Ptr cr = make_shared(); cr->SetOutput(output); cr->SetPerformanceData(perfdata); cr->SetState(state); cr->SetCheckSource(IcingaApplication::GetInstance()->GetNodeName()); - - return cr; + service->ProcessCheckResult(cr); } String ClusterCheckTask::FormatArray(const Array::Ptr& arr) diff --git a/components/cluster/clusterchecktask.h b/components/cluster/clusterchecktask.h index d34ddd3a5..126159a61 100644 --- a/components/cluster/clusterchecktask.h +++ b/components/cluster/clusterchecktask.h @@ -33,7 +33,7 @@ namespace icinga class ClusterCheckTask { public: - static CheckResult::Ptr ScriptFunc(const Service::Ptr& service); + static void ScriptFunc(const Service::Ptr& service, const CheckResult::Ptr& cr); private: ClusterCheckTask(void); diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index 4a2ab06f3..5d4679007 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -489,6 +489,8 @@ void Service::ExecuteCheck(void) ASSERT(!OwnsLock()); + UpdateNextCheck(); + bool reachable = IsReachable(); { @@ -505,8 +507,6 @@ void Service::ExecuteCheck(void) SetLastReachable(reachable); } - UpdateNextCheck(); - /* keep track of scheduling info in case the check type doesn't provide its own information */ double scheduled_start = GetNextCheck(); double before_check = Utility::GetTime(); -- 2.40.0