]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Fixed downtime start does not update actual_start_time
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 11 Aug 2016 10:10:04 +0000 (12:10 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 11 Aug 2016 10:10:27 +0000 (12:10 +0200)
fixes #12401

lib/db_ido/dbevents.cpp

index b3444ed0c36718ebceab98bd464f28a9adc2f0d9..37b8a17735346da1dcd4e33e0fc63777864b5675 100644 (file)
@@ -503,7 +503,15 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
        fields1->Set("duration", downtime->GetDuration());
        fields1->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
        fields1->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
-       fields1->Set("was_started", ((downtime->GetStartTime() <= Utility::GetTime()) ? 1 : 0));
+
+       /* flexible downtimes are started at trigger time */
+       if (downtime->GetFixed()) {
+               std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(downtime->GetStartTime());
+               fields1->Set("actual_start_time", DbValue::FromTimestamp(time_bag.first));
+               fields1->Set("actual_start_time_usec", time_bag.second);
+               fields1->Set("was_started", ((downtime->GetStartTime() <= Utility::GetTime()) ? 1 : 0));
+       }
+
        fields1->Set("is_in_effect", (downtime->IsInEffect() ? 1 : 0));
        fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
        fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */