1
0
Fork 0
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
Find a file
2024-08-20 14:58:38 +02:00
.gitea/workflows [a] add workflow automation 2024-08-20 14:58:38 +02:00
.gitignore Initial Commit 2024-08-16 13:48:37 +02:00
check_containers.py [a] add workflow automation 2024-08-20 14:58:38 +02:00
LICENSE.md Initial Commit 2024-08-16 13:48:37 +02:00
README.md [c] update readme 2024-08-19 15:18:56 +02:00

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

  1. Download the check_containers.py script.

  2. Make the script executable:

    chmod +x check_containers.py
    
  3. 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

  1. Check all running containers:

    ./check_containers.py
    
  2. Check specific containers:

    ./check_containers.py -c container1 container2
    
  3. Check exited containers with custom thresholds:

    ./check_containers.py -s exited -t 0:1:5
    
  4. 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.