serverscripts/mailQWatch

22 lines
564 B
Plaintext
Raw Normal View History

#!/bin/bash
# Script Name: mailQWatch
# Author: Matt McKinnon
# Date: 7th June 2016
# Description:
# This script will email a report mailq on postfix is high.
2016-06-07 20:51:02 +10:00
QUEUELIMIT=75
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
MAILTO="support@comprofix.com"
HOST=$(/bin/hostname)
POSTQUEUE=$(which postqueue)
QUEUELENGTH=$($POSTQUEUE -p | tail -n1 | awk '{print $5}')
QUEUECOUNT=$(echo $QUEUELENGTH | grep "[0-9]")
2016-06-06 16:28:56 +10:00
if [ "$QUEUECOUNT" == "" ]; then
exit;
elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then
2016-06-07 20:51:02 +10:00
$POSTQUEUE -p | /bin/mail -s "$SUBJECT" "$MAILTO"
2016-06-06 16:28:56 +10:00
fi