Share your love
Install and Configure Nagios on Rocky Linux 8
In this tutorial, we intend to teach you to Install and Configure Nagios Core Monitoring Tool on Rocky Linux 8.
Nagios is a free and open-source software application for computer systems. It is used for monitoring the systems, networks, and infrastructure.
This software application mainly provides the services of monitoring and alerting for switches, applications, and servers inside the DevOps culture.
It is also used to notify the users when things go bad, and also alerts them when things become better.
This software application is written in C language, which was mainly designed to run under the Linux operating system. But it can also run under Unix and Windows operating systems.
This software application is available in the following two variants:
- Nagios Core: The Nagios is also known as a Nagios Core. It is an open-source product.
- Nagios XI: It is an extended version of Nagios. It provides advanced components and tools for monitoring. This variant needs a software license.
Steps To Install and Configure Nagios on Rocky Linux 8
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 Rocky Linux 8.
Then, you must have Apache installed on your server. For this purpose, you can follow this guide on Installing Apache Web Server on Rocky Linux 8.
Also, you must have PHP installed on your server. To do this, you can follow our guide on How To Install PHP 8.1 on Rocky Linux 8.
And you must disable the SELinux.
When you are done, follow the steps below to Set up Nagios Core on Rocky Linux 8.
Required Packages For Nagios on Rocky Linux 8
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 Rocky Linux 8:
cd nagios-4.4.10
Compile and Build Nagios Core on Rocky Linux 8
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 Rocky Linux 8:
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 Rocky Linux 8
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 Rocky Linux 8
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 Rocky Linux 8
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 Rocky Linux 8
Now that both Nagios and its plugins are installed, start the Nagios service on Rocky Linux 8 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 pres>
Active: active (running) since Fri 2023-02-24 15:37:19 EST; 7s ago
Docs: https://www.nagios.org/documentation
Process: 130181 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/e>
Process: 130180 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagio>
Main PID: 130183 (nagios)
Tasks: 6 (limit: 23699)
Memory: 4.9M
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:
You will be redirected to the default Nagios home page as shown in the image below:
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 Rocky Linux 8.
Hope you enjoy using it. You may be like these articles on the Orcacore website: