Installing Nagios Cross-Platform Agent on a Debian 12 Workstation

Picture of Johnny Mengistu
Johnny Mengistu
Debian 12 logo with a green gradient backgound.

Nagios Core is one of the most widely used monitoring solutions for IT infrastructure, and the Nagios Cross-Platform Agent (NCPA) is a versatile and powerful tool for monitoring both Linux and Windows systems. NCPA allows you to monitor system metrics such as CPU usage, memory consumption, disk space, and more. In this guide, we will walk you through the steps to install NCPA on a Debian 12 workstation.

Prerequisites

Before starting the installation, ensure that you have the following prerequisites in place:

  • A working Debian 12 workstation.
  • A user with sudo privileges.
  • Basic knowledge of using the terminal and text editors like nano or vim.
  • Knowledge of bash scripting
  • A working instance of Nagios XI

Step 1: Update the System

It is always a good idea to make sure your system is up to date before installing any new software. Open a terminal and run the following commands to update the package lists and upgrade existing packages:

sudo apt update
sudo apt upgrade -y

Step 2: Download the NCPA Package

Now, you’ll need to download the NCPA package from Nagios’s official website. You can do this using the wget command. First, navigate to the directory where you want to store the downloaded package. For simplicity, we’ll use the /tmp directory:

cd /tmp

Next, download the latest NCPA package for Debian. The following command downloads the latest .deb package for Debian systems:

wget https://assets.nagios.com/downloads/ncpa3/ncpa-latest-1.amd64.deb

You should see an image similar to this below if done correctly:

Download the NCPA Package
NCPA Package

Note: Ensure that you check the NCPA GitHub releases page for the most recent version of NCPA and replace the link above accordingly.

Step 3: Install the NCPA Package

Once the package is downloaded, you can install it using the dpkg command:

sudo dpkg -i ncpa-latest-1.amd64.deb

Step 4: Configure NCPA

After installation, you’ll need to configure the NCPA agent. The configuration file is located at /usr/local/ncpa/etc/ncpa.cfg.

To edit the configuration, you can use the script below:

sudo nano /usr/local/ncpa/etc/ncpa.cfg

Your screen should look similar to the one below after running the script:

NCPA Main Config File e1791384306558
NCPA Config

Set a Password for the NCPA API

In the configuration file, look for the API key parameter. This is used to authenticate API requests. You should set a strong password for the API key. It should look like this below:

NCPA Main Config File API Comm String Token rev2
Listener Config

The community string token, by default, might have a series of numbers or it might say my_token. Replace mytoken with a secure API token of your choice. Save the file (CTRL + X, then Y, and Enter).

Step 5: Install & Enable UFW

If you already have UFW (Uncomplicated Firewall) installed and enabled skip this step. If you don’t, you’ll need to install UFW with the following scripts. First we’ll check the status:

sudo ufw status

Then if it’s not installed we’ll need install it, check the status again to make sure it’s there, enable then reload it. Enter each script individually, not at the same time:

sudo apt install ufw
sudo ufw status
sudo ufw enable
sudo ufw reload

Step 6: Start the NCPA Service

Once you have configured NCPA to your liking and installed UFW, you need to restart the NCPA service:

systemctl restart ncpa

This will restart the service, and NCPA will now use the newly configured token.

Step 7: Configure Firewall

Next we’ll configure the firewall and allow traffic on port 5693 which is used by NCPA

1. Create the necessary directory for UFW application profiles:

sudo mkdir -p /etc/ufw/applications.d

2. Create a custom application profile for NCPA. Make sure to enter each script individually and not at the same time.

sudo sh -c "echo '[NCPA]' > /etc/ufw/applications.d/ncpa"
sudo sh -c "echo 'title=Nagios Cross Platform Agent' >> /etc/ufw/applications.d/ncpa"
sudo sh -c "echo 'description=Nagios Monitoring Agent' >> /etc/ufw/applications.d/ncpa"
sudo sh -c "echo 'ports=5693/tcp' >> /etc/ufw/applications.d/ncpa"

3. Allow NCPA traffic through the firewall:

sudo ufw allow NCPA

4. Reload the firewall to apply the changes:

sudo ufw reload

Step 8: Verify NCPA Installation

1. Open a web browser and go to: https://<NCPA_IP_Address>:5693/

2. You will see the error message below saying that site isn’t safe to continue. Simply click Advanced and proceed to the site.

NCPA Warning Message
Warning Message

3. On the NCPA login page, enter the community string API token you configured earlier in Step 4 and click Log In.

4. You will be directed to the NCPA Dashboard and your screen should look like the one below. Click See Live Stats to continue.

NCPA Check Status
NCPA Dashboard > See Live Stats

Step 9: Configure NCPA on Nagios XI

1. Log into Nagios XI.

2. Open the NCPA Wizard by selecting Configure > Run a Monitoring Wizard > NCPA.

ConfigurationWizard NCPA
NCPA Wizard

3. Enter the IP address of the server, the API token you configured in Step 4, and select Debian as the system you are using. Click Next.

4. Complete the Wizard setup and apply configuration changes.

NCPA Config Info Step1
NCPA Wizard Step 1

5. After completing the Wizard, Nagios XI should display the monitored host and its services.

6. Navigate to the Host Status Detail page to confirm that the system is being monitored.

NCPA Host Status Detail Debian12
Host Status Detail page

Conclusion

Installing NCPA on a Debian 12 workstation is a straightforward process that allows you to collect valuable system metrics and monitor your system from Nagios Core. By following these steps, you can ensure that your workstation is integrated into your monitoring setup, providing real-time insights into your system’s performance and health.

Once installed, you can further customize the NCPA configuration to suit your environment, add it to your Nagios monitoring setup, and ensure that your system is continuously monitored for performance issues.

Additional Resources

Visit Our Website

Visit Nagios Support Forum

Visit Nagios Exchange

Visit Nagios Documentation Hub

Share: