Icinga2: DB IDO: Delete old hosts/services

Created on 20 Sep 2017  路  6Comments  路  Source: Icinga/icinga2

I just try to migrate from Icinga 1 System with icinga-idoutils (1.11.6-1+b4) to Icinga2 with icinga2-ido-mysql (2.7.0-1.stretch).
Now I found, that in the new Icinga2 system old Hosts aren鈥檛 deleted anymore in the Database, although they are completely deleted from Icinga2 config.

Expected Behavior

Deleting a Host in Icinga2 should delete that host in the ido database (as the old icinga1 version does).

Current Behavior

Old hosts stay in the database.

Workaround (quick and dirty)

DELETE icinga_hosts, icinga_hoststatus FROM icinga_hosts
INNER JOIN icinga_hoststatus ON icinga_hosts.host_object_id = icinga_hoststatus.host_object_id
WHERE icinga_hoststatus.status_update_time < cast((now() - interval 1 day) as date);

DELETE icinga_services, icinga_servicestatus FROM icinga_services
INNER JOIN icinga_servicestatus ON icinga_services.service_object_id = icinga_servicestatus.service_object_id
WHERE icinga_servicestatus.status_update_time < cast((now() - interval 3 day) as date);

Steps to Reproduce (for bugs)

  1. Create new Host with checkalive and reload
  2. Wait so ido db can also create the host
  3. Delete the Host from icinga config and reload
  4. Wait, but it will newer deleted from ido db

Context

I am also using the Icinga Director, but IMHO this should not made any difference.
Some problem exist for services.

Your Environment

  • Director version: master (last update: 20.09.2017)
  • Icinga Web 2 version and modules: 2.4.1-2.stretch
  • Icinga 2 version: 2.7.0-1.stretch
  • Enabled features: api checker command ido-mysql influxdb mainlog notification
  • Operating System and version: Debian 9 (stretch)
  • Webserver, DB, PHP versions: Apache 2.4.25-3+deb9u2, mariadb-10.1.26-0+deb9u1, PHP 7.0.19-1
no-issue

Most helpful comment

This is intentional because removing objects would render IDs in other history tables unusable. You need to check the is_active column in the icinga_objects table to see whether an object still exists.

All 6 comments

This is intentional because removing objects would render IDs in other history tables unusable. You need to check the is_active column in the icinga_objects table to see whether an object still exists.

I'm running into this behavior as well- I set up both a localhost service and a "hostname-of-localhost" service when experimenting with the configuration, and now I can't get rid of one or the other despite standardizing on "localhost".

Is it expected behavior? It seems that I will now have an obsolete "hostname-of-localhost" service indefinitely. Should mark "hostname-of-localhost" as "not active", and how do I do that? This looks like it will lead to necessarily conflicting information, where lookups of the same node via different paths (localhost or by correct hostname) will give different results.

@tim-win How did you solve your problem with orphaned status-entrys in icingaweb?

I had a small enough test environment to blow away the database and start from scratch.

@gunnarbeutner Can this be repopened, as there still doesn't seem to be a way to set the active behavior of hosts, or conversely can you link the documentation to how to set active behavior of hosts (as this is indexed by google and now a _definitive source_).

Please move this discussion to https://community.icinga.com

If you'd like to move to a new location- can you start a conversation there and provide a link? this is the first google result when you search for a similar string.

Was this page helpful?
0 / 5 - 0 ratings