Skip to content

Instantly share code, notes, and snippets.

@agarzon
Last active March 28, 2023 01:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save agarzon/95c357d25091d2d4fb88 to your computer and use it in GitHub Desktop.
Save agarzon/95c357d25091d2d4fb88 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
@rizwanikram-hub
Copy link

[root@localhost /]# /etc/queueCounter.sh
/etc/queueCounter.sh: line 13: [: : integer expression expected

@Deepcuts
Copy link

Double the [[ ]]

if [[ "$QUEUE_SIZE" -gt "$LIMIT" ]]; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment