Monitor Docker Container Status

A local check_mk check to create a new local check for each Docker container running on the server and simply whether it is ‘Up’ or not. – WIP
nano /usr/lib/check_mk_agent/local/monitor-docker

#!/bin/bash
# Set environment variables (New line is the only separator)
IFS=$’\n’
set -f
for i in $(docker ps -a | tail -n +2)
do
n=$(echo $i | awk {‘print $1’})
nn=$(echo $i | awk {‘print $2’})
if [[ $i == *”Up”* ]]; then
s=0
st=”Docker $n ($nn) is Up”
else
s=2
st=”Docker $s ($nn) is not Up”
fi
echo “$s docker_$n varname=2;crit $st” 
done 

chmod +x /usr/lib/check_mk_agent/local/monitor-docker

Any comments or questions? Get in touch here or Email me at [email protected]