Giter Site home page Giter Site logo

check_docker's Introduction

Build Status Code Climate Test Coverage

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 (experimental!), does the running image match that in the remote registry?

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.3 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
curl -o /usr/local/bin/check_swarm https://raw.githubusercontent.com/timdaman/check_docker/master/check_swarm
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
wget -O /usr/local/bin/check_swarm https://raw.githubusercontent.com/timdaman/check_docker/master/check_swarm
chmod a+rx /usr/local/bin/check_docker /usr/local/bin/check_swarm

check_docker Usage

usage: check_docker [-h]
                    [--connection [/<path to>/docker.socket|<ip/host address>:<port>]
                    | --secure-connection [<ip/host address>:<port>]]
                    [--timeout TIMEOUT]
                    [--containers CONTAINERS [CONTAINERS ...]] [--present]
                    [--cpu WARN:CRIT] [--memory WARN:CRIT:UNITS]
                    [--status STATUS] [--health] [--uptime WARN:CRIT]
                    [--version] [--restarts WARN:CRIT]

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.
  --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.
  --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,k,m,g.
  --status STATUS       Desired container status (running, exited, etc).
                        (default: None)
  --health              Check container's health check status
  --uptime WARN:CRIT    Minimum container uptime in seconds. Use when
                        infrequent crashes are tolerated.
  --version             Check if the running images are the same version as
                        those in the registry. Useful for finding stale
                        images. Only works with public registry.
  --restarts WARN:CRIT  Container restart thresholds.

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 ...])

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.
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 ...])

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.

check_docker's People

Contributors

kiangj avatar kristianlyng avatar mattwwarren avatar tatref avatar timdaman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.