Install Nagios 4.1.1 Network Monitoring tool on Fedora, CentOS & RHEL

Nagios is one of the most popular Open-source Computer System Monitoring, Network Monitoring and IT Infrastructure Monitoring Software which prevents the critical issues in IT Infrastructure and run it smoothly without any trouble. It monitors entire IT infrastructure such as servers, switches, applications, network and services which alerts when there is any trouble and as well as the recovery alerts of the system. The latest version of Nagios core 4.1.1 released on Augest 19, 2015. Alternatively you can install other network monitoring tools such as Zabbix, Cacti, Monitorix, Munin & Icinga2.

Nagios Features

  • Monitors the entire IT infrastructure
  • Spot the problems before they occur
  • Know immediately when problems arise
  • Shares availability of data with stakeholders
  • Detects security breaches
  • Plan and budget for IT upgrades
  • Reduces downtime and business losses
  • Automatic fix of the problems when they are detected

1) Prerequisites for Nagios

You have to install LAMP & EPEL Repository before proceeding Nagios core installation.

# For RHEL/CentOS/Fedora 21 & older Systems #
# yum install gcc glibc glibc-common gd gd-devel

# For RHEL/CentOS/Fedora 22 & later Systems #
# dnf install gcc glibc glibc-common gd gd-devel

2) Create User & Group Account for Nagios

Create new user account & group for nagios and assign the user to nagios group and also assign the apache user to nagios group.

# Create new user for nagios #
# useradd nagios
# passwd nagios

# Create new group for nagios #
# groupadd nagcmd

# Assign nagios user to nagios group #
# usermod -a -G nagcmd nagios

# Assign apache user to nagios group #
# usermod -a -G nagcmd apache

3) Download Nagios & Nagios Plugin

Navigate to /opt directory and download latest version of nagios and nagios plugin.

# Nagios download #
# wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.1.1/nagios-4.1.1.tar.gz

# Nagios Plugin download #
# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

4) Compile and Install Nagios

Use the below commands to Compile and Install Nagios on your system.

# tar -xzvf nagios-4.1.1.tar.gz
# cd nagios-4.1.1

# Run the Nagios configure script, passing the name of the group you created earlier like so: #
# ./configure --with-command-group=nagcmd

# Compile the Nagios source code #
# make all

# Install Nagios binaries #
# make install

# Install init script for Nagios #
# make install-init

# Install sample config file for Nagios #
# make install-config

# set permissions on the external command directory #
# make install-commandmode

Note: Don’t start Nagios yet – there’s still more that needs to be done.

5) Customize Configuration

The sample configuration file is installed at /usr/local/nagios/etc and its working fine but we need to add our email id for Alerts. For that you need to modify below file /usr/local/nagios/etc/objects/contacts.cfg.

# nano /usr/local/nagios/etc/objects/contacts.cfg
email  [email protected]

6) Configure the Web Interface

Use the below commands to install Nagios web interface and it will drop the config file to Apache conf.d directory, while installation nagios web interface it will create nagios web user called nagiosadmin and you need to set the password to access the nagios web interface.

# Install web interface #
# make install-webconf

# Set password for nagiosadmin user #
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

# Restart Apache on SysVinit System to make the new settings take effect #
# service httpd restart

# Restart Apache on SysVinit System to make the new settings take effect #
# systemctl restart httpd.service

7) Compile and Install the Nagios Plugins

After Nagios core installation, you need to Install latest nagios plugin in your system.

# tar -xzvf nagios-plugins-2.1.1.tar.gz
# cd nagios-plugins-2.1.1

# Run the Nagios plugin configure script, passing the name of the user you created earlier like so #
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

# Compile the Nagios plugin source code #
# make

# Install Nagios plugin binaries #
# make install

8) Start Nagios

before staring nagios, check nagios configuration file whether any error is occurring or not. Also add the service to system boot.

# Checking Nagios Configuration File #
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# For SysVinit Systems #
# service nagios start
# chkconfig nagios on

# For Systemd Systems #
# systemctl start nagios.service
# systemctl enable nagios.service

8) Access Nagios Web Interface

Navigate your browser to http://localhost/nagios or http://IP-Address/nagios or http://Domain-Name/nagios and enter username password which you created to access it.
nagios-4-0-8-installation-fedora-rhel-centos-8
Nagios Home Page
nagios-4-0-8-installation-fedora-rhel-centos-8a
Host list By default nagios monitor him self and we can add N number of hosts.
nagios-4-0-8-installation-fedora-rhel-centos-8b
Service status checking
nagios-4-0-8-installation-fedora-rhel-centos-8c

Manage your IT infrastructure with Nagios and minimize the downtime…stay tune us will come with nagios host adding linux & windows..Happy wEeKeNd..

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...