December 3, 2021
How to install Nagios Core on Centos 7

How To Install Nagios Core and Plugin on Centos 7

On this article we will discuss how to install Nagios Core 4.4.5 and Nagios Plugin 2.2.1 on Centos 7 operating system.


If we have a fairly complex IT infrastructure, it requires adequate monitoring tools to help us find out the current condition of the system. And able to detect possible problems that will arise, for example: server capacity, memory or network. One of the most common monitoring tools used by many circles is Nagios.

Nagios is a free and open source application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved. Nagios enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios was wrote and developed by Ethan Galstad as NetSaint.

On this article we will discuss how to install Nagios on Centos 7.

Installing Nagios On Centos 7

On this section forward, we will discuss how to install Nagios on Centos 7. We will use the Nagios stable release version 4.4.5, which was released on August 20, 2019. There will be several steps for installing Nagios on Ubuntu 18.04, and will be described deeply below :

Prerequisite & Install Required Dependencies

Before continuing with this tutorial, we have to prepare our Centos 7 environment first. Nagios installation requires a user with sudo privileges or root account, sufficient space and the last update of Centos repository, good internet connection for downloading required package. In our environment we have all the necessary requirements.

After all basic requirements are met, than we have to prepare for the required dependencies software for installing Nagios. The dependencies libraries are needed like : gcc, glibc, glibc-common and GD libraries and its development libraries before installing Nagios 4.4.5 with the source beside Apache and PHP.  This step can be achieved by submitting command line below :

[ramans@localhost ~]$ sudo yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

Install Nagios on Centos - required dependecies software

Create Nagios User and Group

We need a new user and group for this installation. We create a new user called as nagios and group called as nagcmd. After all done, we log in to its directory using root account, Add both the nagios user and the apache user to the nagcmd. This step is done, by submitting command line below :

[ramans@localhost ~]$ sudo useradd nagios
[ramans@localhost ~]$ sudo groupadd nagcmd
[ramans@localhost ~]$ sudo usermod -a -G nagcmd nagios
[ramans@localhost ~]$ sudo usermod -a -G nagcmd apache

create nagios user and nagcmd group

Download Nagios Core 4.4.5 and Nagios Plugin 2.2.1

We need to download the source of Nagios Core 4.4.5 and Nagios Plugin 2.2.1, we need a new directory for this purpose, we create the new /root/nagios using root account. Then enter to its new direktory using root account. Than download inside this directory.

The Nagios corea located in and Nagios plugin located in

[ramans@localhost ~]$ sudo mkdir /root/nagios
[ramans@localhost ~]$ cd /root/nagios
[ramans@localhost ~]$ su -
Last login: Thu Apr 9 06:29:25 WIB 2020 on pts/0
ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1586388565
[root@localhost ~]# cd /root/nagios
[root@localhost nagios]# cd /tmp
[root@localhost tmp]# cd /root/nagios
[root@localhost nagios]# wget
[root@localhost nagios]# wget

donwload Nagios Core 4.4.5

Download Nagios plugin

Extract Nagios Core and its Plugins

The two source we had downloaded than extract by submitting command below :

[root@localhost nagios]# tar -xvf nagios-4.4.5.tar.gz
[root@localhost nagios]# tar -xvf nagios-plugins-2.2.1.tar.gz

Extract nagios-4.4.5 core

extract nagios-plugins-2.2.1


The Nagios files structure are as follow

Extract Nagios Core and plugin result

Configure Nagios

There will be two steps configuration in this step : Nagios Core configuration and Nagios Plug in Configuration. We will do the Nagios Core configuration first.

Configure Nagios Core 4.4.5

We will configure Nagios Core first, to do so, we need to enter its directory and configurin it from there, with the following command below.

[root@localhost nagios]# cd nagios-4.4.5/
[root@localhost nagios-4.4.5]# ./configure --with-command-group=nagcmd

Configure Nagios Core

The output could be :

Creating sample config files in sample-config/ ...
*** Configuration summary for nagios 4.4.5 2019-08-20 ***:

General Options:
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: /usr/local/nagios/var/spool/checkresults
Init directory: /lib/systemd/system
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
IOBroker Method: epoll

Web Interface Options:
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute

Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

The next step after configuring the core, we need to compile and install all the binaries with make all and make install command, with command line below :

[root@localhost nagios-4.4.5]# make all
[root@localhost nagios-4.4.5]# make install

[root@localhost nagios-4.4.5]# make all

Nagios make install

The next step is installing the init scripts for Nagios, by submitting command line below :

[root@localhost nagios-4.4.5]# make install-init

Nagios - install init

Then execute command line below to enable the Nagios to be command line mode :

[root@localhost nagios-4.4.5]# make install-commandmode

Nagios command-mode

The next step is installing sample Nagios files, by running command below:

[root@localhost nagios-4.4.5]# make install-config

Nagios make install-config

Customize Nagios Configuration

The next step is customize original Nagios configuration as our requirement. On this step, we will edit the contacts.cfg file to setup the email address associated with the nagiosadmin contact definition to receiving email alerts.

[root@localhost nagios-4.4.5]# vi /usr/local/nagios/etc/objects/contacts.cfg

[root@localhost nagios-4.4.5]# vi /usr/local/nagios/etc/objects/contacts.cfg

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

Install and Configure Web Interface for Nagios

After all backend configuration was done, the next step is configuring Web Interface. On this step we will create an admin user as ‘nagiosadmin‘.

[root@localhost nagios-4.4.5]# make install-webconf

The output is as shown below :

/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then \
ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \

*** Nagios/Apache conf file installed ***

The nagiosadmin user has been created, and then we have to supply password for its user by submitting command below :

[root@localhost nagios-4.4.5]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

The output could be :

New password: 
Re-type new password: 
Adding password for user nagiosadmin

nagiosadmin password

To take effect for this step, we have to restart the apache service by submitting command below :

[root@localhost nagios-4.4.5]# systemctl start httpd.service

Restart apache for nagios

Configure Nagios Plugin 2.2.1

So far, the Nagios Core installation and configuration has been done. The next step is configuring the Nagions Plugin 2.2.1. We have to be in nagios-plugin-2.2.1 directory and submit command line :

[root@localhost nagios]# cd /root/nagios/
[root@localhost nagios]# cd nagios-plugins-2.2.1/
[root@localhost nagios-plugins-2.2.1]# ./configure --with-nagios-user=n

Nagios Plugin configuration

And then make install the Nagios plug in with command line below :

[root@localhost nagios-plugins-2.2.1]# make

Nagios plugin make install

Then verify Nagios plugin configuration with command line below :

[root@localhost nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios plugin veriftying

Restart Nagios Service

To take effect all new Nagios services, we have to restart Nagios daemon, by submitting command below :

Restart Nagios services

Login to Nagios Web Interface

All we have done so far, Now we will test the Nagios function by login to Nagios web interface by hitting its URL. By supplying the username nagiosadmin and password we have created before. The web interface is as like below :

Nagios Login

Nagios Web Interface

SNagios Web Portal

So far, the Nagios installation on Centos 7 has been successfully done. For Covid-19 campaign, Keep safe and stay at home!

Share this article via :

Leave a Reply

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