This commit is contained in:
Manas Singh 2026-05-23 16:10:05 +08:00 committed by GitHub
commit 7aa62bdc42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 2 deletions

View file

@ -1905,7 +1905,7 @@ void IcingaDB::SendStateChange(const ConfigObject::Ptr& object, const CheckResul
auto eventTime (cr->GetExecutionEnd());
auto eventTs (TimestampToMilliseconds(eventTime));
Array::Ptr rawId = new Array({m_EnvironmentId, object->GetName()});
Array::Ptr rawId = new Array({m_EnvironmentId, GetObjectIdentifier(object)});
rawId->Add(eventTs);
RedisConnection::Query xAdd ({

View file

@ -92,7 +92,7 @@ String IcingaDB::GetObjectIdentifier(const ConfigObject::Ptr& object)
*/
String IcingaDB::CalcEventID(const char* eventType, const ConfigObject::Ptr& object, double eventTime, NotificationType nt)
{
Array::Ptr rawId = new Array({object->GetName()});
Array::Ptr rawId = new Array({GetObjectIdentifier(object)});
rawId->Insert(0, m_EnvironmentId);
rawId->Insert(1, eventType);

View file

@ -61,6 +61,7 @@ if(ICINGA2_WITH_PGSQL)
endif()
if(ICINGA2_WITH_ICINGADB)
list(APPEND types_test_SOURCES icingadb-eventid.cpp)
list(APPEND types_test_SOURCES $<TARGET_OBJECTS:icingadb>)
endif()

22
test/icingadb-eventid.cpp Normal file
View file

@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "icingadb/icingadb.hpp"
#include "icinga/host.hpp"
#include <BoostTestTargetConfig.h>
using namespace icinga;
BOOST_AUTO_TEST_CASE(calc_event_id_uses_object_identifier)
{
Host::Ptr host = new Host();
host->SetName("master01");
host->SetIcingadbIdentifier("id-a");
auto first = IcingaDB::CalcEventID("state_change", host, 1710000000.123);
host->SetIcingadbIdentifier("id-b");
auto second = IcingaDB::CalcEventID("state_change", host, 1710000000.123);
BOOST_CHECK_NE(first, second);
}