serverscripts/mailQWatch.sh
2016-06-06 22:41:18 +10:00

17 lines
428 B
Bash
Executable File

#!/bin/bash
QUEUELIMIT=75
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
MAILTO="mmckinnon@comprofix.com"
HOST=$(/bin/hostname)
POSTQUEUE=$(which postqueue)
QUEUELENGTH=$($POSTQUEUE -p | tail -n1 | awk '{print $5}')
QUEUECOUNT=$(echo $QUEUELENGTH | grep "[0-9]")
if [ "$QUEUECOUNT" == "" ]; then
exit;
elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then
$POSTQUEUE -p | /bin/mail -s "$SUBJECT" "$MAILTO"
fi