From 7acec6fc36a878bae1806bd8964d34170be1a4c3 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 14 Mar 2025 11:36:37 +0100 Subject: [PATCH] IcingaDB: Set downtime `cancel_time` conditionally If the downtime ended automatically `cancel_time` should just be `NULL` instead of a `0` timestamp. --- lib/icingadb/icingadb-objects.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 29f946708..914d46bc0 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -2221,7 +2221,6 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime) "scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())), "has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()), "trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())), - "cancel_time", Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())), "event_id", CalcEventID("downtime_end", downtime), "event_type", "downtime_end" }); @@ -2241,6 +2240,11 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime) xAdd.emplace_back(GetObjectIdentifier(triggeredBy)); } + if (downtime->GetWasCancelled()) { + xAdd.emplace_back("cancel_time"); + xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime()))); + } + if (downtime->GetFixed()) { xAdd.emplace_back("start_time"); xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(downtime->GetStartTime())));