From ca16c4bc5641530db67877ab5f6ac1ae2391d8c6 Mon Sep 17 00:00:00 2001 From: Niklas Date: Sat, 17 Jun 2017 20:16:38 +0200 Subject: [PATCH] =?UTF-8?q?'mail/checkdelivery.sh'=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail/checkdelivery.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 mail/checkdelivery.sh 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