install nagios AlmaLinux and Rocky Linux

Nagios Core is free and open source software which is mainly used for monitoring the IT infrastructure. It can monitors hosts, services, networking devices, containers etc and sends alerts through sms, email and other medium etc. It also offers the Nagios dashboard from which we have a visibility on the alerts status.

It uses the encryption to communicate with target host by using SSL and SSH. For networking devices, we generally uses the SNMP.

In this article, we are installing Nagios Core on AlmaLinux 9.x and Rocky Linux 9.x servers.

Steps to install Nagios Core on AlmaLinux and Rocky Linux

Follow the given below steps to install the Nagios monitoring tool.

Preliminary requirements

In this section we will do some preliminary requirements before installing the Nagios.

Login as root user in the server.

Install packages

Install following packages will be used for download and extracting the packages.

dnf install wget unzip tar

wget is used for downloading the package from the remote URL.

unzip and tar are used for extracting the compressed files/folder.

Disable SELINUX

Now disable the SELINUX . The sed command will directly edit the file to ‘SELINUX=disabled’. After editing the file, the server must have to restart. If in case, you want to restart the server later and also want to continue the Nagios installation. Then also run the command setenforce which is given after this code snippet.

sed -i.bak 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

The sed -i.bak will help to create a backup file of /etc/selinux/configwith extension .bak .

Run this command to skip the server restart.

setenforce 0

Now install the dependencies which is required for Nagios installation.

dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
dnf install openssl-devel
dnf update -y

Download Nagios core and extract the package.

Download the Nagios Core and extract the packages.

cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.5.8.tar.gz
tar -xvzf nagios-4.5.8.tar.gz

Compile the Nagios Core package

cd /tmp/nagios-4.5.8
./configure
make all

Create user and group

The given below command will create the required nagios user and group as well as it also add the apache user to the nagios group.

make install-groups-users
usermod -a -G nagios apache

Install Nagios binaries

Install the binaries by running this command

make install

Install the service and daemon

Install the systemd service and daemon for nagios. And also enable the httpd service.

make install-daemoninit
systemctl enable httpd.service

Install command mode

Run the given below command to install the external command files.

make install-commandmode

Install sample config for kickstart

For quick start, we will install the sample config.

make install-config

Install Apache configuration files

It install the apache configurations files which are related to Nagios.

make install-webconf

Configure firewall

Here, we are allowing port 80 in the firewall.

firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent

Create Nagios admin user

To login to Nagios dashboard, we will create a apache user called ‘nagiosadmin’, its password will be set by using command ‘htpasswd’ .

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

Start and enable the Apache service

Start and enable the Apache service. By ‘enable’ whenever the server get booted, the httpd service will start always.

systemctl start httpd.service
systemctl enable httpd.service

Start and enable the Nagios service

Start and enable the Nagios service.

systemctl start nagios.service

Access Nagios dashbaord

Finally, we have completed all the steps of Nagios installation. Open the web browser and give the Nagios server address.

http://nagios-server-ip-address/nagios

Note: Replace nagios-server-ip-address with actual server ip address of your Nagios server.

After login you will find the Nagios dashboard like this.

Now we have successfully completed the installation of Nagios Core monitoring server in AlmaLinux and Rocky Linux.

Post Nagios Core Installation Activities

In this section we are covering the action item which is required after Nagios core installation. When you start exploring the Nagios Core Dashbaord you will observe some error and warning. So we will first fix those. More importantly, these alerts are showing from localhost which means it is from Nagios core itself.

Install Nagios NRPE Plugin in Nagios Core Server

You may encounter some alerts on Nagios dashboard, it is because of missing Nagios plugin. Here, we will use the NRPE.

Follow the given below steps to install Nagios NRPE plugin on localhost that is in Nagios Core server.

Install Nagios Plugin dependencies and EPEL repo.

dnf install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum --enablerepo=epel install perl-Net-SNMP

Download the latest NRPE release

For this we are directly downloading from its Git repo.

wget https://github.com/nagios-plugins/nagios-plugins/archive/refs/tags/release-2.4.12.zip
Nagios NRPE github page

Compile and install NRPE

Unzip the package and change to its directory. Follow with compiling and make installation of the NRPE package.

unzip release-2.4.12.zip
cd nagios-plugins-release-2.4.12
./tools/setup
./configure
make
make install

This will install the Nagios NRPE plugin in the system.

Note:

In our Server the default, NRPE installation was /usr/lib/nagios/plugins/ .

HTTP WARNING: HTTP/1.1 403 Forbidden

You will find the warning on localhost about the HTTP. You have simply create a blank index.html inside the Apache’s root folder. We have also provided the detail explanation about this on our previous article.

touch /var/www/html/index.html

Either wait for a while or click to reschedule the check. Later the warning status turned to OK and color will be changed to green.

Now check your Nagios Dashboard it should all Green now with no errors. Start adding Hosts and Services in Nagios Dashboard.

Read Some More Articles