mirror of https://github.com/Icinga/icinga2.git
Merge branch 'feature/v1-actions-execute-command-8034-deadline-timer' into feature/v1-actions-execute-command-8034
refs #8034
This commit is contained in:
commit
fe4a44096a
|
@ -20,6 +20,8 @@ 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;
|
||||||
|
static Timer::Ptr l_CleanDeadlinedExecutions;
|
||||||
|
|
||||||
thread_local std::function<void(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()
|
||||||
|
@ -79,6 +81,11 @@ void Checkable::Start(bool runtimeCreated)
|
||||||
l_CheckablesFireSuppressedNotifications->SetInterval(5);
|
l_CheckablesFireSuppressedNotifications->SetInterval(5);
|
||||||
l_CheckablesFireSuppressedNotifications->OnTimerExpired.connect(&Checkable::FireSuppressedNotifications);
|
l_CheckablesFireSuppressedNotifications->OnTimerExpired.connect(&Checkable::FireSuppressedNotifications);
|
||||||
l_CheckablesFireSuppressedNotifications->Start();
|
l_CheckablesFireSuppressedNotifications->Start();
|
||||||
|
|
||||||
|
l_CleanDeadlinedExecutions = new Timer();
|
||||||
|
l_CleanDeadlinedExecutions->SetInterval(300);
|
||||||
|
l_CleanDeadlinedExecutions->OnTimerExpired.connect(&Checkable::CleanDeadlinedExecutions);
|
||||||
|
l_CleanDeadlinedExecutions->Start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,3 +265,34 @@ void Checkable::ValidateMaxCheckAttempts(const Lazy<int>& lvalue, const Validati
|
||||||
if (lvalue() <= 0)
|
if (lvalue() <= 0)
|
||||||
BOOST_THROW_EXCEPTION(ValidationError(this, { "max_check_attempts" }, "Value must be greater than 0."));
|
BOOST_THROW_EXCEPTION(ValidationError(this, { "max_check_attempts" }, "Value must be greater than 0."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Checkable::CleanDeadlinedExecutions(const Timer * const&)
|
||||||
|
{
|
||||||
|
double now = Utility::GetTime();
|
||||||
|
Dictionary::Ptr executions;
|
||||||
|
Dictionary::Ptr execution;
|
||||||
|
|
||||||
|
for (auto& host : ConfigType::GetObjectsByType<Host>()) {
|
||||||
|
executions = host->GetExecutions();
|
||||||
|
if (executions) {
|
||||||
|
for (const String& key : executions->GetKeys()) {
|
||||||
|
execution = executions->Get(key);
|
||||||
|
if (execution->Contains("deadline") && now > execution->Get("deadline")) {
|
||||||
|
executions->Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& service : ConfigType::GetObjectsByType<Service>()) {
|
||||||
|
executions = service->GetExecutions();
|
||||||
|
if (executions) {
|
||||||
|
for (const String& key : executions->GetKeys()) {
|
||||||
|
execution = executions->Get(key);
|
||||||
|
if (execution->Contains("deadline") && now > execution->Get("deadline")) {
|
||||||
|
executions->Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -205,6 +205,7 @@ private:
|
||||||
static void NotifyDowntimeEnd(const Downtime::Ptr& downtime);
|
static void NotifyDowntimeEnd(const Downtime::Ptr& downtime);
|
||||||
|
|
||||||
static void FireSuppressedNotifications(const Timer * const&);
|
static void FireSuppressedNotifications(const Timer * const&);
|
||||||
|
static void CleanDeadlinedExecutions(const Timer * const&);
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
std::set<Comment::Ptr> m_Comments;
|
std::set<Comment::Ptr> m_Comments;
|
||||||
|
|
Loading…
Reference in New Issue