Nagios Installation

1. Let’s assume we have the following configurations:

Nagios Host:
        Hostname: monitor
        IP: 172.20.10.217
		OS: Linux/Debian/Ubuntu
Example Server:
        Hostname: server1
        IP: 172.20.10.218
		OS: Linux/Debian/Ubuntu

2. Install Nagios in both servers

monitor:~# apt-get install nagios3 nagios-plugins nagios-nrpe-plugin
server1:~# apt-get install nagios-nrpe-server nagios-plugins

In the process of installing you get asked for samba workgroup and WINS Settings just let these set on default.

3. Putting up a basic nagios configuration on the monitoring host

To get access to the Nagios Configuration Page we have to set the password for the nagiosadmin user:

monitor:~# htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin

After this you should be able to login to: http://172.20.10.217/nagios3/ with the username nagiosadmin and the password you just set before.

If you go to the service detail site you will see that Nagios provides already a basic configuration for the localhost.

4. Install a webserver on the sample server1

server1:~# apt-get install apache2

5. Create a new config file on the nagios host

monitor:~# nano /etc/nagios3/conf.d/server1_nagios2.cfg

define host{
        use             generic-host
        host_name       server1
        alias           server1
        address         172.20.10.218
}
define service{
        use                     generic-service
        host_name               server1
        service_description     HTTP-Server
        check_command           check_http
}

Restart the nagios service with:

monitor:~# /etc/init.d/nagios3 restart

The ‘use’ variable in every object here indicates which template is used. The generic-host object can be found in the file /etc/nagios3/generic-host_nagios2.cfg, while the generic-service is determined in the file /etc/nagios3/generic-service_nagios2.cfg.

You should now be able to see the server1 and http service on the Service Detail Site of Nagios.

6. Prepare nrpe client on server1 to submit more data to nagios

We have to change the nrpe config of the server we want to overwatch, first change the line for the allowed host (line 79 by default):

server1:~# nano /etc/nagios/nrpe.cfg

From

allowed_hosts=127.0.0.1

to

allowed_hosts=172.20.10.217

Restart the nrpe service on server1:

server1:~# /etc/init.d/nagios-nrpe-server restart

Check the nrpe-service by hand before we continue to change the config. We do this from our Nagios host.

monitor:~# cd /usr/lib/nagios/plugins/
monitor:/usr/lib/nagios/plugins# ./check_nrpe -H 172.20.10.218 -c check_users

The output should be something like this:

USERS OK - 2 users currently logged in |users=2;5;10;0