Tuesday, June 9, 2015

Steps to delete a defunct nagios host from centreon mysql database

If you have deleted a Centreon host from GUI but still is shows in Centreon monitoring service status, you may need to clean up host and related services from MySQl DB.

Below is steps to delete a dead host. If select statement do not return any record, obviously, corresponding delete is not required.


# mysqld
myysql> connect centreon_status;

myysql> SELECT host_id        FROM nagios_hosts WHERE display_name LIKE '%deadsystem01%';
myysql> SELECT host_object_id FROM nagios_hosts WHERE display_name= 'deadsystem01';
myysql> SELECT *              FROM nagios_hosts WHERE display_name = 'deadsystem01';

myysql> DELETE from nagios_hosts WHERE  display_name = 'deadsystem01';


myysql> SELECT * FROM nagios_objects WHERE name1 = 'deadsystem01';
myysql> DELETE   FROM nagios_objects WHERE name1 = 'deadsystem01';


myysql> SELECT * FROM nagios_hostgroup_members WHERE host_object_id = '123456';
myysql> DELETE   FROM nagios_hostgroup_members WHERE host_object_id = '123456';


myysql> SELECT * FROM nagios_hosts WHERE host_object_id = '123456';
myysql> DELETE   FROM nagios_hosts WHERE host_object_id = '123456';


myysql> SELECT * FROM nagios_hoststatus WHERE host_object_id = '123456';
myysql> DELETE   FROM nagios_hoststatus WHERE host_object_id = '123456';


myysql> SELECT * FROM nagios_objects WHERE name1 = 'deadsystem01';
myysql> DELETE   FROM nagios_objects WHERE name1 = 'deadsystem01';


myysql> SELECT service_object_id FROM nagios_services WHERE host_object_id = '123456';
myysql> DELETE FROM nagios_services WHERE host_object_id = '123456';


myysql> SELECT * FROM nagios_servicestatus WHERE service_object_id = '$above_id';
myysql> DELETE   FROM nagios_servicestatus WHERE service_object_id = '$above_id';





No comments:

Post a Comment