mirror of
https://github.com/Icinga/icinga2.git
synced 2026-06-11 01:30:22 -04:00
Merge 6b72dba228 into f63bbec4ab
This commit is contained in:
commit
7aa62bdc42
4 changed files with 25 additions and 2 deletions
|
|
@ -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 ({
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
22
test/icingadb-eventid.cpp
Normal 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);
|
||||
}
|
||||
Loading…
Reference in a new issue