Nagios: Monitor Hosts and Services (Part-1)

What is Nagios?
Nagios is an open source software that can be used for network and infrastructure monitoring. Nagios monitors servers, switches, applications and services. It alerts the System Administrator when something went wrong and also alerts back when the issues have been rectified.
Nagios designed to run under Linux distributions such as Red Hat, Centos and Fedora etc.

Some of the many features of Nagios include:
i. Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
ii. Monitoring of host resources (processor load, disk usage, etc.)
iii. Simple plugin design that allows users to easily develop their own service checks
iv. Parallelized service checks
v. Contact notifications when service or host problems occur and get resolved via email
vi. Automatic log file rotation
vii. Support for implementing redundant monitoring hosts
viii. Optional web interface for viewing current network status, notification and problem history, log file, etc.

Different types of Nagios:
There are many different types of Nagios Monitoring system such as Nagios Core, Nagios Log Server, Nagios Fusion, Nagios XI, Nagios Network Analyzer etc. Here I shall try to discuss Nagios Core monitoring system.

In this tutorial, i am going to use two systems as mentioned below.

Nagios Server:
Operating System: Centos 7 minimal server
IP Address :
SeLinux : disabled/permissive

Nagios Client:
Operating System: Centos 7 minimal server
IP Address :
SeLinux : disabled/permissive

Before installing Nagios, make sure the packages installed in our server.
# yum install -y httpd php
# yum install -y gcc glibc glibc-common make gd gd-devel net-snmp wget

Create Nagios user and group
# useradd nagios
# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache

Next step is to download the installation packages. Create a new directory to store the downloaded contents:
# mkdir ~/nagios
# cd ~/nagios
# wget
# wget
# tar zxvf nagios-4.0.7.tar.gz
# tar zxvf nagios-plugins-2.0.3.tar.gz

Now we need to compile and install the files so we go to the Nagios directory and run the configuration script
# cd nagios-4.0.7
# ./configure –with-command-group=nagcmd
# make all
# make install
Finally we need to install the init scripts, the required files to run Nagios from the command line and the sample configuration files with the following commands:
# make install-init
# make install-commandmode
# make install-config

Install Nagios Web Interface:
Enter the following commands to compile and install nagios web interface.
# make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Set the password running the following command and enter the password twice:

# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
# systemctl start httpd.service
# systemctl enable httpd

Install Nagios Plugins

# cd ~/nagios/nagios-plugins-2.0.3
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install

Next we have to make Nagios start at boot time, so first verify that the configuration file has no errors running the following command:

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If everything is fine add the service to run on boot with this commands:

# chkconfig –add nagios
# chkconfig –level 35 nagios on
# systemctl start nagios.service

Access Web Interface
http://localhost/nagios or http://server-ip/nagios
user name: nagiosadmin
Password: password

To get email alerts for this user, Edit the /usr/local/nagios/etc/objects/contacts.cfg config file and put the actual email address.

define contact {
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin

See More at Nagios: Monitor Hosts and Services (Part-2)