Probably duplicate entry in icinga_hosts

I accidentally recognized a probably duplicate entry in icinga_hosts. Everything exactly the same (even config_hash) except host_id and host_object_id. I’d assume that’s not correct?

Icinga r2.11.1-1
mysql Ver 15.1 Distrib 10.1.41-MariaDB

The actual host name is stored in icinga_objects.name1, so a join is required to see that.

select oh.name1 as host_name, h.display_name as host_display_name, oh.object_id as object_id, oh.is_active as is_active from icinga_hosts h join icinga_objects oh on h.host_object_id=oh.object_id;

Cheers,
Michael

Hmm, still strange. The first entry has its fqdn as host_name and the second entry has its hostname as host_name. But there was no change with that host object (except the display name). Is it worth to investigate further on it?

You need to show me at least something which explains the difference even when hiding your company hosts :slight_smile:

With anonymized names:

MariaDB [icinga2]> select oh.name1 as host_name, h.display_name as host_display_name, oh.object_id as object_id, oh.is_active as is_active from icinga_hosts h join icinga_objects oh on h.host_object_id=oh.object_id;

+--------------------+-------------------+-----------+-----------+
| host_name         | host_display_name | object_id | is_active |
+--------------------+-------------------+-----------+-----------+
| icinga.example.com | icinga            |       265 |         1 |
| icinga             | icinga            |       638 |         0 |
| ...                |                   |           |           |
+--------------------+-------------------+-----------+-----------+

MariaDB [icinga2]> select * from icinga_objects where object_id=265;

+-----------+-------------+---------------+-------------------+-------+-----------+
| object_id | instance_id | objecttype_id | name1             | name2 | is_active |
+-----------+-------------+---------------+-------------------+-------+-----------+
|       265 |           1 |             1 | icinga.example.com | NULL  |         1 |
+-----------+-------------+---------------+-------------------+-------+-----------+

MariaDB [icinga2]> select * from icinga_objects where object_id=638;

+-----------+-------------+---------------+--------+-------+-----------+
| object_id | instance_id | objecttype_id | name1  | name2 | is_active |
+-----------+-------------+---------------+--------+-------+-----------+
|       638 |           1 |             1 | icinga | NULL  |         0 |
+-----------+-------------+---------------+--------+-------+-----------+

Ah, I see. is_active is set to 0 for the second host which means it was there in the past but now is not deployed anymore. Keeping those old objects in the database is for the historical data and required joins. If you require e.g. SLA reporting for decommissioned hosts, you can do so with modifying the SQL queries to also include is_active=0. By default, you don’t need to worry about this data, just ensure that you own custom queries always include is_active=1.

Cheers,
Michael