Published February 12, 2018 by

Install and Configure Nagios on Centos7/RedHat



Nagios is a free Monitoring Tool, It’s Provides you Monitoring environment to always keep an eye on your all Networks/systems from anywhere.

With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually helps us to detect some problems before they occur. It helps us to reduce downtime and business losses.

Few things that you need to keep in mind about Nagios
  • Nagios installed in /usr/local/nagios/.
  • Nagios Plugins are installed under /usr/local/nagios/libexec/.
  • Nagios will be configured to monitor few services of your local machine like Disk Usage, CPU Load, Current Users, Total Processes, etc...
  • Nagios main Page located under /usr/local/nagios/share/index.php
  • Nagios Templates are stored at /usr/local/nagios/etc/objects/templates.cfg
  • Nagios Configuration file under /usr/local/nagios/etc/objects/contacts.cfg
  • All Host files are added in this location /usr/local/nagios/etc/objects

Install Required Dependencies

We need to install Apache, PHP and some libraries like wget,unzip, gcc, glibc, glibc-common and GD libraries and its development libraries before installing Nagios 4.3.4 with the source.


# yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
# yum install unzip
# yum install wget

Create Nagios User and Group

Create a new nagios user and nagcmd group account and add both the nagios user and the apache user to the nagcmd group.


# useradd nagios
# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache

Download Nagios Core and Nagios Plugin


Create a directory for your Nagios installation.

# mkdir /root/nagios
# cd /root/nagios

Download latest Nagios Core 4.3.4 and Nagios plugins 2.2.1 packages.

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Extract Nagios Core and its Plugins

Extract downloaded package.

# tar -xvf nagios-4.3.4.tar.gz
# tar -xvf nagios-plugins-2.2.1.tar.gz

Configure Nagios Core

Now we will configure Nagios Core.

# cd nagios-4.3.4/
# ./configure --with-command-group=nagcmd

After configuring, we need to compile and install all the binaries with make all and make install command, it will install all the needed libraries on your machine.

# make all
# make install

Install the init scripts, command-mode and sample nagios file for Nagios.

# make install-init
# make install-commandmode
# make install-config

Install and Configure Web Interface for Nagios

The below command will Configure Web interface for Nagios and a web admin user will be created "nagiosadmin" also set password for "nagiosadmin"

# make install-webconf
# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache

# systemctl start httpd.service

Compile and Install Nagios Plugin

We have downloaded Nagios plugins in /root/nagios, Go there and configure and install it.

# cd /root/nagios/nagios-plugins-2.2.1/
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

Verify Nagios Configuration Files

We are done with the Nagios configuration.Now, It’s time to verify it

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Add Nagios Services to System Startup

# systemctl enable nagios
# systemctl enable httpd

Restart Nagios

# systemctl start nagios.service

Login to the Nagios Web Interface

Open a browser and hit "http://Server-IP-address/nagios" and Provide the username "nagiosadmin" and password.