Skip to main content

Nagios/NRPE compatible plugins for checking Docker based services

Project description

Build Status Code Climate Test Coverage Downloads

check_docker

Nagios/NRPE compatible plugins for checking docker based services. Currently there are two nagios checks

  • check_docker which checks docker container health

  • check_swarm which checks health of swarm nodes and services

With check_docker can use it to check and alert on

  • memory consumption in absolute units (bytes, kb, mb, gb) and as a percentage (0-100%) of the container limit.

  • CPU usages as a percentage (0-100%) of container limit.

  • automatic restarts performed by the docker daemon

  • container status, i.e. is it running?

  • container health checks are passing?

  • uptime, i.e. is it able to stay running for a long enough time?

  • the presence of a container or containers matching specified names

  • image version, does the running image match that in the remote registry?

  • image age, when was the image built the last time?

With check_swarm you can alert

  • if a node is not joined to a docker swarm

  • if a service is running in a swarm

These checks can communicate with a local docker daemon socket file (default) or with local or remote docker daemons using secure and non-secure TCP connections.

These plugins require python 3. It is tested on 3.5 and greater but may work on older versions of 3.

Installation

With pip

pip3 install check_docker
--or--
pip install check_docker

With curl

curl -o /usr/local/bin/check_docker https://raw.githubusercontent.com/timdaman/check_docker/master/check_docker/check_docker.py
curl -o /usr/local/bin/check_swarm https://raw.githubusercontent.com/timdaman/check_docker/master/check_docker/check_swarm.py
chmod a+rx /usr/local/bin/check_docker /usr/local/bin/check_swarm

With wget

wget -O /usr/local/bin/check_docker https://raw.githubusercontent.com/timdaman/check_docker/master/check_docker/check_docker.py
wget -O /usr/local/bin/check_swarm https://raw.githubusercontent.com/timdaman/check_docker/master/check_docker/check_swarm.py
chmod a+rx /usr/local/bin/check_docker /usr/local/bin/check_swarm

check_docker Usage

usage: check_docker.py [-h]
                       [--connection [/<path to>/docker.socket|<ip/host address>:<port>]
                       | --secure-connection [<ip/host address>:<port>]]
                       [--binary_units | --decimal_units] [--timeout TIMEOUT]
                       [--containers CONTAINERS [CONTAINERS ...]] [--present]
                       [--threads THREADS] [--cpu WARN:CRIT]
                       [--memory WARN:CRIT:UNITS] [--status STATUS] [--health]
                       [--uptime WARN:CRIT] [--image-age WARN:CRIT] [--version]
                       [--insecure-registries INSECURE_REGISTRIES [INSECURE_REGISTRIES ...]]
                       [--restarts WARN:CRIT] [-V]

Check docker containers.

optional arguments:
  -h, --help            show this help message and exit
  --connection [/<path to>/docker.socket|<ip/host address>:<port>]
                        Where to find docker daemon socket. (default:
                        /var/run/docker.sock)
  --secure-connection [<ip/host address>:<port>]
                        Where to find TLS protected docker daemon socket.
  --binary_units        Use a base of 1024 when doing calculations of KB, MB,
                        GB, & TB (This is default)
  --decimal_units       Use a base of 1000 when doing calculations of KB, MB,
                        GB, & TB
  --timeout TIMEOUT     Connection timeout in seconds. (default: 10.0)
  --containers CONTAINERS [CONTAINERS ...]
                        One or more RegEx that match the names of the
                        container(s) to check. If omitted all containers are
                        checked. (default: ['all'])
  --present             Modifies --containers so that each RegEx must match at
                        least one container.
  --threads THREADS     This + 1 is the maximum number of concurent
                        threads/network connections. (default: 10)
  --cpu WARN:CRIT       Check cpu usage percentage taking into account any
                        limits. Valid values are 0 - 100.
  --memory WARN:CRIT:UNITS
                        Check memory usage taking into account any limits.
                        Valid values for units are %,B,KB,MB,GB.
  --status STATUS       Desired container status (running, exited, etc).
  --health              Check container's health check status
  --uptime WARN:CRIT    Minimum container uptime in seconds. Use when
                        infrequent crashes are tolerated.
  --image-age WARN:CRIT Maximum image age in days.
  --version             Check if the running images are the same version as
                        those in the registry. Useful for finding stale
                        images. Does not support login.
  --insecure-registries INSECURE_REGISTRIES [INSECURE_REGISTRIES ...]
                        List of registries to connect to with http(no TLS).
                        Useful when using "--version" with images from
                        insecure registries.
  --restarts WARN:CRIT  Container restart thresholds.
  --no-ok               Make output terse suppressing OK messages. If all
                        checks are OK return a single OK.
  --no-performance      Suppress performance data. Reduces output when
                        performance data is not being used.
  -V                    show program's version number and exit

check_swarm Usage

usage: check_swarm [-h]
                   [--connection [/<path to>/docker.socket|<ip/host address>:<port>]
                   | --secure-connection [<ip/host address>:<port>]]
                   [--timeout TIMEOUT]
                   (--swarm | --service SERVICE [SERVICE ...]) [-V]

Check docker swarm.

optional arguments:
  -h, --help            show this help message and exit
  --connection [/<path to>/docker.socket|<ip/host address>:<port>]
                        Where to find docker daemon socket. (default:
                        /var/run/docker.sock)
  --secure-connection [<ip/host address>:<port>]
                        Where to find TLS protected docker daemon socket.
  --timeout TIMEOUT     Connection timeout in seconds. (default: 10.0)
  --swarm               Check swarm status
  --service SERVICE [SERVICE ...]
                        One or more RegEx that match the names of the
                        services(s) to check.
  -V                    show program's version number and exit

Gotchas

  • When using check_docker with older versions of docker (I have seen 1.4 and 1.5) –status only supports ‘running’, ‘restarting’, and ‘paused’.

  • When using check_docker, if no container is specified, all containers are checked. Some containers may return critcal status if the selected check(s) require a running container.

  • When using check_docker, –present cannot be used without –containers to indicate what to check the presence of.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

check_docker-2.2.1.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

check_docker-2.2.1-py2.py3-none-any.whl (29.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file check_docker-2.2.1.tar.gz.

File metadata

  • Download URL: check_docker-2.2.1.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/2.7.16 Darwin/19.2.0

File hashes

Hashes for check_docker-2.2.1.tar.gz
Algorithm Hash digest
SHA256 b852f991478e7eb486a01050b9444330f66553a32e0117c13f9195a2c595bf38
MD5 0db9c66425f62f46992ec913826a3565
BLAKE2b-256 a265469e4e5d58eccd8ef0e3d57df3b6eaf1d3d98446e829042bb15e4412f052

See more details on using hashes here.

File details

Details for the file check_docker-2.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: check_docker-2.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/2.7.16 Darwin/19.2.0

File hashes

Hashes for check_docker-2.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9418755e221b47845c61fcff3cb517838ea9b4ec65f6ae8651113463cdeedfd7
MD5 bfdc1a31e732854884f96de13288fe53
BLAKE2b-256 aece9cde620fe2e8d5b13a38a9b2ee274ddeff472f022d85206762fd2c1fb082

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page