'mail/checkdelivery.sh' hinzufügen

This commit is contained in:
Niklas 2017-06-17 20:16:38 +02:00
parent 85ebdc29e1
commit ca16c4bc56
1 changed files with 12 additions and 0 deletions

12
mail/checkdelivery.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
MAX=100
COUNTER=$(grep 'non-delivery notification' /var/log/mail.log | wc -l)
if [ "$COUNTER" -gt "$MAX" ]; then
OUTPUT=$(grep -B 3 -A 2 'non-delivery notification' /var/log/mail.log | head -n 150 | tail -n 25)
TEXT="!!WARNING!!\ngrep resulted in more than $MAX 'non-delivery notifications'.\n\n$OUTPUT"
echo "delivery notifications are larger than $MAX... Sending Mail...";
printf "$TEXT" | mail -s "Mail Administration" -a from:mc8051@schuetrumpf.net niklas@schuetrumpf.net
# printf "$TEXT"
fi