Install Nagios Monitoring Tool on AlmaLinux 9

This guide intends to teach you to Install and Configure the Nagios Monitoring Tool on AlmaLinux 9.

Nagios is a type of tool that is used as a monitoring tool for monitoring the network in several ways. The tool is able to provide all the system-related information to the user and is also used for real-time monitoring of the network and applications. Nagios is capable of monitoring the server and finding performance bottlenecks. The tool maintains the server statistics so that performance-related issues can be identified and can be resolved and also send alerts to the user when any issue is identified.

Steps To Install Nagios Monitoring Tool on AlmaLinux 9

To complete this guide, you need some requirements first.

Requirements

First, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

Then, you must have Apache installed on your server. For this purpose, you can follow this guide on Install Apache Web Server on AlmaLinux 9.

Also, you must have PHP installed on your server. To do this, you can follow our guide on How To Install PHP 8.2 on AlmaLinux 9.

And you must disable the SELinux by visiting this guide on How To Disable SELinux on AlmaLinux.

When you are done, follow the steps below to Set up Nagios on AlmaLinux 9.

Install Required Packages For Nagios on AlmaLinux 9

At this point, you need to run the following command to install the required packages and dependencies:

sudo dnf install php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget make gettext autoconf net-snmp-utils perl-Net-SNMP postfix unzip automake -y

Download the Latest Release of Nagios

Now you need to navigate to your /usr/src/ directory:

cd /usr/src/

Then, visit the Project GitHub repository and download the latest release of the Nagios tar.gz file by using the wget command:

sudo wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.4.10/nagios-4.4.10.tar.gz

When your download is completed, extract your file with the following command:

sudo tar zxf nagios-*.tar.gz

Next, switch to your Nagios directory on AlmaLinux 9:

cd nagios-4.4.10

Compile and Build Nagios Monitoring Tool on AlmaLinux 9

Now run the following script which will perform a number of checks to make sure all of the dependencies on your system are present:

sudo ./configure

Then, start your compilation process with the following command:

sudo make all

The compilation may take some time, depending on your system. Once the build process is completed, you will get the following output:

Output
For more information on obtaining support for Nagios, visit:
       https://support.nagios.com
*************************************************************
Enjoy.

At this point, you need to create a new Nagios user and group on AlmaLinux 9:

sudo make install-groups-users
Output
groupadd -r nagios
useradd -g nagios nagios

Then, add the Apache user to the Nagios group:

sudo usermod -a -G nagios apache

Now run the following command to install Nagios binary files, CGIs, and HTML files:

sudo make install
Output
...
*** Main program, CGIs and HTML files installed ***
...

Nagios can process commands from external applications. Create the external command directory and set the proper permissions by running the following command:

sudo make install-commandmode
Output
*** External command directory configured ***

Install the sample Nagios configuration files:

sudo make install-config
Output
*** Config files installed ***
Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

Run the command below to install the Apache web server configuration files:

sudo make install-webconf
Output
*** Nagios/Apache conf file installed ***

Then, restart Apache:

sudo systemctl restart httpd

Here you need to create a systemd unit file. The following command installs a systemd unit file and also configures the Nagios service to start on boot:

sudo make install-daemoninit
Output
*** Init script installed ***

Create an Admin User for Nagios on AlmaLinux 9

To be able to access the Nagios web interface we’ll create an admin user called nagiosadmin.

Run the following htpasswd command to create a user called nagiosadmin:

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

You will be asked to enter a password for your user:

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

To apply the changes, restart Apache:

sudo systemctl restart httpd

Configure Firewall for Nagios on AlmaLinux 9

At this point, you need to allow traffic on HTTP and HTTPs with the following commands:

# sudo firewall-cmd --permanent --zone=public --add-service=http
# sudo firewall-cmd --permanent --zone=public --add-service=https

To apply the new rules, run the following command:

sudo firewall-cmd --reload

Install Nagios Monitoring Tool Plugins on AlmaLinux 9

To install the Nagios plugins, switch to your /usr/src directory:

cd /usr/src/

Download the latest version of the Nagios Plugins from the project GitHub repository:

sudo wget -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.3/nagios-plugins-2.4.3.tar.gz

When the download is complete extract the tar file:

sudo tar zxf nagios-plugins.tar.gz

Switch to your Nagios plugins directory:

cd nagios-plugins-2.4.3

Run the following commands one by one to compile and install the Nagios plugins:

# sudo ./configure
# sudo make
# sudo make install

Start Nagios Service on AlmaLinux 9

Now that both Nagios and its plugins are installed, start the Nagios service on AlmaLinux 9 with the following command:

sudo systemctl start nagios

To verify that Nagios is running, check the service status with the following command:

sudo systemctl status nagios
Output
● nagios.service - Nagios Core 4.4.10
     Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor pr>
     Active: active (running) since Wed 2023-02-15 03:11:45 EST; 5s ago
       Docs: https://www.nagios.org/documentation
    Process: 112909 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nag>
    Process: 112910 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios>
   Main PID: 112911 (nagios)
      Tasks: 6 (limit: 23609)
     Memory: 6.1M
        CPU: 311ms
     CGroup: /system.slice/nagios.service
...

Access Nagios Monitoring Tool Web Interface

At this point, you access your Nagios Web Interface by typing your server’s IP address in your web browser followed by nagios:

http://server-ip/nagios

Enter the nagiosadmin user login credentials and click sign in:

Nagios login screen
Nagios Sign in page

You will be redirected to the default Nagios home page as shown in the image below:

Nagios dashboard
Nagios Dashboard

That’s it, you are done.

For more information, you can visit the Nagios Documentation page.

Conclusion

At this point, you have learned to Install and Configure the Nagios Monitoring Tool on AlmaLinux 9.

Hope you enjoy using it.

For more guides and articles, you can visit the Orcacore website.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!