diff --git a/mail/checkdelivery.sh b/mail/checkdelivery.sh new file mode 100644 index 0000000..2ec9854 --- /dev/null +++ b/mail/checkdelivery.sh @@ -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 \ No newline at end of file