[modify] change alert method to mail
This commit is contained in:
@ -1,12 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
> /tmp/docker_alarm.log
|
||||
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"
|
||||
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
||||
fi
|
||||
done < /opt/logs/docker_status.log
|
||||
|
||||
alarm=`cat /tmp/docker_alarm.log`
|
||||
python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
||||
|
||||
|
Reference in New Issue
Block a user