#!/bin/sh
for QUEUE in postfix postfix-mailin postfix-mailout postfix-bmailout ; do
   QUEUE_LEN=$( postqueue -c /etc/$QUEUE/ -p | egrep -c "^[A-F0-9]+ " )
   ALERT=0
   if [ "$QUEUE" = "postfix-bmailout" ]; then
     if [ "$QUEUE_LEN" -gt "100" ]; then
       ALERT=1
     fi
   elif [ "$QUEUE_LEN" -gt "100" ]; then
     ALERT=1
   fi
   if [ "$ALERT" -eq "1" ]; then
      postqueue -c /etc/$QUEUE/ -p | head -n100 | mail -s "Monit Alert $( hostname ) Mail-Queue $QUEUE enthaelt $QUEUE_LEN Nachrichten." alarm@hostsharing.net
   fi
done
exit 0;
