Nagios – System & Network Monitoring Tool

nagios

In any IT company, a lot of web projects runs simultaneously on many servers which can create heavy load on servers. You can not afford your servers gets down or becomes unresponsive due to heavy load, so to avoid such kind of situation, it becomes very important to keep an eye on all servers.In Linux servers, we usually use commands like ps, top, htop and many other commands to check the process status. But suppose you have more than 10 or 20 servers to manage, what will you do? Will you login in each server and run your favorite command to check the process status? I know it will make you a little frustrated and tired. But you do not need to worry about this,because there are a lot of network monitoring tool available for Linux and one of the most popular monitoring tool is ‘Nagios’.

Nagios is a system and network monitoring tool for Linux. It is available for most of the *NIX variants. You can configure and modify nagios according to your needs and manage it through graphical interface. Following are its major features:

  • Monitors network services such as HTTP,SMTP,PING,OPENSSH,SAMBA,SQUID and other running process
  • Monitors local resources such as disk space on server, Load on processor,server logs, memory usage etc.
  • Ability to send mails to administrator or others and report the status of all services
  • Web interface to view all servers process, notification,logs etc.
  • Authorization can be set to give view access to only authorized users

These are the few features and there are many other features which you will get to know, once you will configure it and start working with nagios.So here i am gonna show you how to configure Nagios server to monitor a remote server on your entire group of servers.

Note: Below configuration is made on CentOS 6. There can be a little difference in configuration method on other *Nix variants.

Lets start now. Following are the servers we have.

Nagios Server Hostname: nagios
Nagios Server IP: 192.168.0.2

Remote Server’s Hostname: Server1
Remote Server’s IP: 192.168.0.3

Step1. Install nagios packages.

 [root@nagios ~]# yum install *nagios*

Step2. Set nagios admin email id to get the mails from Nagios.

 [root@nagios ~]# vi /etc/nagios/objects/contacts.cfg

# line 35: change to admin’s address

 
vinod.pundir@linuxonlinesolutions.com

Step3. Set nagiosadmin password which you will use to get web interface access.

 
[root@nagios ~]# htpasswd -mc /etc/nagios/passwd nagiosadmin

Step4. Open nagios.cfg and define the file where you will define the services to be monitored.

 
[root@nagios ~]# vim /etc/nagios/nagios.cfg
 
cfg_file=/etc/nagios/objects/Server1.cfg
 
Step5. Open Server1.cfg and add the services.
 
define host{
use                     linux-server
host_name               Server1
alias                   Server1
address                 192.168.0.3
normal_check_interval           1
retry_check_interval            1
}
define service{
use                     generic-service
host_name               Server1
service_description     PING
check_command           check_ping!100.0,20%!500.0,60%
normal_check_interval           1
retry_check_interval            1
}
define service{
use                     generic-service
host_name               Server1
service_description     Current Users
check_command           check_nrpe!check_users
normal_check_interval           1
retry_check_interval            1
}
define service{
use                     generic-service
host_name               Server1
service_description     Server Load
check_command           check_nrpe!check_load
normal_check_interval           1
retry_check_interval            1
}
define service{
use                     generic-service
host_name               Server1
service_description     Disk Space
normal_check_interval           1
retry_check_interval            1
}
define service{
use                     generic-service
host_name               Server1
service_description     FTP
check_command           check_nrpe!check_localftp
normal_check_interval           1
retry_check_interval            1
}
define service{
use                       generic-service
host_name                  Server1
service_description       APACHE
check_command             check_nrpe!check_http
normal_check_interval           1
retry_check_interval            1
}
define service{
use                       generic-service
host_name                 Server1
service_description       SSH
check_command             check_nrpe!check_ssh
normal_check_interval           1
retry_check_interval            1
}

Step6. Start the nagios daemon.

 
[root@nagios ~]# service nagios start

NOw you can browse url:

 
http://192.168.0.2/nagios

Thats it.  We have configure nagios servers. Now we will configure Remote server so that Nagios server can get the updates from the remote server.

To Monitor Remote Server:

Step1. Install below packages.

 
[root@Server1 ~]# yum install nagios-plugins* nrpe

Step2. Open nrpe.cfg and the nagios servers ip address in allowed_hosts.

 [root@Server1 ~]# vim /etc/nagios/nrpe.cfg
 
allowed_hosts=127.0.0.1,192.168.0.2

Step3. Start the NRPE[Nagios Remote Plugin Executor].

 
[root@Server1 ~]# service nrpe start

Thats it. Client part is configured too. Now you can login to nagios servers web interface and get the latest status of Server1.

Some Useful commands:

To check nagios configuration:

 
nagios -v /etc/nagios/nagios.cfg

To Check connectivity with nrpe daemon of Remote Server:

 
/usr/lib/nagios/plugins/check_nrpe -H 192.168.0.3

 

You can leave a response, or trackback from your own site.

One Response to “Nagios – System & Network Monitoring Tool”

  1. Sara says:

    To make sure that you’ve defined the command on the remote server as check_all_diskscoamnmd[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20 -c 10. Also check to make sure that the check_disk binary actually exists.If both are there and correct then the final thing to check is that within your host Config you’re using NRPE to call the correct check_all_disks command.

Leave a Reply