How to Install Nagios 4 in CentOS, RHEL, Fedora


how to install nagios 4 in centos rhel fedora

Nagios 4 is a powerful enterprise-grade website monitoring platform that allows you to monitor every aspect of your website infrastructure – servers, network, websites, hardware and more. Let us look at how to install Nagios 4 in CentOS, RHEL, Fedora systems.

 

How to Install Nagios 4 in CentOS, RHEL, Fedora

Here are the steps to install Nagios 4 in CentOS, RHEL, Fedora. We will be installing Nagios 4.3.4 and Nagios Plugin 2.2.1

Please note:

  • You will find Nagios is installed at /usr/local/nagios directory
  • You can access Nagios admin at http://localhost/nagios

 

1. Install Required Dependencies

Before we install Nagios, we need to install Apache, PHP and libraries like gcc, glibc, glibc-common and GD to ensure that your installation goes smoothly. If you don’t install them, Nagios will automatically install them for you.


$ yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

Fedora 22+ onwards:


$ dnf install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

 

2. Create Nagios User group

Next, we create a new user “nagios”, a new group “nagcmd” and set its password.


$ useradd nagios
$ groupadd nagcmd

 

Next, we add both apache and nagios users to the new group.


$ usermod -G nagcmd nagios
$ usermod -G nagcmd apache

 

3. Download installation files

Next, we create a directory where we will download and install Nagios Core and Plugin files


$ mkdir /root/nagios
$ cd /root/nagios

 

Download Nagios Core and Plugin files


$ 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

If you want to download a different version, please update the above file names accordingly.

 

4. Extract the downloaded files

You can extract Nagios Core and plugin files with the commands


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

 

If you have downloaded a different version, please update the above file names accordingly. After you extract these files, you will see that 2 new subfolders have been created in your present location (/root/nagios)

 

5. Install Nagios 4

You can install Nagios 4 by running the following commands


$ cd nagios-4.3.4
$ ./configure --with-command-group=nagcmd
$ make all
$ make install
$ make install-init
$ make install-config
$ make install-commandmode

 

Then run the following command to configure Apache for Nagios


$ make install-webconf

 

6. Configure Apache Authentication

Next, we need to setup Apache authentication for the user “nagiosadmin”. Don’t use a different username. Run the following command


$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

You’ll be asked to enter a password twice. Remember it because you will need this username & password to log into Nagios web interface.

Restart Apache to apply changes

 

On RHEL/CentOS 6/5 and Fedora:


$ service httpd start

 

On RHEL/CentOS 7 and Fedora 19 Onwards:


$ systemctl start httpd.service

 

7. Install Nagios Plugins

Go to /root/nagios and install Nagios Plugins


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

 

8. Verify Installation

You can verify that everything has been installed properly, by running the following command


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

 

If you don’t see any errors in the output, you will see the following message at the end of the output


Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

 

9. Restart Nagios

Add Nagios to system startup with the following commands

On RHEL/CentOS 6/5 and Fedora


$ chkconfig --add nagios
$ chkconfig --level 35 nagios on
$ chkconfig --add httpd
$ chkconfig --level 35 httpd on

On RHEL/CentOS 7 and Fedora 19-26


$ systemctl enable nagios
$ systemctl enable httpd

 

Restart Nagios to make the new settings take effect.

On RHEL/CentOS 6/5 and Fedora


$ service nagios start

On RHEL/CentOS 7 and Fedora 19-24


$ systemctl start nagios.service

 

10. View Nagios Web Interface

Open web browser and go to http://localhost/nagios. If you have installed it on your domain, go to http://your_domain/nagios

You will be asked for the username password. Enter username as “nagiosadmin” and password as the one you saved in step 6.

You will be directed to the Admin screen

nagios core

 

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!