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


Prerequisites
Before starting, ensure you have:
- A macOS system running macOS 12 Monterey or later 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 some required dependencies.
1.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).
1.2 Install Required Dependencies
Install Python 3, OpenSSL, and Git using Homebrew:
brew install python3 openssl git
This installs Python 3.x (e.g., 3.11 or later), OpenSSL for secure communication, and Git for cloning the NCPA repository.
1.3 Verify Python Installation
Check the version to ensure it’s installed:
python3 --version
Step 2: Download NCPA Source Code
Nagios doesn’t provide a direct macOS package for NCPA, so we’ll clone it from GitHub.
2.1 Clone the NCPA Repository
Run the following command to clone the NCPA source code:
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).
2.2 Optional: Check for Updates
If you want a specific version, use:
git checkout v3.1.2 # replace with the desired version tag
Otherwise, the master branch (default) is fine for the latest stable version.
Step 3: Build NCPA from Source
3.1 Install Python Dependencies
Before building, install the Python dependencies listed in the requirements.txt
file:
pip3 install -r requirements.txt
This installs libraries like psutil, bottle, and other required modules.
3.2 Run the Build Script
Build the NCPA binary 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. If there’s an issue with architecture, you can explicitly specify:
arch -arm64 python3 build.py --platform macos
3.3 Locate the Output
After a successful build, the executable and supporting files will be in a build
subdirectory (e.g., build/ncpa). The folder name may vary based on the platform (e.g., build/ncpa-macos-arm64).
Step 4: Install NCPA
Now, move the built files to a standard location and set up the agent.
4.1 Copy Files to Installation Directory
To maintain consistency, copy the NCPA files to /usr/local/ncpa
:
sudo mkdir -p /usr/local/ncpa
sudo cp -r build/ncpa/* /usr/local/ncpa/
Make sure to adjust the build/ncpa
path if needed, based on your output.
4.2 Set Permissions
Ensure the files are executable:
sudo chmod +x /usr/local/ncpa/ncpa
Step 5: Configure NCPA
5.1 Edit the Configuration File
The main configuration file is usually located at /usr/local/ncpa/etc/ncpa.cfg
. Open it with nano
:
sudo nano /usr/local/ncpa/etc/ncpa.cfg
In the configuration file, set the API token (used for secure communication):
[general]
community_string = Str0ngT0k3n!
Restrict access to your Nagios server’s IP by updating the allowed_hosts
section:
[general]
allowed_hosts = <Nagios_IP_address>
Save and exit (Ctrl+X
, then Y
to confirm, and Enter
).
5.2 Test the Configuration
You can now test the NCPA agent:
sudo /usr/local/ncpa/ncpa
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 ensure NCPA starts automatically on boot, you’ll need to create a launchd service file.
6.1 Create the Service File
Create the com.nagios.ncpa.plist
file:
sudo nano /Library/LaunchDaemons/com.nagios.ncpa.plist
Paste the following content into the file:
<?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</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/ncpa/ncpa</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
6.2 Load and Start the Service
Now, load and start the service with:
sudo launchctl load /Library/LaunchDaemons/com.nagios.ncpa.plist
sudo launchctl start com.nagios.ncpa
6.3 Verify Services
Check that NCPA is running by listing the services:
sudo launchctl list | grep ncpa
You should see the service listed along with its process IDs (PIDs).
Step 7: Verify NCPA Installation
7.1 Check the Web Interface
Open a browser and visit:
https://localhost:5693
Log in using the API token you set earlier (Str0ngT0k3n!
or your custom value).
7.2 Test from Nagios Server
From your Nagios server, run:
curl -k https://<your_mac_ip>:5693/api
Step 8: Add NCPA to Nagios
On your Nagios XI web GUI:
- Navigate to Configuration Wizards.

- Select Mac OS X.

- Enter the IP address of your macOS system and the API token you created in the configuration file.
- Follow the wizard to select the system metrics you want to monitor.

- Click Finish to complete the setup.
Conclusion
By following these steps, you have successfully installed the Nagios Cross-Platform Agent (NCPA) on macOS Monterey for Apple Silicon. Your Nagios monitoring server will now be able to collect system metrics and monitor your macOS system in real time.
For further support, refer to:
- Nagios Support Forum: https://support.nagios.com/forum/
- Nagios Knowledge Base: https://support.nagios.com/kb/