NDC & PKI

[Day 5] 8. Monitoring a Remote Linux Machine using Nagios

D
DITISS Admin
••5 min read

Overview

Goal:
Set up Nagios to monitor a remote Linux machine using NCPA (Nagios Cross-Platform Agent).

Setup:

  1. Nagios Server: The machine where Nagios is installed.
  2. Client Machine: The Linux system you want to monitor remotely.

Pre-requisite: Before proceeding, ensure the following:

  1. Nagios Server Configuration:
    If your Nagios server is not yet configured, refer to Day 3, File 6 and 7 for detailed setup instructions.

  2. Changes from Day 4, File 4:
    Apply only the Nagios Server-specific changes mentioned in the file. Ignore the configurations related to monitoring a Windows machine.


Steps

1. Install Dependencies on the Client Machine

Run the following command to install required dependencies on the Client Machine:

bash
sudo apt-get install wget libsqlite3-0

2. Install NCPA on the Client Machine

  1. Download the NCPA Package:
    Download the latest NCPA .deb file for your system.

  2. Install NCPA:
    Use the

    dpkg
    command to install it:

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

    here

    -i
    stands for installation.


3. Configure NCPA on the Client Machine

  1. Edit the Configuration File:
    Open the

    ncpa.cfg
    file to set the community string (password):

    bash
    sudo vim /usr/local/ncpa/etc/ncpa.cfg
    

    Search for

    community_string
    and set your password:

    plaintext
    community_string = <your_token>
    
  2. Restart the NCPA Service:

    bash
    sudo systemctl restart ncpa
    sudo systemctl status ncpa
    

4. Test Connectivity Between Nagios Server and Client

  1. On the Nagios server, navigate to the

    libexec
    directory:

    bash
    cd /usr/local/nagios/libexec/
    
  2. Test the connection with the client machine:

    bash
    sudo ./check_ncpa.py -t <your_token> -H <linux_machine_ip> -M system/agent_version
    
    • Replace
      <your_token>
      with the password you configured in
      ncpa.cfg
      .
    • Replace
      <linux_machine_ip>
      with the IP address of the client machine.
    • If successful, this command will return the agent version.

5. Configure Nagios to Monitor the Client

  1. Navigate to the Nagios configuration directory:

    bash
    cd /usr/local/nagios/etc/servers
    
  2. Create a configuration file for the client (e.g.,

    deb_12-1.cfg
    ):

    bash
    sudo vim deb_12-1.cfg
    
  3. Add the following content to the file:

    plaintext
    define host {
        use                   linux-server
        host_name             deb_12-1
        alias                 Debian 12 Sys 1
        address               <linux_machine_ip>
        max_check_attempts    5
    }
    define service {
        use                   generic-service
        host_name             deb_12-1
        service_description   Agent Version
        check_command         check_ncpa!-t '<your_token>' -p -P 5693 -M system/agent_version
    }
    define service {
        use                   generic-service
        host_name             deb_12-1
        service_description   Virtual Memory
        check_command         check_ncpa!-t '<your_token>' -p -P 5693 -M memory/virtual -w 50 -c 80 -u G
    }
    
    • Replace
      <linux_machine_ip>
      with the client machine's IP address.
    • Replace
      <your_token>
      with the password you set earlier.

6. Restart Nagios

Restart the Nagios service to load the new configuration:

bash
sudo systemctl restart nagios
sudo systemctl status nagios

7. Access the Nagios Web Interface

Open a browser and navigate to:

plaintext
http://<nagios_server_ip>/nagios
  • Replace
    <nagios_server_ip>
    with the IP address of the Nagios server.
  • Log in with your Nagios credentials to view the monitoring status.

Expected Output

  1. Agent Version: Displays the version of the NCPA agent installed on the client.
  2. Virtual Memory: Shows the current virtual memory usage with warning (
    -w
    ) and critical (
    -c
    ) thresholds set at 50% and 80%, respectively.

Troubleshooting

  1. NCPA Connectivity Issues:
    • Verify the NCPA service is running on the client:

      bash
      sudo systemctl status ncpa
      
    • Ensure the Nagios server can reach the client machine on port 5693 (default NCPA port).

  2. Invalid Token or IP:
    • Double-check the
      community_string
      in
      ncpa.cfg
      and ensure it matches the token in the Nagios configuration.
    • Verify the client machine's IP address.

Read Next

8/26/2026

[Day 5] 9. Extra

#### **1. What is an Application Proxy?** An **Application Proxy** acts as an intermediary between the client and the server, facilitating secure c...

8/26/2026

[Day 6] 1. Firewall and its Types

A **Firewall** is a unit (hardware, software, or a combination of both) used to control network traffic. It allows authorized traffic and blocks unaut...