Nagios – Monitoring IT Infrastructure

Nagios

Nagios is an open source software that is used for monitoring IT Infrastructure that includes servers, services, devices etc. and provides alerts in case of failures and also for resolutions from such failures.  NetSaint that was used to monitor the availability of resources in Network like hosts, services etc. is now called Nagios.  NAGIOS is an acronym that stands for ‘Nagios Ain’t Gonna Insist On Sainthood’.  Nagios is an open source Network Monitoring solution that comes with a GPL license.

Nagios – Features

  • An open source IT Infrastructure monitoring software
  • Nagios is based on Client/Server architecture.  
  • The agents are installed on remote machines that use polling to communicate the availability status to the server, where-in the information is populated and depicted using Nagios Graphical User Interface.  
  • It keeps a periodic watch on the status of Hosts and Services and alerts when these go down or are recovered from failures.  
  • It can monitor network services like ICMP, HTTP, FTP, SSH, SMTP, POP3 etc.  
  • It can also monitor the resources of the machine like CPU load, Memory load, Disk usage etc.  
  • A wide-variety of plugins are available that can be configured to monitor several different services and resources.  
  • It uses NRPE (Nagios Remote Plugin Executor) for monitoring remote hosts.  
  • NRPE is installed as a Nagios agent on the remote host, that uses polling mechanism and provides the status information to the Nagios server.  
  • We can define Host Groups and Service Groups in Nagios.  
  • Nagios provides Availability report on the basis of Hostgroup(s), Host(s), ServiceGroup(s), Service(s).  
  • We can schedule a Downtime for a Host or a Service in Nagios.  
  • We can configure Notifications to be done in Nagios via Email or SMS. 

Installing Nagios on Centos 6.2

This installation assumes that you have a running Centos 6.2 installed Linux machine and you wish to install Nagios on the top of it for the purpose of monitoring IT Infrastructure.

Download the following packages and copy them in the location /usr/local/src

  • nagios-3.4.4.tar.gz
  • nagios-plugins-1.4.16.tar.gz
  • nrpe-2.8.tar.gz

Installing Nagios

Extract nagios-3.4.4.targ.gz
Add a ‘nagios’ user and ‘nagcmd’ group.

useradd -m nagios
passwd nagios
<Enter password for nagios user>
<Confirm password for nagios user>

groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
tar -xvzf nagios-3.4.4.tar.gz

cd nagios
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode

Edit contacts.cfg file to add your details like name, email etc.
vi /usr/local/nagios/etc/objects/contacts.cfg
Change alias, email etc. as per your requirement
alias: Nagios Admin
email: <your email>

make install-webconf

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
<Enter new password>
<Confirm password>

service httpd restart

Install nagios plugins

tar -xvzf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
chkconfig –add nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start

Check SELinux settings:
getenforce
setenforce 0

To make this change permanent, you will have to modify the settings in /etc/selinux/config and reboot.
SELINUX=disabled
SELINUXTYPE=targeted

Goto web browser and try the url: http://localhost/nagios.

You will be prompted for authentication, enter the username and password defined in ealier steps and you will see the Nagios User Interface to start with it.

Install the NRPE Deamon:

cd /usr/local/src
tar -xvzf nrpe-2.8.tar.gz
cd nrpe-2.8
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the ‘only_from’ directive.

Add the following entry for the NRPE daemon to the /etc/services file
nrpe      5666/tcp      #NRPE

Restart xinetd Daemon
service xinetd restart

Make sure that nrpe daemon is running under xinetd
netstat -at | grep nrpe

The output of this command should show the following line:
tcp    0    0 *:nrpe     *:*      LISTEN

Run the check_nrpe plugin /usr/local/nagios/libexec/check_nrpe -H localhost
The following should get displayed:
NRPE v2.8

Open firewall rules if firewall is enabled.

Change NRPE settings from /usr/local/nagios/etc/nrpe.cfg

service xinetd restart
service nagios restart

For more information, please visit Nagios website: www.nagios.org