Merge pull request #10379 from Icinga/set-cancel-time-conditionally

IcingaDB: Sync downtime `cancel_time` conditionally
This commit is contained in:
Yonas Habteab 2025-05-16 12:18:20 +02:00 committed by GitHub
commit 45c651499b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2131,7 +2131,6 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
"scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())), "scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())),
"has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()), "has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()),
"trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())), "trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())),
"cancel_time", Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())),
"event_id", CalcEventID("downtime_start", downtime), "event_id", CalcEventID("downtime_start", downtime),
"event_type", "downtime_start" "event_type", "downtime_start"
}); });
@ -2222,7 +2221,6 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
"scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())), "scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())),
"has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()), "has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()),
"trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())), "trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())),
"cancel_time", Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())),
"event_id", CalcEventID("downtime_end", downtime), "event_id", CalcEventID("downtime_end", downtime),
"event_type", "downtime_end" "event_type", "downtime_end"
}); });
@ -2242,6 +2240,11 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
xAdd.emplace_back(GetObjectIdentifier(triggeredBy)); xAdd.emplace_back(GetObjectIdentifier(triggeredBy));
} }
if (downtime->GetWasCancelled()) {
xAdd.emplace_back("cancel_time");
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())));
}
if (downtime->GetFixed()) { if (downtime->GetFixed()) {
xAdd.emplace_back("start_time"); xAdd.emplace_back("start_time");
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(downtime->GetStartTime()))); xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(downtime->GetStartTime())));