Skip to content

Instantly share code, notes, and snippets.

@heartshare
Forked from agarzon/queueCounter.sh
Created January 28, 2019 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heartshare/7bdeebfab74ed436e72c163aadbb3004 to your computer and use it in GitHub Desktop.
Save heartshare/7bdeebfab74ed436e72c163aadbb3004 to your computer and use it in GitHub Desktop.
alert based in mail queue size for postfix and plesk
#!/bin/sh
MAIL_BIN=`command -v mail`
QUEUE_SIZE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'`
QUEUE_SUMMARY=`/usr/sbin/qshape -s deferred | head`
MAILTO="xxx@gmail.com"
LIMIT=100
function send_notification_mail() {
echo $QUEUE_SUMMARY | $MAIL_BIN -s "WARNING: mail queue critical on $HOSTNAME" $MAILTO
}
if [ "$QUEUE_SIZE" -gt "$LIMIT" ]; then
send_notification_mail
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment