mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Add timer to clean deadlined executions
This commit is contained in:
parent
53fa09d144
commit
19628252f8
@ -20,6 +20,7 @@ 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;
|
||||||
|
|
||||||
void Checkable::StaticInitialize()
|
void Checkable::StaticInitialize()
|
||||||
{
|
{
|
||||||
@ -78,6 +79,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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,3 +263,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -202,6 +202,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…
x
Reference in New Issue
Block a user