Installing Nagios Cross-Platform Agent on a Debian 12 Workstation

Picture of Johnny Mengistu
Johnny Mengistu

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 Nagios 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’s 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 and Install 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:

Note: Ensure that you check the Nagios 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 the script:

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:

The community string token, by default, might have a series of numbers or it might say “my_token”. After making changes press “CTRL and X ” then press Y to confirm your changes and hit Enter to save everything.

Step 5: Install & Enable UFW

If you already have ufw installed and enabled skip this step. If you dont you’ll need to install ufw with the following scripts. First we’ll check the status by:

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 start the NCPA service. Use the following command to start 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 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. This step is optional but recommended. 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.

3. You will then enter the community string API token from earlier in step 4 & click Log In. If you have the token proceed to the next step otherwise go back & retrieve it.

4. Your screen should look like the one below. Click See Live Stats to continue

Step 9: Configure NCPA on Nagios XI

  1. In the Neptune interface, log into Nagios XI and hover your mouse over the gear icon & select Configuration Wizards. Or click the gear icon & then click Configuration Wizards. If you’re using light or dark mode the buttons might be in different locations.
  2. In the search bar above like in the picture below look for NCPA and select it

3. Enter the IP address, API token and system you are using (Debian) like in the picture below

4. Fill in the rest of the information to your liking and click Finish or Finish w/Defaults

5. After you are finished click the home icon on the far left and select the green host bar in the middle of the screen like in the picture below.

6. Select the name of the NCPA agent you just created & you will see Host Status Details

Conclusion

Installing Nagios 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: https://www.nagios.com

Visit Nagios Support: https://support.nagios.com/

Visit Nagios Exchange: https://exchange.nagios.org/

Share

Table of Contents