Updated formatting mailQWatch.sh

This commit is contained in:
Matthew McKinnon 2016-06-07 20:51:02 +10:00
parent 2cda37ccc8
commit 601e0bb5db

View File

@ -4,18 +4,18 @@
# Date: 7th June 2016 # Date: 7th June 2016
# Description: # Description:
# This script will email a report mailq on postfix is high. # This script will email a report mailq on postfix is high.
QUEUELIMIT=75 QUEUELIMIT=75
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT" SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
MAILTO="support@comprofix.com" MAILTO="support@comprofix.com"
HOST=$(/bin/hostname) HOST=$(/bin/hostname)
POSTQUEUE=$(which postqueue) POSTQUEUE=$(which postqueue)
QUEUELENGTH=$($POSTQUEUE -p | tail -n1 | awk '{print $5}') QUEUELENGTH=$($POSTQUEUE -p | tail -n1 | awk '{print $5}')
QUEUECOUNT=$(echo $QUEUELENGTH | grep "[0-9]") QUEUECOUNT=$(echo $QUEUELENGTH | grep "[0-9]")
if [ "$QUEUECOUNT" == "" ]; then if [ "$QUEUECOUNT" == "" ]; then
exit; exit;
elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then
$POSTQUEUE -p | /bin/mail -s "$SUBJECT" "$MAILTO" $POSTQUEUE -p | /bin/mail -s "$SUBJECT" "$MAILTO"
fi fi