Page 1 of 1

Remove Pending service.

Posted: Sun Jan 02, 2022 11:20 pm
by safuanmansor
Hi ,

How do i remove the pending service that are not associated with any host/service?
It only show in XI and not in Core.

XI View
PendingService.PNG
Nagios Core View.
PendingService Core.PNG
Its been there for quite sometimes.

Thanks,
Safuan

Re: Remove Pending service.

Posted: Mon Jan 03, 2022 5:21 pm
by pbroste
Hello @safuanmansor

Thanks for reaching out, I see an earlier post that outlines which I went ahead blatantly copied from.

following as root to clear the message queue.

Code: Select all

postsuper -d ALL
You will also, have to run the following in a root shell to stop, truncate old data and start the processes. If you are using ndo2db please go ahead and refer to the instructions found here.

Code: Select all

service npcd stop
service nagios stop
service crond stop
pkill -9 -u nagios
Depending if your server is hosting the nagiosxi database in MYSQL, you would run this.

Code: Select all

echo "truncate table xi_events; truncate table xi_meta; truncate table xi_eventqueue;" | mysql -u root -pnagiosxi nagiosxi
If it is Postgress, run this

Code: Select all

echo "truncate table xi_events; truncate table xi_meta; truncate table xi_eventqueue;" | psql nagiosxi nagiosxi
FYI, you can run them both if you are unsure, just one of the commands will generate an error and that is normal.

Code: Select all

/usr/local/nagiosxi/scripts/repair_databases.sh
rm -f /usr/local/nagios/var/rw/nagios.cmd
rm -f /usr/local/nagios/var/nagios.lock
rm -f /var/run/nagios.lock
rm -f /var/lib/mrtg/mrtg_l
rm -f /usr/local/nagiosxi/var/*.lock
rm -f /usr/local/nagiosxi/tmp/*.lock
for i in `ipcs -q | grep nagios |awk '{print $2}'`; do ipcrm -q $i; done
service httpd restart  ## or systemctl start apache2 depending on distro
service nagios start
service npcd start
service crond start
let us know how things look,
Perry

Re: Remove Pending service.

Posted: Mon Jan 03, 2022 5:39 pm
by pbroste
Hello @safuanmanor

Please also run through the following to truncate the service status too:

Code: Select all

echo 'truncate nagios_hoststatus; truncate nagios_hosts; truncate nagios_services; truncate nagios_servicestatus;' |mysql -u root -pnagiosxi nagios
Thanks,
Perry

Re: Remove Pending service.

Posted: Wed Jan 05, 2022 3:23 am
by safuanmansor
Hi Perry

The long list step is meant for removing Notifications. Appreciate if you can pinpoint the only required command to remove the faulty services.

Is it safe to just leave those tables blank after truncate it?

Thanks,
Safuan

Re: Remove Pending service.

Posted: Wed Jan 05, 2022 12:46 pm
by pbroste
Hello @safuanmansor

Thanks for following up; you are correct that we don't need to concern with the message queue since that is not directly associated with the issue. To focus on the problem.

The issue is that there are "old leftover" data in the nagios database for those four tables, and they need to be truncated and the nagios process restarted so they will be repopulated when written to with up to date data.

First, let's make a backup of the database before truncating:

Code: Select all

mysqldump -uroot -pnagiosxi --all-databases | gzip -c > /tmp/nagios-databases.sql.gz
To truncate the four tables:

Code: Select all

echo 'truncate nagios_hoststatus; truncate nagios_hosts; truncate nagios_services; truncate nagios_servicestatus;' |mysql -u root -pnagiosxi nagios
Then restart the nagios service to sync/re-write to database:

Code: Select all

systemctl restart nagios
Please PM your updated system profile if the issue persists.

To send us your system profile.
  • Login to the Nagios XI GUI using a web browser.
  • Click the "Admin" > "System Profile" Menu
  • Click the "Download Profile" button
  • Save the profile.zip file and send via Private Message
Thanks,
Perry