Nagios tool for server Monitoring


Nagios is very popular open source monitoring tools we can monitor anything, you will be able to monitor hosts resources by  web interface. Nagios is useful for keeping an inventory of your servers, and making sure your critical services are up and running. For using a monitoring system, like Nagios, is an essential tool for any production server environment.

You will also use of or  utilize the Nagios Remote Plugin Executor (NRPE), that will be installed and configured as an agent on remote hosts (Clients), to monitor their local resources.There are many things that Nagios  can monitor

  • Hosts
  • Services
  • Logs
  • Interaction and connectivity
  • Network’s Security
  • System Perfomance etc

How it works

Nagios is very powerful  monitoring tool, that provides you the clarification or awareness of company’s critical IT- Infrastructure. And it allow to you detect the problems or issues and resolve them and make sure for future issue send notification before they affect server/system  or automatically fix problems when they are detected & co-ordinate with Tech Team.

Ngios monitoring by two method,

  1. Active Checks
  2. Passive checks

Active checks are initiated and performed by nagios while passive checks are performed by external application.

so here below the most important features of Nagios.

  • Monitoring :  Tech IT – team configure Nagios to monitor our critical IT infrastructure components, including system metrics,  applications, services, network protocols, servers, and network infrastructure.
  • Alerting : Nagios sends alert when detect the problems or issues with critical IT infrastructure send notification before they affect server/system. Alerts can be delivered via email, SMS, or custom script.
  • Reporting : Nagios reports provide a historical record of outages, events, notifications, and alert response for later review. Availability reports help ensure your SLAs are being met.
  • Planning : Nagios  provides the graph and reports allow to identify necessary infrastructure upgrades before failures occur.

HOW to INSTAll – Nagios core

  • We must have create a nagios user and group that will run the Nagios process.
  • We have to install latest Nagios source code from here and configure.
  • Install and configure Nagios Plugin “NRPE” download from here NRPE downloads page. Nagios Plugins – ‘/etc/xinetd.d/nrpe ‘  NRPE- Nagios Remote Plugins Executor, xinetd- startup script (xinetd-script).
  • Install apache.utils to setup Nagios web interface.Use htpasswd to create an admin user, called “nagiosadmin”, that can access the Nagios web interface.
  • Create a list of hosts and services and configure for getting notification typically email & sms. Also you can view status information at anytime.
  • It is uses an object and template based configuration system.
  • Also must be installed few development libraries.

Configuration file

  • Resource file – It is used to store sensitive information like username, password.
  • Object Definition files – It is the location where you define all things, you want to monitor and how you want to monitor. It used to define ‘ Hosts, Services, Host_Groups, Contacts_groups command etc.

Now, these instructions explain the steps  to understand install Nagios Core and get it running on an Amazon EC2 instance using the Amazon Linux AMI for the  Linux OS. Also these instruction will work equally well with Linux on  server/system running any Red Hat variety of Linux such as CentOS, Ubuntu(some configuration could be differ).

1.create a nagios user and group that will run the 
Nagios process:

$ sudo useradd nagios

Then create a new nagioscmd group for allowing external 
commands to be submitted through the web interface:

$ sudo  groupadd nagioscmd
$ sudo  usermod -a -G nagcmd nagios
$ sudo  usermod -a -G nagioscmd nagios
$ sudo  usermod -G nagioscmd apache 
2.Download Nagios Core and the Plugins

$ curl -L -O

Compile and Install Nagios, Extract the Nagios source code.

$ sudo tar xvf nagios-4.1.1.tar.gz

$ cd  nagios-4.1.1

3.Run the Nagios configure script, passing the name of the
 group you created earlier like so.

$ sudo  ./configure ./configure --with-command-group=nagioscmd
$ sudo make all    (Compile the Nagios source code )

Install binaries, init script, sample config files and set
permissions on the external command directory. 

$ sudo make install-sh 
$ sudo make install
$ sudo make install-init
$ sudo make install-config
$ sudo make install-commandmode
4. Customize the Nagios's Configuration:
Edit the /usr/local/nagios/etc/objects/contacts.cfg config 
file with editor(vim, vi nano etc)and change the email address
associated with the ngiosadmin contact definition to the 
address you'd like to use for receiving alerts.

$ cd 
$ sudo vim /usr/local/nagios/etc/objects/contacts.cfg
5. Configure Nagios wen interface:
Use htpasswd to create an admin user, called "nagiosadmin",
that can access the Nagios web interface

$ cd nagios-4.1.1
$ sudo make install-webconf
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
$ sudo service httpd restart
6. Install the Nagios Plugins

$ curl -L -O
$ sudo tar xvf nagios-plugins-2.1.1.tar.gz 
$ cd nagios-plugins-2.1.1
$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagioscmd
$ sudo make
$ sudo make install
7. Install NRPE plugin and configure

$ curl -L -O
$ sudo tar xvf nrpe-2.15.tar.gz 
$ cd  nrpe-2.15
$ sudo ./configure  --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios
$ sudo make all
$ sudo make install
$ sudo make install-xinetd
$ sudo make install-daemon-config
$ sudo vim /etc/xinetd.d/nrpe (Modify the “only_from” line by adding the private
 IP address of the your Nagios server to the end (substitute in the actual IP address of your server) )

$ sudo service xinetd restart

Organize Nagios Configuration Open the main Nagios configuration file. We’ll use vim to edit the file:

$ sudo vim /usr/local/nagios/etc/nagios.cfg

Now find an un-comment this line by deleting the #


Now create the directory that will store the configuration file for each server that you will monitor:

$ sudo mkdir /usr/local/nagios/etc/servers

8.Configure 'check_nrpe' Command Let's add a new command to our Nagios configuration:

$ sudo vim /usr/local/nagios/etc/objects/commands.cfg

Add the following to the end of the file:

define command{
 command_name check_nrpe
 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

This allows you to use the “check_nrpecommand in your Nagios service definitions.

Now you can open the Nagios web interface or Nagios Dashboard, so verify the sample Nagios configuration files if there are no error, start nagios.

$ sudo  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
$ sudo service  nagios  start

Accessing the Nagios Web Interface : Open your favorite web browser, and go to your Nagios server ( IP address or host name for the highlighted part): access with credential username and password (htpassowrd for nagiosadmin)




Congratulations! As with above configuration you can see, Nagios is monitoring only “localhost”, or itself.  If you want to  monitor  more hosts and services with Nagios, you must have to add the them.

So in next post you will learn how to add more hosts and services for Nagios to monitor. 


2 thoughts on “Nagios tool for server Monitoring

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s