Nagios Core, formerly known as Nagios, is a powerful, free, and open-source application that allows you to monitor systems, networks, and infrastructure. It provides comprehensive monitoring and alerting services for servers, switches, applications, and services, ensuring that you stay informed about any issues that may arise. In this guide, we will walk you through the step-by-step process of installing Nagios Core on Rocky Linux 8
1. Prerequisites
Before we begin the installation process, there are a few prerequisites that need to be met. Ensure that you have:
- A server running Rocky Linux 8.
- Root access or a user account with sudo privileges.
2. Install Required Dependencies
Before installing Nagios Core, we need to install some required libraries to ensure proper functionality. Open your terminal and run the following command:
sudo dnf install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp
This command will install the necessary dependencies, including Apache, PHP, GCC, GD, and Net-SNMP.
3. Create Nagios User and Group
Next, we need to create a dedicated user and group for Nagios. Run the following commands in your terminal:
sudo useradd nagios sudo groupadd nagcmd sudo usermod -G nagcmd nagios sudo usermod -G nagcmd apache
These commands create a user and group for Nagios and add both the Nagios user and the Apache user to the nagcmd group.
4. Download Nagios Core and Nagios Plugin
Now, let’s download Nagios Core and the Nagios plugins. Create a directory to store the installation files and navigate to it with the following commands:
mkdir ~/nagios && cd ~/nagios
Once inside the directory, download Nagios Core and the Nagios plugins using the following commands:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
These commands will download the latest versions of Nagios Core and Nagios plugins to your local machine.
5. Configure Nagios
Before we can proceed with the installation, we need to configure Nagios Core. Extract the downloaded files using the following commands:
tar -xvf nagios-4.4.6.tar.gz tar -xvf nagios-plugins-2.2.1.tar.gz
Once the files are extracted, navigate to the Nagios Core directory:
cd nagios-4.4.6/
To configure Nagios, run the following command:
./configure --with-command-group=nagcmd
This command will configure Nagios with the appropriate command group.
After running the configuration command, review the output to ensure that all the options are accurate. If everything looks good, proceed with the compilation and installation of the required libraries using the following commands:
make all make install
If the compilation and installation process completes without any errors, you can move on to the next step.
6. Compile and Install Nagios Plugin Libraries
To compile and install the Nagios Plugin libraries, navigate to the Nagios Plugin directory using the following command:
cd ~/nagios/nagios-plugins-2.2.1/
Next, run the configuration command:
./configure --with-nagios-user=nagios --with-nagios-group=nagios
This command configures the Nagios Plugin libraries with the appropriate user and group.
Once the configuration is complete, compile and install the required libraries using the following commands:
make all make install
This will compile and install the Nagios Plugin libraries on your system.
7. Verify Nagios Configuration Files
After installing Nagios Core and the Nagios Plugin libraries, it’s important to verify the configuration files to ensure everything is set up correctly. Run the following command:
/usr/local/nagios/bin/nagios -v /usr/local/nagios /etc/nagios.cfg
This command will validate the Nagios configuration files and provide you with any errors or warnings, if any.
8. Enable Nagios Services
To enable Nagios services to start automatically on system boot, run the following commands:
sudo systemctl enable nagios sudo systemctl enable httpd
These commands will enable both Nagios and Apache services to start on system boot.
9. Accessing the Nagios Web Interface
To access the Nagios Web Interface, open a web browser and enter the following URL:
http://your-server-ip-address/nagios
Replace “your-server-ip-address” with the actual IP address or domain name of your server.
You will be prompted to enter the username and password. Use the default username “nagiosadmin” and the password you set earlier.
Once logged in, you will have access to the Nagios Web Dashboard, where you can configure and monitor your systems, networks, and infrastructure.
10. Additional Configuration: Email Alerts
To configure email alerts in Nagios, open the contacts.cfg file using a text editor:
sudo vi /usr/local/nagios /etc/objects/contacts.cfg
In this file, you can define the email addresses where you want to receive alerts. Locate the “CONTACTS” section and modify the email address accordingly:
define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin email your-email@example.com }
Save the changes and exit the text editor.
11. Additional Configuration: Web Interface Password
To set a password for the Nagios Web Interface, use the htpasswd command:
sudo htpasswd -s -c /usr/local/nagios /etc/htpasswd.users nagiosadmin
You will be prompted to enter and confirm the password. Once set, restart the Apache service for the changes to take effect:
sudo systemctl restart httpd
12. Conclusion
Congratulations! You have successfully installed Nagios Core on Rocky Linux 8. With Nagios, you can now monitor your systems, networks, and infrastructure with ease. Remember to regularly check the Nagios Web Interface for alerts and configure additional settings as per your requirements.
If you encounter any technical difficulties or need further assistance, don’t hesitate to reach out to our support team at Shape.host. We offer reliable and scalable Linux SSD VPS hosting solutions to help you streamline your operations and ensure maximum uptime for your business.