monit-docker

MONIT-DOCKER / v0.0.64

Installation

Choose a Python environment on the host or the official Docker image. Start by reading metrics.

1. Prepare your machine

These examples assume Linux, a POSIX shell and a Docker Engine accessible by your account. Check docker ps -a. For Python, use Python 3.10 or 3.12 with venv and the system libmagic library (libmagic1 on Debian/Ubuntu). Stacks require Docker Compose v2 with up --wait.

Docker socket access grants powerful host privileges. A :ro mount does not make the Docker API read-only.

2A. Install with Python

python3 -m venv "$HOME/.local/share/monit-docker/venv"
"$HOME/.local/share/monit-docker/venv/bin/python" -m pip install 'monit-docker==0.0.64'
mkdir -p "$HOME/.local/state/monit-docker"
export PATH="$HOME/.local/share/monit-docker/venv/bin:$PATH"
export MONIT_DOCKER_LOGFILE="$HOME/.local/state/monit-docker/monit-docker.log"
export MONIT_DOCKER_RUNTIMEDIR="$HOME/.local/state/monit-docker/run"
monit-docker --help

These variables apply to the current shell. Keep these paths in your cron script or service definition. Installation uses the project’s declared dependencies, including HTTPdis and Sonicprobe.

3. Verify collection

Replace my-container with a name listed by Docker. Global options come before the subcommand.

docker ps -a
monit-docker stats --output json
monit-docker --name 'my-container' stats --rsc mem_usage --rsc cpu_percent

The JSON output should contain the selected containers and measurements. With no configuration file, the default local Docker connection can be used. See troubleshooting if collection fails.

2B. Use the Docker image

docker run --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  decryptus/monit-docker:0.0.64 \
  monit-docker stats --output json

The command after the image is explicit: monit-docker stats. Persistent rules also need a mounted state directory. The Docker serve guide provides a complete example.

4. Get the examples

git clone --branch v0.0.64 --depth 1 https://github.com/decryptus/monit-docker.git
cd monit-docker

This pinned checkout is used by the interface and monitoring guides. Next choose cron or serve.