Sendmail Queue lenghts

Derek Winkler dwinkler at ALGORITHMICS.COM
Mon Nov 14 14:24:47 GMT 2005


Hi,

        Anyone here has scripts for testing queue lengths
(incoming/outgoing)
with sendmail?

MRTG has the ability to send alerts itself, look for Thresh config
parameters, don't know if this would work with mailscanner-mrtg.

Here's my Big Brother script, nothing fancy but it works...

#!/bin/sh
BBPROG=mailq.sh; export BBPROG
TEST="mailq"
BBHOME=/opt/bb ; export BBHOME

if test "$BBHOME" = ""
then
        echo "BBHOME is not set... exiting"
        exit 1
fi

if test ! "$BBTMP"                      # GET DEFINITIONS IF NEEDED
then
         # echo "*** LOADING BBDEF ***"
        . $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

# SELECT SOME LEVELS... GREEN IS THE DEFAULT...

WARN="100"      # GO YELLOW AT THIS LEVEL
PANIC="250"     # GO RED AND PAGE AT THIS LEVEL

# GETTING NUMBER OF QUEUE FILES
LEVEL_IN=`find /var/spool/mqueue.in -name "qf*" -type f | wc -l 2>
/dev/null`
LEVEL_OUT=`find /var/spool/mqueue -name "qf*" | wc -l 2> /dev/null`
LEVEL_OUT2=`find /var/spool/mqueue.spam -name "qf*" | wc -l 2> /dev/null`
LEVEL_OUT3=`find /var/spool/mqueue.highspam -name "qf*" | wc -l 2>
/dev/null`

#
# DETERMINE RED/YELLOW/GREEN
#
if test "$LEVEL_IN" -ge "$PANIC" -o "$LEVEL_OUT" -ge "$PANIC"
then
        COLOR="red"
elif test "$LEVEL_IN" -ge "$WARN" -o "$LEVEL_OUT" -ge "$WARN"
then
        COLOR="yellow"
else
        COLOR="green"
fi

MACHINE=`hostname`

#
# THE FIRST LINE IS STATUS INFORMATION... STRUCTURE IMPORANT!
# THE REST IS FREE-FORM - WHATEVER YOU'D LIKE TO SEND...
#
LINE="status $MACHINE.$TEST $COLOR `date`
The size of the incoming mail queue has reached:
$LEVEL_IN

The size of the outgoing mail queue has reached:
$LEVEL_OUT

The size of the spam outgoing queue has reached:
$LEVEL_OUT2

The size of the high spam outgoing queue has reached:
$LEVEL_OUT3"

# NOW USE THE BB COMMAND TO SEND THE DATA ACROSS
$BB $BBDISP "$LINE"                     # SEND IT TO BBDISPLAY



------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/)
and the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list