×

Host Still Visible After Deletion in Nagios - How to resolve ?


Host Still Visible After Deletion in Nagios - How to resolve ?

Sometimes, though the host and its services delete successfully from the Core Config Manager it will be seen in the web UI.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform several Nagios queries.

In this context, we shall look into how to fix this error.


Nature of Host Still Visible After Deletion in Nagios

At times, it is possible to have multiple instances of Nagios running or to have so-called "ghost" hosts or services.

To check those multiple instances of Nagios, we run:

ps -ef | head -1 && ps -ef | grep bin/nagios
UID PID PPID C STIME TTY TIME CMD
nagios 3828 1 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios 3830 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3831 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3832 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3833 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3834 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3835 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
nagios 3840 3828 0 19:00 ? 00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root 6050 1785 0 19:05 pts/0 00:00:00 grep bin/nagios

In such a case, it is possible that we have "ghost" hosts or services. A config file that for some reason is "left behind" after deleting the host and its services in the Core Config Manager can cause Ghosts.

This problem was more common with older versions of Nagios XI. We suggest it would be a good idea to upgrade to the latest.


How to fix Host Still Visible After Deletion in Nagios ?

Initially, we run the below commands.


On RHEL 7|CentOS 7|Debian|Ubuntu 16/18:

$ systemctl stop nagios.service
killall nagios
systemctl start nagios.service

In the case of Ghosts, go to the Core Config Manager > Tools > Config File Management, use Write Configs to manually write out the configuration data to file.

Then use Verify Files to test configuration. If it verifies, go ahead and restart Nagios.

Suppose, we completely delete the host and all of its services in the Core Config Manager and the actual host config file is still there after using the Write Configs button, then go ahead and delete the config file manually.

We can find the files in the following directories:

/usr/local/nagios/etc/hosts
/usr/local/nagios/etc/services

For instance, to delete a "ghost" host, we go to the "hosts" directory:

cd /usr/local/nagios/etc/hosts

Then run the following command to view the configs sorted by modification time:

ls -lt

If we notice a configuration file with an old timestamp, it is possible this is a "ghost" host.

Eventually, to remove the config file, we run:

rm -f <ghost config>

In addition, a much easier way to resolve "ghost" host/services issues is to delete all host/service configuration files and then apply the configuration:

1. Go to the Core Config Manager.

2. Tools > Config File Management.

3. Click on Write Configs and Verify Files to check for config errors.

4. If there are no errors, click on Delete to remove all host and service configuration files.

5. Then, we apply the configuration. The configs will recreate with whatever is in the database.


[Need help with Nagios errors resolution? We are here for you. ]

Who We Are ?

Most prominent, efficient, and well-performing IT companies and software solutions.

Related Posts