From 9dc37c58eafce45197b0c844acf48b270ec33be6 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 22 Jan 2016 18:42:15 +0100 Subject: [PATCH] DB IDO: Only update 'next_check' column when manually scheduling a check Otherwise the changes from #7287 already take care of setting the proper next check time from inside ProcessCheckResult(). There is no need to use the generic OnNextCheckChanged signal but instead we're using a new one, locally just for DB IDO. fixes #11019 --- lib/db_ido/dbevents.cpp | 4 ++-- lib/db_ido/dbevents.hpp | 2 +- lib/icinga/apiactions.cpp | 3 +++ lib/icinga/checkable-check.cpp | 1 + lib/icinga/checkable.hpp | 1 + lib/icinga/externalcommandprocessor.cpp | 18 ++++++++++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index bcd86b80d..e621ea8e5 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -51,7 +51,7 @@ void DbEvents::StaticInitialize(void) Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4)); Checkable::OnAcknowledgementCleared.connect(boost::bind(&DbEvents::RemoveAcknowledgement, _1)); - Checkable::OnNextCheckChanged.connect(boost::bind(&DbEvents::NextCheckChangedHandler, _1)); + Checkable::OnNextCheckUpdated.connect(boost::bind(&DbEvents::NextCheckUpdatedHandler, _1)); Checkable::OnFlappingChanged.connect(boost::bind(&DbEvents::FlappingChangedHandler, _1)); Checkable::OnNotificationSentToAllUsers.connect(boost::bind(&DbEvents::LastNotificationChangedHandler, _1, _2)); @@ -89,7 +89,7 @@ void DbEvents::StaticInitialize(void) } /* check events */ -void DbEvents::NextCheckChangedHandler(const Checkable::Ptr& checkable) +void DbEvents::NextCheckUpdatedHandler(const Checkable::Ptr& checkable) { Host::Ptr host; Service::Ptr service; diff --git a/lib/db_ido/dbevents.hpp b/lib/db_ido/dbevents.hpp index 89df2b469..8b870a13f 100644 --- a/lib/db_ido/dbevents.hpp +++ b/lib/db_ido/dbevents.hpp @@ -69,7 +69,7 @@ public: static void AddLogHistory(const Checkable::Ptr& checkable, String buffer, LogEntryType type); /* Status */ - static void NextCheckChangedHandler(const Checkable::Ptr& checkable); + static void NextCheckUpdatedHandler(const Checkable::Ptr& checkable); static void FlappingChangedHandler(const Checkable::Ptr& checkable); static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable); diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index c24ec908e..db8e8c3f2 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -128,6 +128,9 @@ Dictionary::Ptr ApiActions::RescheduleCheck(const ConfigObject::Ptr& object, checkable->SetNextCheck(nextCheck); + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(checkable); + return ApiActions::CreateResult(200, "Successfully rescheduled check for object '" + checkable->GetName() + "'."); } diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index c5dab8e84..0e3723dc2 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -39,6 +39,7 @@ boost::signals2::signal Checkable::OnStateChange; boost::signals2::signal, const MessageOrigin::Ptr&)> Checkable::OnReachabilityChanged; boost::signals2::signal Checkable::OnNotificationsRequested; +boost::signals2::signal Checkable::OnNextCheckUpdated; CheckCommand::Ptr Checkable::GetCheckCommand(void) const { diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 7ba0fad21..9ce25dbd1 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -126,6 +126,7 @@ public: static boost::signals2::signal OnAcknowledgementSet; static boost::signals2::signal OnAcknowledgementCleared; + static boost::signals2::signal OnNextCheckUpdated; static boost::signals2::signal OnEventCommandExecuted; /* Downtimes */ diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index fa1ff7f0e..e0a6b317e 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -382,6 +382,9 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vectorSetNextCheck(planned_check); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(host); } void ExternalCommandProcessor::ScheduleForcedHostCheck(double, const std::vector& arguments) @@ -396,6 +399,9 @@ void ExternalCommandProcessor::ScheduleForcedHostCheck(double, const std::vector host->SetForceNextCheck(true); host->SetNextCheck(Convert::ToDouble(arguments[1])); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(host); } void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vector& arguments) @@ -421,6 +427,9 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vectorSetNextCheck(planned_check); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(service); } void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const std::vector& arguments) @@ -435,6 +444,9 @@ void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const std::vector< service->SetForceNextCheck(true); service->SetNextCheck(Convert::ToDouble(arguments[2])); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(service); } void ExternalCommandProcessor::EnableHostCheck(double, const std::vector& arguments) @@ -516,6 +528,9 @@ void ExternalCommandProcessor::ScheduleForcedHostSvcChecks(double, const std::ve service->SetNextCheck(planned_check); service->SetForceNextCheck(true); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(service); } } @@ -543,6 +558,9 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const std::vectorGetName() << "'"; service->SetNextCheck(planned_check); + + /* trigger update event for DB IDO */ + Checkable::OnNextCheckUpdated(service); } }