mirror of https://github.com/Icinga/icinga2.git
Merge pull request #9122 from Icinga/bugfix/downtime-trigger-time
Set downtime trigger time deterministically
This commit is contained in:
commit
cbbaf4eac8
|
@ -327,7 +327,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsStateOK(new_state))
|
if (!IsStateOK(new_state))
|
||||||
TriggerDowntimes();
|
TriggerDowntimes(cr->GetExecutionEnd());
|
||||||
|
|
||||||
/* statistics for external tools */
|
/* statistics for external tools */
|
||||||
Checkable::UpdateStatistics(cr, checkableType);
|
Checkable::UpdateStatistics(cr, checkableType);
|
||||||
|
|
|
@ -16,10 +16,10 @@ void Checkable::RemoveAllDowntimes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checkable::TriggerDowntimes()
|
void Checkable::TriggerDowntimes(double triggerTime)
|
||||||
{
|
{
|
||||||
for (const Downtime::Ptr& downtime : GetDowntimes()) {
|
for (const Downtime::Ptr& downtime : GetDowntimes()) {
|
||||||
downtime->TriggerDowntime();
|
downtime->TriggerDowntime(triggerTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
int GetDowntimeDepth() const final;
|
int GetDowntimeDepth() const final;
|
||||||
|
|
||||||
void RemoveAllDowntimes();
|
void RemoveAllDowntimes();
|
||||||
void TriggerDowntimes();
|
void TriggerDowntimes(double triggerTime);
|
||||||
bool IsInDowntime() const;
|
bool IsInDowntime() const;
|
||||||
bool IsAcknowledged() const;
|
bool IsAcknowledged() const;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include <boost/thread/once.hpp>
|
#include <boost/thread/once.hpp>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ void Downtime::Start(bool runtimeCreated)
|
||||||
Log(LogNotice, "Downtime")
|
Log(LogNotice, "Downtime")
|
||||||
<< "Checkable '" << checkable->GetName() << "' already in a NOT-OK state."
|
<< "Checkable '" << checkable->GetName() << "' already in a NOT-OK state."
|
||||||
<< " Triggering downtime now.";
|
<< " Triggering downtime now.";
|
||||||
TriggerDowntime();
|
TriggerDowntime(checkable->GetLastStateChange());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetFixed() && CanBeTriggered()) {
|
if (GetFixed() && CanBeTriggered()) {
|
||||||
|
@ -138,7 +139,7 @@ void Downtime::Start(bool runtimeCreated)
|
||||||
OnDowntimeStarted(this);
|
OnDowntimeStarted(this);
|
||||||
|
|
||||||
/* Trigger fixed downtime immediately. */
|
/* Trigger fixed downtime immediately. */
|
||||||
TriggerDowntime();
|
TriggerDowntime(std::fmax(GetStartTime(), GetEntryTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +423,7 @@ bool Downtime::CanBeTriggered()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downtime::TriggerDowntime()
|
void Downtime::TriggerDowntime(double triggerTime)
|
||||||
{
|
{
|
||||||
if (!CanBeTriggered())
|
if (!CanBeTriggered())
|
||||||
return;
|
return;
|
||||||
|
@ -432,8 +433,9 @@ void Downtime::TriggerDowntime()
|
||||||
Log(LogInformation, "Downtime")
|
Log(LogInformation, "Downtime")
|
||||||
<< "Triggering downtime '" << GetName() << "' for checkable '" << checkable->GetName() << "'.";
|
<< "Triggering downtime '" << GetName() << "' for checkable '" << checkable->GetName() << "'.";
|
||||||
|
|
||||||
if (GetTriggerTime() == 0)
|
if (GetTriggerTime() == 0) {
|
||||||
SetTriggerTime(Utility::GetTime());
|
SetTriggerTime(triggerTime);
|
||||||
|
}
|
||||||
|
|
||||||
Array::Ptr triggers = GetTriggers();
|
Array::Ptr triggers = GetTriggers();
|
||||||
|
|
||||||
|
@ -445,7 +447,7 @@ void Downtime::TriggerDowntime()
|
||||||
if (!downtime)
|
if (!downtime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
downtime->TriggerDowntime();
|
downtime->TriggerDowntime(triggerTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +477,7 @@ void Downtime::DowntimesStartTimerHandler()
|
||||||
OnDowntimeStarted(downtime);
|
OnDowntimeStarted(downtime);
|
||||||
|
|
||||||
/* Trigger fixed downtime immediately. */
|
/* Trigger fixed downtime immediately. */
|
||||||
downtime->TriggerDowntime();
|
downtime->TriggerDowntime(std::fmax(downtime->GetStartTime(), downtime->GetEntryTime()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
void UnregisterChild(const Downtime::Ptr& downtime);
|
void UnregisterChild(const Downtime::Ptr& downtime);
|
||||||
std::set<Downtime::Ptr> GetChildren() const;
|
std::set<Downtime::Ptr> GetChildren() const;
|
||||||
|
|
||||||
void TriggerDowntime();
|
void TriggerDowntime(double triggerTime);
|
||||||
|
|
||||||
static String GetDowntimeIDFromLegacyID(int id);
|
static String GetDowntimeIDFromLegacyID(int id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue