How to Easily Monitor Docker Containers with Nagios XI (2025)

Picture of Tucker Falen
Tucker Falen
docker

Monitoring Docker containers is essential for maintaining system health and performance. Nagios XI provides a powerful Docker Configuration Wizard that enables users to track container status and resource usage effectively. This guide walks through the setup process, outlining two primary methods: using Docker’s Remote API or executing a plugin on the Docker server via the Nagios Cross-Platform Agent (NCPA).

Using Docker Remote API

If possible, leveraging Docker’s built-in cURL API is highly recommended. This method involves binding the Docker socket to a TCP port. To test the connection, execute the following command from your Nagios XI server (replace ip and port with the appropriate values for your Docker server):

curl -f -g http://ip:port/containers/json?all=true

Alternatively, you can use the “Populate Containers/Networks” button in the Docker Configuration Wizard. If the list successfully populates or the above command returns a JSON object (other than {"message": "page not found"}), proceed to the next step.

Using NCPA

If binding Docker to a TCP port isn’t an option, you will need to install NCPA on your Docker machine. Download the NCPA installer via the Docker Configuration Wizard or the “Installing NCPA” documentation.

Steps to Configure NCPA:

  1. Download the check_docker.py plugin to NCPA’s plugin directory:
cd /usr/local/ncpa/plugins/
wget http://xi_address/nagiosxi/includes/configwizards/docker/plugins/check_docker.py
  1. Add the Nagios user to the Docker group to grant read/write permissions to the Docker socket:
usermod -a -G docker nagios
  1. Restart the machine for the changes to take effect.

After these steps, proceed to the Docker Configuration Wizard.

Docker Configuration Wizard

The Docker Configuration Wizard communicates with your Docker installation via the UNIX socket. Each check retrieves relevant metrics and compares them against user-defined thresholds.

Accessing the Wizard

Navigate to Run a Wizard in Nagios XI and select the Docker wizard. The search field can help locate the wizard quickly.

Screenshot 2025 03 06 163431
Config wizards page

Step 1: Docker Server Information

Depending on your access method, different options will be available:

Remote Agent (NCPA)

  • IP Address: The IP of the Docker host.
  • NCPA Listener Port: The configured NCPA listening port.
  • NCPA Token: The authentication token for NCPA.
  • Docker Socket: Typically located at /var/run/docker.sock.
  • Docker API Base URL: Corresponds to the API version (e.g., http:/v1.30/).
Screenshot 2025 03 06 163848
Docker config wizard page

Remote API

  • IP Address: The IP of the Docker host.
  • Docker API Base URL: Access URL for the Docker API (e.g., http://ip:port/).

If using the Remote API method with TLS security enabled, additional fields for certificate file locations will be required.

Step 2: Selecting Checks

Users must select the monitoring checks to be performed. The wizard provides options such as:

  • Existing Containers: Tracks running and non-running containers.
  • Healthy Containers: Monitors health status and handles containers without a health check.
  • CPU Usage: Collects CPU usage as a percentage of the host system.
  • Memory Usage: Measures memory consumption as a resident set size.

Each check allows threshold configuration, timeout settings, and various output formats.

Step 3: Completing the Setup

After configuring thresholds and selecting checks, click Next to proceed through the remaining steps. Once completed, finalize the setup by clicking Finish. The wizard will apply the configuration, and a status link will appear to review the newly created services.

Conclusion

This guide provides a comprehensive walkthrough for monitoring Docker containers using Nagios XI. By leveraging either the Remote API or NCPA-based plugin execution, users can efficiently track container health and resource utilization.

Share: