Mail queue notifier script for qmail
This is a shell script that I wrote that checks the Qmail mail queue size and if it is above a given number it will send an email alert. With this handy script you can be notified of when your mail queue is filling up before you run into problems. This can easily be added to a cron job. You may have to change some of the script to make work on your system.
Download checkqueuesize.sh
This is a shell script that I wrote that checks the Qmail mail queue size and if it is above a given number it will send an email alert. With this handy script you can be notified of when your mail queue is filling up before you run into problems. This can easily be added to a cron job. You may have to change some of the script to make work on your system.
file: checkqueuesize.sh#!/bin/sh ######################################################### # # # Script to check the number of messages in a qmail # # queue and sends an email alert when it is over the # # given amount. # # # # Author: Neil Bittner # # Version: 0.1 # # # ######################################################### EMAIL=youremail@domain.com validNumber() { case "$1" in *[!0-9]*) return 1;; # string contains invalid chars. *) return 0;; # only digits from 0-9 esac } if [ $# -eq 1 ]; then if validNumber "$1" ; then msgCap=$1 largeQueueMessage="The mail queue on `hostname -f` has over $msgCap messages. You should try cleaning the bounce messages out of the queue." messageSub="`hostname -f` has over $msgCap messages in the queue" messageTo="$EMAIL" messageFrom="root@`hostname -f`" if [ -f /var/qmail/bin/qmail-qstat ]; then MESSAGES="`/var/qmail/bin/qmail-qstat | head -n 1 | awk '{ print substr($0,20,length($0))}'`" if [ $MESSAGES -gt $msgCap ]; then echo "The queue needs to be cleaned!" echo "$largeQueueMessage" | mail -s "$messageSub" "$messageTo" -- -f "$messageFrom" fi fi else echo "Invalid number \"$1\"" echo "Usage:" echo " $0 MESSAGES_REQUIRED" fi else echo "Usage:" echo " $0 MESSAGES_REQUIRED" fi
Download checkqueuesize.sh
