mirror of https://github.com/Icinga/icinga2.git
parent
05d0dc5683
commit
5492d6fac3
|
@ -105,7 +105,11 @@ void CheckerComponent::CheckTimerHandler(void)
|
||||||
m_IdleServices.erase(service);
|
m_IdleServices.erase(service);
|
||||||
m_PendingServices.insert(service);
|
m_PendingServices.insert(service);
|
||||||
|
|
||||||
service->BeginExecuteCheck(boost::bind(&CheckerComponent::CheckCompletedHandler, this, service));
|
try {
|
||||||
|
service->BeginExecuteCheck(boost::bind(&CheckerComponent::CheckCompletedHandler, this, service));
|
||||||
|
} catch (const exception& ex) {
|
||||||
|
Logger::Write(LogCritical, "checker", "Exception occured while checking service '" + service->GetName() + "': " + ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
tasks++;
|
tasks++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,13 +682,22 @@ void Service::BeginExecuteCheck(const function<void (void)>& callback)
|
||||||
scheduleInfo->Set("schedule_start", GetNextCheck());
|
scheduleInfo->Set("schedule_start", GetNextCheck());
|
||||||
scheduleInfo->Set("execution_start", Utility::GetTime());
|
scheduleInfo->Set("execution_start", Utility::GetTime());
|
||||||
|
|
||||||
vector<Value> arguments;
|
try {
|
||||||
arguments.push_back(static_cast<Service::Ptr>(GetSelf()));
|
vector<Value> arguments;
|
||||||
ScriptTask::Ptr task;
|
arguments.push_back(static_cast<Service::Ptr>(GetSelf()));
|
||||||
task = InvokeMethod("check", arguments, boost::bind(&Service::CheckCompletedHandler, this, scheduleInfo, _1, callback));
|
ScriptTask::Ptr task;
|
||||||
assert(task); /* TODO: gracefully handle missing methods */
|
task = InvokeMethod("check", arguments, boost::bind(&Service::CheckCompletedHandler, this, scheduleInfo, _1, callback));
|
||||||
|
Set("current_task", task);
|
||||||
|
} catch (...) {
|
||||||
|
/* something went wrong while setting up the method call -
|
||||||
|
* reschedule the service and call the callback anyway. */
|
||||||
|
|
||||||
Set("current_task", task);
|
UpdateNextCheck();
|
||||||
|
|
||||||
|
callback();
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
||||||
|
|
Loading…
Reference in New Issue