mirror of
https://gitlab.uzh.ch/stelian.tsekov/check_containers.git
synced 2025-09-04 02:40:13 +00:00
Nagios Plugin to check for running Podman/Docker containers
.gitea/workflows | ||
.gitignore | ||
check_containers.py | ||
LICENSE.md | ||
README.md |
check_containers
A Nagios Plugin to check for containers using the Docker/Podman CLI.
Features
- Automatically detects Docker or Podman installations
- Checks status of specific containers or all containers
- Checks containers by status (running, exited, paused, restarting)
- Customizable thresholds for OK, WARNING, and CRITICAL states
Requirements
- Python 3.x
- Docker or Podman CLI installed on the system
Installation
-
Download the
check_containers.py
script. -
Make the script executable:
chmod +x check_containers.py
-
Place the script in your Nagios plugins directory or any location accessible by Nagios.
Usage
./check_containers.py [-h] [-c CONTAINERS [CONTAINERS ...]] [-s {running,exited,paused,restarting}] [-t THRESHOLDS] [-r RUNNER]
Options
-h, --help
: Show help message and exit-c CONTAINERS [CONTAINERS ...], --containers CONTAINERS [CONTAINERS ...]
: Specific containers to check-s {running,exited,paused,restarting}, --status {running,exited,paused,restarting}
: Container status to check (default: running)-t THRESHOLDS, --thresholds THRESHOLDS
: Thresholds for OK, WARNING, and CRITICAL in format OK:WARN:CRIT (default: 1:0:0)-r RUNNER, --runner RUNNER
: Path to Docker/Podman binary. If not provided, will attempt to find it automatically.
Examples
-
Check all running containers:
./check_containers.py
-
Check specific containers:
./check_containers.py -c container1 container2
-
Check exited containers with custom thresholds:
./check_containers.py -s exited -t 0:1:5
-
Use a custom Docker binary path:
./check_containers.py -r /usr/local/bin/docker
License
Distributed under the MIT License. See LICENSE.md
file for more information.