From 10c1d0e4c89cb1fd854cc0c539dc9347c4e67875 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 25 Nov 2019 18:11:06 +0100 Subject: [PATCH] IcingaDB: don't always set Comment#expire_time --- lib/icingadb/icingadb-objects.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 222aa99fa..b275335ee 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -970,7 +970,6 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a attributes->Set("entry_time", TimestampToMilliseconds(comment->GetEntryTime())); attributes->Set("is_persistent", comment->GetPersistent()); attributes->Set("is_sticky", comment->GetEntryType() == CommentAcknowledgement && comment->GetCheckable()->GetAcknowledgement() == AcknowledgementSticky); - attributes->Set("expire_time", TimestampToMilliseconds(comment->GetExpireTime())); Host::Ptr host; Service::Ptr service; @@ -985,6 +984,12 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a attributes->Set("service_id", "00000000000000000000000000000000"); } + auto expireTime (comment->GetExpireTime()); + + if (expireTime > 0) { + attributes->Set("expire_time", TimestampToMilliseconds(expireTime)); + } + return true; } @@ -1453,7 +1458,6 @@ void IcingaDB::SendAddedComment(const Comment::Ptr& comment) "entry_type", Convert::ToString(comment->GetEntryType()), "is_persistent", Convert::ToString((unsigned short)comment->GetPersistent()), "is_sticky", Convert::ToString((unsigned short)(comment->GetEntryType() == CommentAcknowledgement && comment->GetCheckable()->GetAcknowledgement() == AcknowledgementSticky)), - "expire_time", Convert::ToString(TimestampToMilliseconds(comment->GetExpireTime())), "event_id", Utility::NewUniqueID(), "event_type", "comment_add" }); @@ -1475,6 +1479,15 @@ void IcingaDB::SendAddedComment(const Comment::Ptr& comment) xAdd.emplace_back(GetObjectIdentifier(endpoint)); } + { + auto expireTime (comment->GetExpireTime()); + + if (expireTime > 0) { + xAdd.emplace_back("expire_time"); + xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expireTime))); + } + } + m_Rcon->FireAndForgetQuery(std::move(xAdd)); } @@ -1500,7 +1513,6 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment) "entry_type", Convert::ToString(comment->GetEntryType()), "is_persistent", Convert::ToString((unsigned short)comment->GetPersistent()), "is_sticky", Convert::ToString((unsigned short)(comment->GetEntryType() == CommentAcknowledgement && comment->GetCheckable()->GetAcknowledgement() == AcknowledgementSticky)), - "expire_time", Convert::ToString(TimestampToMilliseconds(comment->GetExpireTime())), "event_id", Utility::NewUniqueID(), "event_type", "comment_remove" }); @@ -1532,6 +1544,15 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment) xAdd.emplace_back("0"); } + { + auto expireTime (comment->GetExpireTime()); + + if (expireTime > 0) { + xAdd.emplace_back("expire_time"); + xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expireTime))); + } + } + m_Rcon->FireAndForgetQuery(std::move(xAdd)); }