Skip to content
Snippets Groups Projects
Select Git revision
  • 23f3327be9995a8d1ae1a938491e541a5810c9c3
  • master default protected
  • simple-task/7248-eol-check-add-node-22
  • 6877_check_iml_deployment
4 results

check_docker_info.md

Blame
  • CHECK_DOCKER_INFO

    Introduction

    check_docker_info_ shows the docker version and count of containers. You get the count of containers by state running, paused or stopped. This check sends performance data.

    Requirements

    • docker Docker must be installed
    • sudo permissions on docker command
    icingaclient ALL=(ALL) NOPASSWD:SETENV: /usr/bin/docker

    Includes

    Additional needed files in the current folder that this check can run:

    • inc_dockerfunctions.sh
    • inc_pluginfunctions

    Rootless docker

    It works with docker setups as root and can handle rootless docker instances.

    To bring it up and running with an unpriviledged icinga user it must be able to access docker. Copy the docker binary eg. from /home/dockeruser/bin/docker to /usr/bin/. Then use the parameter -p /usr/bin.

    If DOCKER_HOST is not set then the docker socket is detected from a running docker instance and will be fetched from the process list.

    Syntax

    ______________________________________________________________________
    
    CHECK_DOCKER_INFO
    v1.3
    
    (c) Institute for Medical Education - University of Bern
    Licence: GNU GPL 3
    
    https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_docker_info.html
    ______________________________________________________________________
    
    Show docker version and count of containers total and by its status.
    
    It returns 
      CRITICAL if a created container is not running.
      OK if no container was created yet or all conmtainers are running
      UNKNOWM if
        - docker or jq were not found
        - docker data were not fetched
        - docker cannot be connected
    
    This check provides performance data.
    
    USAGE:
      check_docker_info [OPTIONS]
    
    OPTIONS:
      -h, --help        this help
      -c, --containers  Flag: Show containers (slow)
      -e, --errors      Flag: Show containers on error only (slow)
      -d, --debug       Debug; Flag: show all docker system infos
      -p, --path        Custom directory for docker binary
    
    EXAMPLES:
      check_docker_info
        Show Status of all containers
    
      check_docker_info -c
        Show Status of all containers and a list of container names with its
        status. Warning: this feature uses docker ps --all and can be slow.
    
      check_docker_info -e
        Show Status of all containers. If not all containers are running you
        get a list of container names with its status.
    
      check_docker_info -p /usr/bin
        Show Status of all containers. The docker binary will be searched in
        given path first - then in all other dirs of $PATH
    
      check_docker_info -d
        Show Status of all containers and json with all docker system infos.
    

    Parameters

    None.

    Examples

    $ ./check_docker_info returns

    OK: Docker 20.10.14 (Community Engine, rootless) .. containers: 2 running: 2 paused: 0 stopped: 0 .. images: 5
    All containers are running
     |containers-running=2;;;0;2 containers-paused=0;;;0;2 containers-stopped=0;;;0;2 images=33;;

    Troubleshooting

    Missing environment

    sudo: sorry, you are not allowed to preserve the environment
    UNKNOWN: No data. Unable to fetch Docker information.

    Solution: you did not set SETENV in the sudoers config file

    icingaclient ALL=(ALL) NOPASSWD:SETENV: /usr/bin/docker

    Docker not found

    If you get an error message that docker was not found then it is not reachable in ofe of the directories of $PATH. This can happen especialy in rootless docker instances.

    Solution: Use the parameter -p /usr/bin to define a target. Copy the docker binary there.