From 1c9d56739c7c79e27e4c5b0d599fbc73cc660737 Mon Sep 17 00:00:00 2001 From: Matthew McKinnon Date: Mon, 6 Jun 2016 16:25:33 +1000 Subject: [PATCH] Added mailQWatch.sh for mailq notifications --- mailQWatch.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 mailQWatch.sh diff --git a/mailQWatch.sh b/mailQWatch.sh new file mode 100644 index 0000000..a5eac20 --- /dev/null +++ b/mailQWatch.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Checks mailQ size + +QUEUELIMIT=0 +HOST=$(/bin/hostname) +QUEUELENGTH=$(/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}') +QUEUECOUNT=$(echo $queuelength | grep "[0-9]") +SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT" +MAILTO="mmckinnon@comprofix.com" + +if [ "$QUEUECOUNT" == "" ]; then + exit; +elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then +#echo $msg | /bin/mail -s "Mail Queue Alert $queuecount ($hostname)" "helpdesk@ambient-it.com.au" + /usr/sbin/postqueue -p | /bin/mail -s "$SUBJECT" "$MAILTO" +fi