How to install nagios core 4 on centos7

Nagios Core is free and open source Monitoring Tool which monitor the resources like servers, network instrumentality like firewall, network switches and printers etc. Nagios core additionally provides alerting services, victimization that nagios informs to network admin regarding issue that has occurred & then trigger alerts once more once the problem has been resolved. Nagios provides info like CPU utilization, Disk utilization, Memory utilization & additionally has support for variety of networking protocols like SMTP, HTTP, POP3, SNMP, ICMP, FTP, SSH etc. Nagios shows all the data concerning all the servers on one screen victimization its web-interface.

Recently, Nagios core discharged four.3.2 version of nagios core & two.2.1 version of nagios plugins. during this tutorial, we tend to area unit about to install and assemble the most recent version (4.4.5) of Nagios server on CentOS 7 then can add a windows machine for observation. therefore let’s begin with installation.

Step: 1 Install essential packages:

We need to put in some essential packages like Apache, PHP & packages needed for building the source packages, use below command to install this packages.

[root@linuxtechi ~]# yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip -y

Step:2 Download and extract Nagios packages

We have to download & extract nagios & its plugins files. Use below links to download it.

[root@linuxtechi ~]# wget
[root@linuxtechi ~]# wget

Now we have to extract the packages, for that run following commands.

[root@linuxtechi ~]# tar -zxvf nagios-4.3.2.tar.gz
[root@linuxtechi ~]# tar -zxpvf nagios-plugins-2.2.1.tar.gz

Step:3 Create user and group for Nagios

Now we will create a user named ‘nagios‘ & a group named ‘nagcmd‘ for running nagios. So, use below command for that.

[root@linuxtechi ~]# useradd nagios
[root@linuxtechi ~]# passwd nagios
[root@linuxtechi ~]# groupadd nagcmd

Once the user & group has been added, we have to add the user nagios & apache user to the created group i.e. nagcmd. Use below command for that.

[root@linuxtechi ~]# usermod -G nagcmd nagios
[root@linuxtechi ~]# usermod -G nagcmd apache

Step:4 Install Nagios core

We are now ready to install the nagios on our server, so go to the folder with extracted nagios core files & compile the extracted files using below commands.

[root@linuxtechi ~]# cd nagios-4.3.2
[root@linuxtechi nagios-4.3.2]# ./configure --with-command-group=nagcmd

Now, we will install the compiled nagios package by running below commands

[root@linuxtechi nagios-4.3.2]# make all
[root@linuxtechi nagios-4.3.2]# make install

After running these, we need to install init scripts, command mode (to make nagios work from CLI) and we also need to install some sample Nagios files

[root@linuxtechi nagios-4.3.2]# make install-init
[root@linuxtechi nagios-4.3.2]# make install-commandmode
[root@linuxtechi nagios-4.3.2]# make install-config

Step:5 Configure Nagios Core Web-Interface

Now we will install the web interface for the nagios, as we will be using web interface for monitoring the resources of the client systems. For installing web interface, run below command

[root@linuxtechi nagios-4.3.2]# make install-webconf

Web interface will be installed with a default user name ‘nagiosadmin‘ but there will be no default password for this user. We have to create default password for this user by issuing the following command

[root@linuxtechi nagios-4.3.2]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
[root@linuxtechi nagios-4.3.2]#

Step:6 Configure email alerts

This is an optional step but consider doing it. Configuring an email to receive alerts on nagios, you will remain informed of all the server activities 24/7. To configure an email open below file

[root@linuxtechi ~]# vi /usr/local/nagios/etc/objects/contacts.cfg

and enter an email address as mentioned below

Now, you have to restart apache service for changes to take effect.

[root@linuxtechi ~]# systemctl restart httpd

Step:7 Install Nagios Plugins

We have now completed installation part for nagios core but we need to install plugins as without plugins we can’t monitor the resources. So open the directory with nagios plugin files and then we will compile and install the plugins

[root@linuxtechi ~]# cd nagios-plugins-2.2.1/
[root@linuxtechi nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@linuxtechi nagios-plugins-2.2.1]# make
[root@linuxtechi nagios-plugins-2.2.1]# make install

Installation of nagios plugins is completed now.

Step:8 Verify Nagios files

Final step is Now to verify Nagios configuration file against a sample configuration file

[root@linuxtechi ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Output will be something like below

This will ensure that all the settings made to nagios configuration file are correct & if there is any issue with file, it will report that as well. After making sure that config file is error less, we will restart the nagios & apache service to implement the changes.

[root@linuxtechi ~]# systemctl restart  nagios
[root@linuxtechi ~]# systemctl restart httpd

Also make sure that these services restart after a reboot,

[root@linuxtechi ~]# systemctl enable  nagios
[root@linuxtechi ~]# systemctl enable httpd

Note: In Case OS firewall in enabled on your Nagios server then allow 80 port using beneath commands

[root@linuxtechi ~]# firewall-cmd --permanent --add-port=80/tcp
[root@linuxtechi ~]# firewall-cmd --reload
[root@linuxtechi ~]#

Step:9 Logging into Nagios Web-interface

Now to check the status of the services, login to the nagios web interface by using the ip address of the nagios server followed by /nagios


You will now be asked to provide the credentials, Use nagiosadmin as user name and password that we set in above steps. Once authenticated you will be reach in the home page of nagios server.

Adding a Windows host to Nagios Monitoring Server

We will now add a windows machine to be monitored by Nagios server for that we need to setup client machine and then will make changes to nagios server.

To adding a windows host for monitoring on Nagios, we need a software called NSClient++ We can download it from, once it downloaded we can start the setup by double clicking on downloaded .msi file.

Then click on Next the first screen, once the installation starts

Now, accept the license agreement and click Next

On the next screen, click on Typical

Leave the following screen as it is and click on Next

Now enter the IP address of Nagios server (for me it is and click on Next

Click on ‘Install’ and wait for the installation to complete. Once its complete click on Finish

Changes on Nagios server

Once the settings on the client side are complete, we need to make changes to configuration file of nagios. Open the file /usr/local/nagios/etc/nagios.cfg

[root@linuxtechi ~]# vi /usr/local/nagios/etc/nagios.cfg

Uncomment the following line


Save file and exit. Next open the file /usr/local/nagios/etc/objects/windows.cfg

[root@linuxtechi ~]# vi /usr/local/nagios/etc/objects/windows.cfg

This file contains a host definition which can be used as a reference to create the host definition for our window client machine. Edit the hostname & IP address to match your own windows machine, below the host definition are some Service Definitions, here we can add more services definition. Make sure that hostname is changed to your windows client name in all the services. Once done all changes save file and exit.

Now restart your nagios server and check if the windows host has been added or not to nagios for monitoring, by browsing to ‘HOSTS‘ under current status.


Our host has been successfully added to nagios for monitoring. Similarly we can add more servers in nagios for monitoring and once any service is affected, nagios will show the status on web console and will also send an alert notification to email address that mentioned in contacts.cfg file.

Thanks for visiting

Suresh Dike

Suresh Dike I am Suresh, working on Cloud, DevOps, Linux, Firewalls,Docker and Kubernetes. Believes in sharing the knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.