Monitoring the super computer with Nagios – Part 2: Adding More Hosts

Nagios stores all of its host configuration files in

/etc/nagios3/conf.d

In this folder we are interested in the config file

localhost_nagios2.cfg

We need to create one of these for each of the servers we want to monitor, so copy this file as many times as you have servers, each time your copy replace localhost in the name with the name of the server to monitor.
In this instance, I have 6 servers

sudo cp localhost_nagios2.cfg rasp-blue_nagios2.cfg
sudo cp localhost_nagios2.cfg rasp-green_nagios2.cfg
sudo cp localhost_nagios2.cfg rasp-white_nagios2.cfg
sudo cp localhost_nagios2.cfg rasp-yellow_nagios2.cfg
sudo cp localhost_nagios2.cfg rasp-purple_nagios2.cfg
sudo cp localhost_nagios2.cfg rasp-red_nagios2.cfg

For each file, open up in your editor and replace every instance of localhost with the name of the service

define host{
use generic-host
host_name REMOTESERVER ; Change to the remote server's hostname and domain name.
alias REMOTESERVER    ; Change to the remote server's hostname
address 5.6.7.8    ; Change to the remote server's IP address (WAN?)
}

define service{
use generic-service
host_name REMOTESERVER ; Change to the remote server's hostname and domain name.
service_description Disk Space 1
check_command check_nrpe!check_sda1
}

define service{
use generic-service
host_name REMOTESERVER ; Change to the remote server's hostname and domain name.
service_description Current Users
check_command check_nrpe!check_users
}

define service{
use generic-service
host_name REMOTESERVER.EXAMPLE.COM    ; Change to the remote server's hostname and domain name.
service_description Total Processes
check_command check_nrpe!check_total_procs
}

define service{
use generic-service
host_name REMOTESERVER ; Change to the remote server's hostname and domain name.
service_description Current Load
check_command check_nrpe!check_load
}

Next we tell Nagios what services are running on each server. This is contained in the file hostgroups_nagios2.cfg. Add the name of each server to the list of members for each service to monitor

# Some generic hostgroup definitions

# A simple wildcard hostgroup
define hostgroup {
        hostgroup_name  all
                alias           All Servers
                members         *
        }

# A list of your Debian GNU/Linux servers
define hostgroup {
        hostgroup_name  debian-servers
                alias           Debian GNU/Linux Servers
                members         localhost, raspi-blue, raspi-green, raspi-white, raspi-yellow, raspi-purple, raspi-red
        }

# A list of your web servers
define hostgroup {
        hostgroup_name  http-servers
                alias           HTTP servers
                members         localhost, raspi-blue, raspi-green, raspi-white, raspi-yellow, raspi-purple, raspi-red
        }

# A list of your ssh-accessible servers
define hostgroup {
        hostgroup_name  ssh-servers
                alias           SSH servers
                members         localhost, raspi-blue, raspi-green, raspi-white, raspi-yellow, raspi-purple, raspi-red
        }

Now we restart Nagios and we’ll see each of the servers

sudo /etc/init.d/nagios3 restart

This information was scammed from Will Bradleys website, which is an excellent source of information on configuring nagios

Your email address will not be published. Required fields are marked *