[modify] change alert method to mail

This commit is contained in:
2023-08-25 21:50:46 +08:00
parent 5efa59be75
commit 8d11aa9ec8
2 changed files with 39 additions and 30 deletions

View File

@ -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"