Skip to content

Nagios Plugin check_docker

Davide Madrisan edited this page Aug 8, 2020 · 3 revisions

check_docker - returns some runtime metrics exposed by Docker

[/etc/nrpe.d/check_docker]
command[check_docker_images]=/usr/lib/nagios/plugins/check_docker --image nxing -c 5:
command[check_docker_memory]=/usr/lib/nagios/plugins/check_docker --memory -w 512 -c 640 5
Usage note
This plugin returns some runtime metrics exposed by Docker
Copyright (C) 2018 Davide Madrisan <davide.madrisan@gmail.com>
Usage:
  check_docker [--image IMAGE] [-w COUNTER] [-c COUNTER]
  check_docker --memory [-b,-k,-m,-g] [-w COUNTER] [-c COUNTER] [delay]
Options:
  -i, --image IMAGE   limit the investigation only to the containers running IMAGE
  -M, --memory    return the runtime memory metrics (alpha!)
  -b,-k,-m,-g     show output in bytes, KB (the default), MB, or GB
  -w, --warning COUNTER    warning threshold
  -c, --critical COUNTER   critical threshold
  -v, --verbose   show details for command-line debugging (Nagios may truncate output)
  -h, --help      display this help and exit
  -V, --version   output version information and exit
  delay is the delay between updates in seconds (default: 1sec)
Examples:
  check_docker -w 100 -c 120
  check_docker --image nginx -c 5:
  check_docker --memory -m -w 512 -c 640 5
Examples of output
Docker images

When no image is set at command line, check_docker displays the number of all the running instances, grouped by image name, followed by the total number of running containers:

docker OK: 4 running container(s) | containers_redis=1 containers_nginx=3 containers_total=4

otherwise only the number of containers running the given image are displayed:

docker OK: 3 running container(s) of type "nginx" | containers_nginx=3
Docker Memory
docker memory OK: 15 MB memory used | cache=11MB rss=3MB swap=0MB unevictable=0MB pgfault=0 pgmajfault=0 pgpgin=0 pgpgout=0
Performance data
Docker images

When no image is set at command line:

containers_${image1} ... containers_${imageN} containers_total

otherwise:

containers_${image}

Docker memory
  • cache: The amount of memory used by the processes of this control group that can be associated precisely with a block on a block device. It also accounts for the memory used by tmpfs mounts
  • rss: The amount of memory that doesn’t correspond to anything on disk: stacks, heaps, and anonymous memory maps
  • swap: The amount of swap currently used by the processes in this cgroup
  • unevictable: The amount of memory that cannot be reclaimed
  • pgfault: The number of times that a process of the cgroup triggered a “page fault”
  • pgmajfault: The number of times that a process of the cgroup triggered a “major fault”
  • pgpgin: Number of pages paged into memory
  • pgpgout: Number of pages paged out of memory