How to Install Nagios Cross-Platform Agent (NCPA) on Apple Silicon macOS

Picture of Jack Brisben
Jack Brisben
AppleSilicoln

Nagios Cross-Platform Agent (NCPA) is a flexible monitoring agent designed for Nagios Core and Nagios XI, allowing you to monitor system metrics, processes, services, and custom plugins. This guide walks you through building and installing NCPA from source on an Apple Silicon Mac, as no official ARM-native binary is available.

Prerequisites

Before starting, ensure you have:

  • A macOS system running macOS 11 Big Sur or later (e.g., Ventura, Sonoma) on Apple Silicon.
  • Administrator privileges (sudo access).
  • An active Nagios Core or Nagios XI server to receive monitoring data.
  • Basic familiarity with the Terminal and command-line tools.

Step 1: Install Development Tools and Dependencies

Since we’re building NCPA from source, you’ll need Homebrew (a package manager) and specific dependencies.

  1. Install Homebrew (if not already installed): Open Terminal and run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

On Apple Silicon, Homebrew installs to /opt/homebrew/. Add it to your PATH if prompted (instructions will appear after installation).

Step 2: Download and Install the NCPA Package

Nagios does not provide a direct macOS package for NCPA. However, you can install it via Homebrew.

2.1 Update Homebrew

brew update

2.2 Install Required Dependencies: NCPA is Python-based and requires Python 3, OpenSSL, and other libraries. Install them with:

brew install python3 openssl git

This installs Python 3.x (e.g., 3.11 or later), OpenSSL for secure communication, and Git to clone the NCPA repository.

Verify Python Installation: Check the version to ensure it’s installed:

python3 --version

Step 2: Download NCPA Source Code

NCPA’s source is hosted on GitHub. Clone the repository to your system.

Clone the NCPA Repository:

git clone https://github.com/NagiosEnterprises/ncpa.git
cd ncpa

This downloads the latest NCPA source (e.g., version 3.1.2 or newer if updated post-March 2025).

Optional: Check for Updates: If you want a specific version, use git checkout v3.1.2 (replace with the desired tag). Otherwise, the default branch (master) is fine.

To ensure the services start automatically on boot, use launchctl:

Step 3: Build NCPA from Source

NCPA includes a build script to compile the agent into an executable package.

1. Install Python Dependencies: Inside the ncpa directory, install required Python packages:
pip3 install -r requirements.txt

This installs libraries like psutil, bottle, and others listed in requirements.txt.

2. Run the Build Script: Build NCPA for macOS:

python3 build.py --platform macos
  • The –platform macos flag ensures macOS-specific adjustments. On Apple Silicon, Python and dependencies should automatically target ARM64, as Homebrew provides ARM-native versions.
  • If the build fails due to architecture issues, you may need to specify the target explicitly with arch -arm64 python3 build.py –platform macos.

Locate the Output: After a successful build, the executable and supporting files are typically placed in a build subdirectory (e.g., build/ncpa). The exact folder name may vary (e.g., build/ncpa-macos-arm64).

Step 4: Install NCPA

Move the built files to a standard location and set up the agent.

  1. Copy Files to Installation Directory: For consistency, install NCPA to /usr/local/ncpa
sudo mkdir -p /usr/local/ncpa
sudo cp -r build/ncpa/* /usr/local/ncpa/
  • Adjust the build/ncpa path based on your build output.

Set Permissions: Ensure the files are executable

sudo chmod +x /usr/local/ncpa/ncpa_listener /usr/local/ncpa/ncpa_passive

Step 5: Configure NCPA

Edit the configuration file to secure and customize the agent.

  1. Edit the Configuration File: The config file is usually ncpa.cfg in the installation directory
sudo nano /usr/local/ncpa/etc/ncpa.cfg
  • Update the API token (used for secure communication):
[general]
community_string = Str0ngT0k3n!
  • Restrict access to your Nagios server’s IP:
[general]
allowed_hosts = <Nagios_IP_address>
  • Save and exit (Ctrl+X, Y, Enter)

2. Test the Configuration: Start the listener manually to check for errors:

sudo /usr/local/ncpa/ncpa_listener
  • If it runs without errors (e.g., binding to port 5693), press Ctrl+C to stop it.

Step 6: Set Up NCPA as a Service

To run NCPA automatically on boot, create launchd service files.

  1. Create Listener Service File:
sudo nano /Library/LaunchDaemons/com.nagios.ncpa_listener.plist

Paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.nagios.ncpa_listener</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/ncpa/ncpa_listener</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

2. Create Passive Service File:

sudo nano /Library/LaunchDaemons/com.nagios.ncpa_passive.plist

Paste:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.nagios.ncpa_passive</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/ncpa/ncpa_passive</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

3. Load and Start Services:

sudo launchctl load /Library/LaunchDaemons/com.nagios.ncpa_listener.plist
sudo launchctl load /Library/LaunchDaemons/com.nagios.ncpa_passive.plist
sudo launchctl start com.nagios.ncpa_listener
sudo launchctl start com.nagios.ncpa_passive

4. Verify Services:

sudo launchctl list | grep ncpa
  • You should see both services listed with PIDs if running.

Step 7: Verify NCPA Installation

  1. Check the Web Interface: Open a browser and go to:
https://localhost:5693
  • Log in with the API token (Str0ngT0k3n! or your custom value).

2. Test from Nagios Server: From your Nagios server, run:

curl -k https://<your_mac_ip>:5693/api

You should receive a JSON response indicating the system’s status.

Step 8: Add NCPA to Nagios

On your Nagios XI web GUI:

  • Navigate to Run a Wizard.
Configuration Wizards
Configuration Wizards
  • Select Mac OS X.
Screenshot 2025 02 20 093742
Mac Wizard
  • Enter the IP address of your macOS system and the token you created in the configuration file.
Screenshot 2025 02 20 094438
setup NCPA
  • Click Next and choose the system metrics you want to monitor, or leave everything as default.
  • Click Finish to complete the setup.

Conclusion

By following these steps, you have successfully installed Nagios Cross-Platform Agent (NCPA) on Apple Silicon macOS. Your Nagios monitoring server will now be able to collect system metrics and monitor your macOS system in real time.

For additional support, refer to:

Share: