From 5ec31aed14524bd83bfea032d77ca91115eb146f Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Mon, 9 Mar 2020 10:49:28 +0100 Subject: [PATCH] Downtime, Comment, Notification: Add host_id, if object_type is service --- lib/icingadb/icingadb-objects.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 32cf7edc3..b7550df30 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1005,10 +1005,9 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a attributes->Set("command_id", GetObjectIdentifier(notification->GetCommand())); + attributes->Set("host_id", GetObjectIdentifier(host)); if (service) attributes->Set("service_id", GetObjectIdentifier(service)); - else - attributes->Set("host_id", GetObjectIdentifier(host)); TimePeriod::Ptr timeperiod = notification->GetPeriod(); if (timeperiod) @@ -1039,13 +1038,13 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a Host::Ptr host; Service::Ptr service; tie(host, service) = GetHostService(comment->GetCheckable()); + + attributes->Set("host_id", GetObjectIdentifier(host)); if (service) { attributes->Set("object_type", "service"); attributes->Set("service_id", GetObjectIdentifier(service)); - } else { + } else attributes->Set("object_type", "host"); - attributes->Set("host_id", GetObjectIdentifier(host)); - } auto expireTime (comment->GetExpireTime()); @@ -1076,13 +1075,12 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a Service::Ptr service; tie(host, service) = GetHostService(downtime->GetCheckable()); + attributes->Set("host_id", GetObjectIdentifier(host)); if (service) { attributes->Set("object_type", "service"); attributes->Set("service_id", GetObjectIdentifier(service)); - } else { + } else attributes->Set("object_type", "host"); - attributes->Set("host_id", GetObjectIdentifier(host)); - } auto triggeredBy (Downtime::GetByName(downtime->GetTriggeredBy())); if (triggeredBy) {