Nagios Monitoring Server installation and Configuration

Nagios Monitoring

Nagios 

Nagios Monitoring is the most widely used open source monitoring tools which help us to monitor the services and application that run’s on Windows,Linux,Routers and other network devices. With the help of Nagios Monitoring, you can monitor basic services and attributes. We can access the Nagios using web interface coming with the bundle and configuration need to be done on the file level.

Nagios can monitor below services by default :

  • Current CPU Usage
  • Current Load
  • Current Users
  • Data Partition
  • PING
  • Root Partition
  • Swap Usage
  • Total Processes
  • Zombie Processes

In this tutorial, we would learn the installation and configuration of Nagios Server and Nagios Client.

We are monitoring same system where we are installing nagios server because this article is about basic installation of nagios server and plugin.

As you know nagios monitoring is very vast topic not possible to explain in single article so what we decide to explain you complete nagios which we need in Live environment in several parts.

It helps you to understand the Nagios Monitoring in more detail and easily.

Before we start the installation process we will check what we need to run nagios server smoothly like system requirements, software dependencies etc.

Scenario 

Here is my test scenario,

System Requirement (Mininum) :

  • CPU      : 2 Core
  • RAM      : 4 GB
  • Storage : 20 GB
  • OS        :  Debian GNU/Linux 8.5 (jessie)
  • IP Address : 192.168.3.39

Setup Nagios Server

Step 1 : First we are installing dependent packages which we need for nagios server. Now we are using apt-get command for updating repo and install the packages.

  • apt-get update
  • apt-get install build-essential apache2 php5 openssl perl make php5-gd libgd2-xpm-dev libapache2-mod-php5 libperl-dev libssl-dev daemon wget apache2-utils

Step 2 : Now we need one user and group which has rights or permissions to access nagios files. For allowing the external commands to be executed through the web interface we add nagios user and apache user in nagioscmd group.

Use below commands to create user and group,

  • useradd nagios
  • groupadd nagioscmd

Use below command to add nagios user and apache user under the nagioscmd group,

  • usermod -a -G nagioscmd nagios
  • usermod -a -G nagioscmd www-data

Step 3 : Download the latest version Nagios core server under /opt directory and compile the nagios core.

Learn more about the tar command,

Read: Everything about tar command linuxadmin must know

Step 4 : All the configuration files of nagios have been installed in “/usr/local/nagios/etc/” . whenever you want to make any nagios configuration changes you need to check for that .cfg file under “/usr/local/nagios/etc/”.

Now we need make one change in contacts.cfg file before proceed..

Edit “/usr/local/nagios/etc/objects/contacts.cfg” file and changed the email id with your email id to receive the Alerts.

vim /usr/local/nagios/etc/objects/contacts.cfg

define contact{

        contact_name     nagiosadmin    ;
        use                     generic-contact ;
        alias                   Nagios Admin    ;                                           email                 test@nagios.com;       
         }

Configuring nagios web interface

Step 5 : 

In this step, we are going to give password protection for nagios web interface using below command,

  • htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosuser

Make sure you note down the password because we need it later when using nagios web interface.

Step 6 : Enable the cgi module on apache.

  • a2enmod cgi
  • service apache2 restart

Step 7 : open the nagios.conf file which is resides under the /etc/apache2/sites-available directory and add the below bold lines before and end of the file. Keep other content as it is.

virtualhost

Step 8:

Once configuration is done restart the apache server.

  • service apache2 restart

Nagios Core server installation has been done.

Nagios NRPE Client installation and Configuration

What is nrpe client?

  • The NRPE (Nagios Remote Plugin Executor) plugin allows you to monitor any remote Linux/Unix services or network devices. This NRPE add-on allows Nagios to monitor any local resources like CPU load, Swap, Memory usage, Online users, etc. on remote Linux machines. After all, these local resources are not mostly exposed to external machines, an NRPE agent must be installed and configured on the remote machines.

 

Let’s start with the installation and configuration steps of nrpe client :

As we already mentioned that we are going to monitor same host where we installed Nagios Server.

Step 1 : First we would be installing the nrpe package with the help of apt-get command.

  • apt-get install nagios-nrpe-server

Step 2 : Download the nagios-plugins using wget command on system. These plugins are helping us to monitor the system.

3. Open the file nrpe.cfg which basically resides under the “/etc/nagios/” directory. This file is the main configuration file of nrpe which is used to define the plugins to monitor the host.

vim /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1

#You will find default plugins are enabled to monitor the localhost.#

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10

command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1

command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

Save and close the file. That’s it.

Now go to Nagios Monitoring Web interface at “http://Your-server-ip/” and provide username and password which we created with htpasswd command.

Currently web interface not able to access the host for monitor. For this we need to provide access or permission to our user to fetch info from server.

Open cgi.cfg file which is resides under /usr/local/nagios/etc and add new username next to nagiosadmin using comma.

vim cgi.cfg

authorized_for_system_information=nagiosadmin,nagiosuser

authorized_for_configuration_information=nagiosadmin,nagiosuser

authorized_for_system_commands=nagiosadmin,nagiosuser

authorized_for_all_service_commands=nagiosadmin,nagiosuser
authorized_for_all_host_commands=nagiosadmin,nagiosuser


Save and close the file.

Test For your configuration changes with below command and then restart nrpe and nagios service.

  • /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  [This command check your complete nagios configuration and provides you warnings and errors so before restarting nagios service always run this command]
  • /etc/init.d/nagios restart && /etc/init.d/nagios-nrpe-server restart


Refresh your nagios web interface and you will see the host is added on server for monitoring.

Refer below url for NRPE Plugin installation :

  • paste link here
nagios

If you’re facing any difficulties while adding installing Nagios. Please do comment your queries or problem via comment section, till then stay tuned to techthings.org for more such valuable articles.

Latest Comments
  1. nawaz January 18, 2017

Leave a Reply

Your email address will not be published. Required fields are marked *