#!/bin/sh
############################################################
# Check process mailqueue if over limit send mail to Tier1 #
# Check every 15 Mins #
# Version 2.1 By golfreeze #
############################################################
export PATH=/usr/bin:/sbin:/usr/sbin:/bin
DATE=`/bin/date`
CHECKMQQ=`/usr/local/sbin/postqueue -p | grep "Kbytes in" | awk -F 'Kbytes in' '{print $2}' | sed s/Requests.//g`
CHECKLOAD=`uptime | awk -F 'load averages:' '{print $2}'`
#echo "Mailqueue in system Now = $CHECKMQQ"
#convert string to integer"
CHECKMQ=`/bin/expr $CHECKMQQ`
#Input limitover value
limitover=300
#######
# -gt = more than
# -lt = less than
if [ "$CHECKMQ" -gt "$limitover" ]
then
echo "Dear Tier1" > /home/golf/___script___/sms_send.txt
echo "Today = $DATE " >> /home/golf/___script___/sms_send.txt
echo "Now Mailqueue in SMTP00 is $CHECKMQ more than $limitover " >> /home/golf/___script___/sms_send.txt
echo "Now Load in server is $CHECKLOAD " >> /home/golf/___script___/sms_send.txt
echo "Urgent urgent!!!! >> /home/golf/___script___/sms_send.txt
echo "Subject: Urgent!!! Mailqueue in SMTP00 Higher" | cat - /home/golf/___script___/sms_send.txt | sendmail -F "
bot-checkmq@xxxx.th" -f
bot-checkmq@xxx.th dc-ops@xxxo.th sleep 5
exit 1
else
echo "Now Mailqueue is $CHECKMQ less than $limitover"
fi