Efficient Server Monitoring with NCPA and Nagios XI on RHEL 9


Effective server monitoring is crucial for maintaining optimal system performance and addressing issues before they escalate. The Nagios Cross-Platform Agent (NCPA) is a lightweight, agent-based tool that simplifies real-time monitoring for Linux systems like Red Hat Enterprise Linux (RHEL) 9. Unlike SNMP, NCPA uses a secure, RESTful API to collect detailed system metrics, offering a powerful and secure solution for integration with Nagios XI. This guide will walk you through the installation and configuration process of NCPA on RHEL 9, enabling comprehensive system monitoring through Nagios XI.
Prerequisites
Before proceeding, make sure you have:
- A RHEL 9 system with root or sudo privileges.
- Nagios XI installed and accessible, with the NCPA Wizard enabled.
- A stable internet connection for package downloads.
- SELinux set to
enforcing
orpermissive
(check withgetenforce
; adjust if needed).
Step 1: Install the Nagios Repository
The recommended method for installing NCPA on RHEL 9 is by using the Nagios repository. To add the repository, run:
sudo rpm -Uvh https://repo.nagios.com/nagios/9/nagios-repo-9-2.el9.noarch.rpm
sudo dnf update
After adding the repository, update your package list:
sudo dnf clean all
sudo dnf update -y
Step 2: Install NCPA on RHEL 9
Once the repository is set up, install the NCPA agent using:
sudo dnf install ncpa -y
Verify the installation:
rpm -q ncpa
Expected output:
ncpa-.el9.x86_64 (e.g., ncpa-3.1.1-1.el9.x86_64)
Step 3: Configure NCPA
After installation, configure NCPA by editing the configuration file to set your API token:
sudo nano /usr/local/ncpa/etc/ncpa.cfg
Find the line:
community_string = mytoken
Replace mytoken
with a strong, unique token (e.g., K9pL3mX7vR2tQ8nJ
), ensuring it is not predictable for security reasons.
Save the file (CTRL + X, then Y, and Enter).
Step 4: Enable and Start the NCPA Service
To ensure NCPA runs automatically at boot and starts immediately, run:
sudo systemctl enable ncpa
sudo systemctl start ncpa
Check if the service is running:
sudo systemctl status ncpa
onfirm that the output shows Active: active (running).
Step 5: Configure Firewall Rules
If firewalld
is active (check with sudo systemctl status firewalld
), allow NCPA traffic on port 5693:
sudo firewall-cmd --zone=public --add-port=5693/tcp --permanent
sudo firewall-cmd --reload
Confirm firewall rules:
sudo firewall-cmd --list-ports
Step 6: Test NCPA Installation
After configuring the firewall, confirm that NCPA is accessible by navigating to:
https://NCPA_IP_ADDRESS:5693/
Since NCPA uses a self-signed certificate, your browser may display a warning. Click Advanced > Proceed to continue.
You should see the NCPA login page. Enter the API token you configured earlier and click Log In.
Step 7: Add RHEL 9 Host to Nagios XI Using NCPA Wizard
Log in to Nagios XI.
Navigate to Configure > Configuring Wizard.

Search for and select NCPA.

Enter the RHEL 9 server’s IP address and the API token.

Click Next, then select the system metrics to monitor (CPU, memory, disk, network traffic, etc.).
Apply the configuration and verify that Nagios XI is collecting data from your RHEL 9 host.
Common Issues & Fixes
NCPA Service is Not Running
Check logs for errors:
sudo journalctl -u ncpa --no-pager | tail -20
Restart NCPA if necessary:
sudo systemctl restart ncpa
Host Appears “Down” in Nagios XI
Check firewall rules:
sudo firewall-cmd --list-ports
Ensure NCPA is running:
sudo systemctl status ncpa
Verify the Nagios XI configuration.
Incorrect API Token Error
- Confirm the correct API token is set in
ncpa.cfg
. - Restart the NCPA service after changes: bashCopy
sudo systemctl restart ncpa
Conclusion
You have successfully installed and configured NCPA on RHEL 9 for monitoring with Nagios XI. This setup enables you to efficiently track system performance metrics and ensure proactive issue resolution.