How to Remove / Add hosts to Nagios

Add/Remove Host from Nagios

Default executable nagios will be in:

/usr/local/nagios/bin/nagios

While configuration will be in:

usr/local/nagios/etc/nagios.cfg

What if you did not find the binary and configuration files in the above folder, you can search for the binary and configuration location using 'ps' command like below:

ps -ef | grep nagios

Expected output will be like:

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

You can have a lot of information using above command line with below parameters:

/usr/local/nagios/bin/nagios [options] <main_config_file>

Use -v or --verify-config to verify all configuration data , Ex.:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Find Nagios version using --version:

/usr/local/nagios/bin/nagios --version

Output:
Nagios Core 4.0.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 02-28..............
..................

Other options:

-v, --verify-config Verify all configuration data (-v -v for more info)
-s, --test-scheduling Shows projected/recommended check scheduling and other
diagnostic info based on the current configuration files.
-T, --enable-timing-point Enable timed commentary on initialization
-x, --dont-verify-paths Deprecated (Don't check for circular object paths)
-p, --precache-objects Precache object configuration
-u, --use-precached-objects Use precached object config file
-d, --daemon Starts Nagios in daemon mode, instead of as a foreground process
-W, --worker /path/to/socket Act as a worker for an already running daemon

To remove old host that no longer there, add new node or modify existing one use the below steps:

vi /usr/local/nagios/etc/hosts.cfg

Search for desired hostname or IP and then simply comment out or delete the configuration group which they will look similar to below (to add new host you need to create one like below in the config file) :

## Default
define host{
use linux-box ; Inherit default values from a template
host_name myHostName ; The name we're giving to this server
alias CentOS 6 ; A longer name for the server
address 10.198.22.64 ; IP address of Remote Linux host
}

You need to restart or reload your Nagios after configuration changes, use below command to reload Nagios configuration:

/etc/rc.d/init.d/nagios reload

 

 


Subscribe to
for video tutorials updates