Quick Guide to Installing and Configuring Nagios on CentOS Stream 9
In this guide, we’ll go through the steps needed to install and configure Nagios on CentOS Stream 9. Nagios is a widely used open-source monitoring tool that helps system administrators monitor network devices, services, and host resources. The Nagios installation on CentOS Stream 9 is as follows :
1. Update Your System
2. Install Required Packages
3. Create a Nagios User and Group
4. Download and Install Nagios Core
5. Install and Configure Nagios Plugins
6. Configure Nagios Web Interface
7. Start Nagios
8. Open the Firewall
9. Access the Nagios Web Interface
10. Verify Configuration and Start Monitoring
Nagios is a powerful, open-source IT infrastructure monitoring system widely used to monitor networks, servers, applications, and services. It’s particularly popular among system administrators for its extensive features, flexibility, and reliability, making it ideal for large-scale IT environments where maintaining uptime and performance is crucial.
Prerequisites
Before you begin, make sure you have:
- A server running CentOS 9
- A non-root user with sudo privileges
- Basic understanding of the command line
Let’s get started!
Step 1: Update Your System
To ensure all packages are up to date, run:
$ sudo dnf update -y
This command will download and install any available updates.
Step 2: Install Required Packages
Nagios requires several dependencies to run properly. Install them with the following command:
$ sudo dnf install httpd php gcc glibc glibc-common wget unzip -y
This will install Apache (httpd), PHP, and additional libraries.
Step 3: Create a Nagios User and Group
Nagios needs its own user and group. Create them by running:
$ sudo useradd nagios $ sudo usermod -aG nagios apache
Step 4: Download and Install Nagios Core
Next, download the latest Nagios Core package from the official site:
$ cd /tmp $ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz $ tar -zxvf nagios-4.4.6.tar.gz $ cd nagios-4.4.6
Now, configure and compile Nagios:
$ sudo ./configure --with-command-group=nagios $ sudo make all $ sudo make install $ sudo make install-init $ sudo make install-config $ sudo make install-commandmode
Step 5: Install and Configure Nagios Plugins
Download the Nagios plugins, which provide additional checks and features:
$ cd /tmp $ wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz $ tar -zxvf nagios-plugins-2.3.3.tar.gz $ cd nagios-plugins-2.3.3
Then configure and compile the plugins:
$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios $ sudo make $ sudo make install
Step 6: Configure Nagios Web Interface
To access Nagios from a web browser, you’ll need to configure Apache:
1. Create a Nagios Admin User:
$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
When prompted, enter a password for the user.
2. Configure Apache: Enable the Nagios configuration file in Apache:
$ sudo ln -s /usr/local/nagios/etc/nagios.conf /etc/httpd/conf.d/
3. Restart Apache:
$ sudo systemctl restart httpd
Step 7: Start Nagios
Enable and start the Nagios service:
$ sudo systemctl enable nagios $ sudo systemctl start nagios
Step 8: Open the Firewall
Allow HTTP traffic so you can access the Nagios web interface:
$ sudo firewall-cmd --zone=public --add-service=http --permanent $ sudo firewall-cmd --reload
Step 9: Access the Nagios Web Interface
Open your web browser and go to:
http://your_server_ip/nagios
Log in using the credentials for nagiosadmin
.
Step 10: Verify Configuration and Start Monitoring
To confirm that everything is working, Nagios provides a configuration verification tool:
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
After verifying, restart Nagios to load the configuration:
$ sudo systemctl restart nagios
Conclusion
Congratulations! You’ve successfully installed and configured Nagios on CentOS 9. Now, you’re ready to start monitoring hosts, services, and network devices. For advanced monitoring setups, explore adding custom plugins or configuring alerts for more granular control.