diff --git a/lib/icinga/checkable-downtime.cpp b/lib/icinga/checkable-downtime.cpp index f04c5a8a6..d643aa163 100644 --- a/lib/icinga/checkable-downtime.cpp +++ b/lib/icinga/checkable-downtime.cpp @@ -73,7 +73,7 @@ String Checkable::AddDowntime(const String& author, const String& comment, if (!triggeredBy.IsEmpty()) { Downtime::Ptr triggerDowntime = GetDowntimeByID(triggeredBy); - + if (triggerDowntime) downtime->SetTriggeredByLegacyId(triggerDowntime->GetLegacyId()); } @@ -104,6 +104,14 @@ String Checkable::AddDowntime(const String& author, const String& comment, l_DowntimesCache[uid] = this; } + /* if this object is already in a NOT-OK state trigger this downtime now */ + if (GetStateRaw() != ServiceOK) { + Log(LogNotice, "Checkable") + << "Checkable '" << GetName() << "' already in a NOT-OK state." + << " Triggering downtime now."; + TriggerDowntime(uid); + } + Log(LogNotice, "Checkable") << "Added downtime with ID '" << downtime->GetLegacyId() << "' between '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", startTime)