Skip to content

Instantly share code, notes, and snippets.

@akhiljalagam
Forked from agarzon/queueCounter.sh
Created November 26, 2020 03:16
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 akhiljalagam/151a71c6d668b78fd702b9b6dd212b29 to your computer and use it in GitHub Desktop.
Save akhiljalagam/151a71c6d668b78fd702b9b6dd212b29 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