#!/bin/bash

QDIR=/var/spool/sympa/queue
W=15
C=30

if [ ! -d $QDIR ]
then
    echo "The queue directory does not exists !"
    exit 3
fi

NB=`find $QDIR -maxdepth 1 -type f 2> /dev/null|wc -l`

if [ $NB -gt $C ]
then
    STATE=CRITICAL
    CODE=2
elif [ $NB -gt $W ]
then
    STATE=WARNING
    CODE=1
else
    STATE=OK
    CODE=0
fi

echo "$STATE : $NB message(s) in the queue."
exit $CODE

