Installing Nagios On Debian Lenny And Monitoring A Debian Lenny Server

Want to support HowtoForge? Become a subscriber!
 
Submitted by wayner (Contact Author) (Forums) on Fri, 2011-03-04 17:13. :: Debian | Monitoring

Installing Nagios On Debian Lenny And Monitoring A Debian Lenny Server

Introduction

Nagios is a monitoring solution for complex IT infrastructures, Nagios is easy to implement and can be extended by custom-modules, called plugins. In this howto I explain howto install Nagios on a Debian Lenny host and make the configuration for it. Furthermore we are going to install a second Debian machine which we monitor with remote and local plugins.

 

1. Installation Of Two Default Debian Machines

Prepare two Debian Lenny machines with a minimal setup. Build yourself a good working environment.

In this howto I will refer to the following default configuration:

  • Nagios Host:
    • Hostname: monitor
    • IP: 10.10.10.105
  • Example Server:
    • Hostname: server1
    • IP: 10.10.10.100

 

2. Install Nagios

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://10.10.10.105/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 Example Server

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         10.10.10.100
}
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=10.10.10.105

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 10.10.10.100 -c check_users

The output should be something like this:

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.