OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

2.3. Configuration

• 1. First, create a host configuration file for server02. Unless otherwise specified, run all these commands on server01. In a terminal enter:


sudo cp /etc/nagios3/conf.d/localhost_nagios2.cfg \

/etc/nagios3/conf.d/server02.cfg


image

In the above and following command examples, replace "server01", "server02" 172.18.100.100, and 172.18.100.101 with the host names and IP addresses of your servers.

2. Next, edit /etc/nagios3/conf.d/server02.cfg:


define host{

use generic-host ; Name of host template to use

host_name server02

alias Server 02

address 172.18.100.101

}


# check DNS service. define service {

use generic-service

host_name server02

service_description DNS

check_command check_dns!172.18.100.101

}

3. Restart the nagios daemon to enable the new configuration:


sudo systemctl restart nagio3.service


• 1. Now add a service definition for the MySQL check by adding the following to /etc/nagios3/conf.d/ services_nagios2.cfg:


# check MySQL servers. define service {

hostgroup_name mysql-servers service_description MySQL

check_command check_mysql_cmdlinecred!nagios!secret!$HOSTADDRESS use generic-service

notification_interval 0 ; set > 0 if you want to be renotified

}

2. A mysql-servers hostgroup now needs to be defined. Edit /etc/nagios3/conf.d/ hostgroups_nagios2.cfg adding:


# MySQL hostgroup. define hostgroup {

hostgroup_name mysql-servers

alias MySQL servers

members localhost, server02

}

3. The Nagios check needs to authenticate to MySQL. To add a nagios user to MySQL enter:


mysql -u root -p -e "create user nagios identified by 'secret';"


image

The nagios user will need to be added all hosts in the mysql-servers hostgroup.


4. Restart nagios to start checking the MySQL servers.


sudo systemctl restart nagios3.service

• 1. Lastly configure NRPE to check the disk space on server02.


On server01 add the service check to /etc/nagios3/conf.d/server02.cfg:


# NRPE disk check. define service {

use generic-service

host_name server02 service_description nrpe-disk

check_command check_nrpe_1arg!check_all_disks!172.18.100.101

}

2. Now on server02 edit /etc/nagios/nrpe.cfg changing:


allowed_hosts=172.18.100.100


And below in the command definition area add:



command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -e

3. Finally, restart nagios-nrpe-server:


sudo systemctl restart nagios-nrpe-server.service

4. Also, on server01 restart nagios:


sudo systemctl restart nagios3.service


You should now be able to see the host and service checks in the Nagios CGI files. To access them point a browser to http://server01/nagios3. You will then be prompted for the nagiosadmin username and password.


Top OS Cloud Computing at OnWorks: