#!/bin/bash docker ps -a --format "table {{.Names}}\t{{.Status}}" > /opt/logs/docker_status.log while read line; do echo $line | grep -q 'Exited' if [[ $? -eq 0 ]]; then name=`echo $line | awk '{print $1}'` alarm="Docker Alarm - $name:\nContainer $name has been off line, please check ASAP." bash /opt/scripts/alert/sendmsg.sh "$alarm" fi done < /opt/logs/docker_status.log