]> granicus.if.org Git - icinga2/commitdiff
Trigger added downtimes immediately if checkable is Not-OK
authorMichael Friedrich <michael.friedrich@gmail.com>
Sat, 7 Feb 2015 23:08:12 +0000 (00:08 +0100)
committerMichael Friedrich <michael.friedrich@gmail.com>
Sat, 7 Feb 2015 23:08:12 +0000 (00:08 +0100)
fixes #8389

lib/icinga/checkable-downtime.cpp

index f04c5a8a6e63797c4a7f5ef8f6981f8b1d56f582..d643aa1636cc0454df51ffcc877d00d1860d16ab 100644 (file)
@@ -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)