Monday, April 28, 2014

Steps to delete a nagios poller from centreon mysql database

You may need to delete a nagios poller from Centreon database in following cases:
(Assuming you are using MySQL DB as your centreon database.


  1. - Due to some reason, there are duplicate pollers ( 2 nagios pollers ID for same nagios poller hostname )
  2. - You are not able to delete a nagios poller from centreon UP
  3. - You have some checks associated with centreon hosts being monitored thru a nagios poller that have been removed without deleting associated service checks.


>> Take mysqlDB backup

# cd /var/lib/mysql/backup && mkdir new
#  innobackupex /var/lib/mysql/backup/new/
#  innobackupex --apply-log /var/lib/mysql/backup/new/2014-05-31_05-01-09/
# chown -R mysql:mysql backup

>> Delete Nagios poller from MySQl DB

# mysql
myysql> connect centreon_status;
mysql> select * from nagios_instances;
+-------------+------------------+----------------------+
| instance_id | instance_name    | instance_description |
+-------------+------------------+----------------------+
|          99 | nagiospoller99                          |
+-------------+------------------+----------------------+

>> Take backup of record being deleted.

# mysqldump centreon_status nagios_instances nagios_services nagios_hoststatus nagios_servicestatus --where 'instance_id=99' --compact -n -t > instancebackup.sql 

>> Delete poller from centreon_status tsable;

# mysqld
myysql> connect centreon_status;
mysql> delete from nagios_instances where instance_id=99;
mysql> delete from nagios_services where instance_id=99;
mysql> delete from nagios_hoststatus where instance_id=99;
mysql> delete from nagios_servicestatus where instance_id=99;

>> You are done !
>> In case you want to restore DB

- To restore partial backup

# cat instancebackup.sql | mysql 

- To restore full backup

service mysql stop 
cd /var/lib/mysql 
df -hP /var/lib/mysql # check if you have enough space
mkdir backup/old 
mv * backup/old 
mv backup/new/DATEOFBACKUP/* . 
chown -R mysql:mysql /var/lib/mysql 
service mysql start 

Reference one and two

No comments:

Post a Comment