Skip to content

Commit

Permalink
DB IDO: Only update 'next_check' column when manually scheduling a check
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Michael Friedrich committed Jan 22, 2016
1 parent 2a11b27 commit b960850
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/db_ido/dbevents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/db_ido/dbevents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DbEvents
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);

Expand Down
3 changes: 3 additions & 0 deletions lib/icinga/apiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() + "'.");
}

Expand Down
1 change: 1 addition & 0 deletions lib/icinga/checkable-check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, co
boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, StateType, const MessageOrigin::Ptr&)> Checkable::OnStateChange;
boost::signals2::signal<void (const Checkable::Ptr&, const CheckResult::Ptr&, std::set<Checkable::Ptr>, const MessageOrigin::Ptr&)> Checkable::OnReachabilityChanged;
boost::signals2::signal<void (const Checkable::Ptr&, NotificationType, const CheckResult::Ptr&, const String&, const String&)> Checkable::OnNotificationsRequested;
boost::signals2::signal<void (const Checkable::Ptr&)> Checkable::OnNextCheckUpdated;

CheckCommand::Ptr Checkable::GetCheckCommand(void) const
{
Expand Down
1 change: 1 addition & 0 deletions lib/icinga/checkable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class I2_ICINGA_API Checkable : public ObjectImpl<Checkable>
static boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType,
bool, double, const MessageOrigin::Ptr&)> OnAcknowledgementSet;
static boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> OnAcknowledgementCleared;
static boost::signals2::signal<void (const Checkable::Ptr&)> OnNextCheckUpdated;
static boost::signals2::signal<void (const Checkable::Ptr&)> OnEventCommandExecuted;

/* Downtimes */
Expand Down
18 changes: 18 additions & 0 deletions lib/icinga/externalcommandprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vector<Strin
planned_check = Utility::GetTime();

host->SetNextCheck(planned_check);

/* trigger update event for DB IDO */
Checkable::OnNextCheckUpdated(host);
}

void ExternalCommandProcessor::ScheduleForcedHostCheck(double, const std::vector<String>& arguments)
Expand All @@ -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<String>& arguments)
Expand All @@ -421,6 +427,9 @@ void ExternalCommandProcessor::ScheduleSvcCheck(double, const std::vector<String
planned_check = Utility::GetTime();

service->SetNextCheck(planned_check);

/* trigger update event for DB IDO */
Checkable::OnNextCheckUpdated(service);
}

void ExternalCommandProcessor::ScheduleForcedSvcCheck(double, const std::vector<String>& arguments)
Expand All @@ -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<String>& arguments)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -543,6 +558,9 @@ void ExternalCommandProcessor::ScheduleHostSvcChecks(double, const std::vector<S
<< "Rescheduling next check for service '" << service->GetName() << "'";

service->SetNextCheck(planned_check);

/* trigger update event for DB IDO */
Checkable::OnNextCheckUpdated(service);
}
}

Expand Down

0 comments on commit b960850

Please sign in to comment.