#!/bin/bash
# Author:royoy
# Desc:check status of the clear jobs
clear_id=("m_dataclear_php_3" "m_dataclear_php_4" "m_dataclear_php_5" "m_dataclear_php_6" "m_dataclear_php_7" "m_dataclear_php_8" "m_dataclear_php_9" "m_dataclear_php_10" "m_dataclear_php_11")
date_id=("04:00" "03:10" "03:30" "05:30" "04:40" "04:42" "04:45" "04:30" "04:35")
date_f=`date +%Y-%m-%d`
Path="/data/app_cli_log/highadmin/"
file="/tmp/clear.txt"
name_ok="OK_105_scplt_CHECK_CLEAR_TIME"
name_error="ERROR_105_scplt_CHECK_CLEAR_TIME"
mail_ok()
{
mailserver="128.199.206.77"
mailport="25"
(
echo "helo sg-zbx77.com"
sleep 1
echo "MAIL From:<replymonitor@sg-zbx77.com>"
sleep 1
echo "RCPT To:<admin@weststarinc.co>"
sleep 1
echo "DATA"
sleep 1
echo "From: replymonitor@sg-zbx77.com"
echo "Subject: $name_ok"
echo "Content-type:multipart/mixed;Boundary="a""
echo "Content-Type: text/plain;charset="UTF-8" Content-Transfer-Encoding: base64"
echo "Content-Disposition:Attachment; filename="$name_ok""
echo "$name_ok"
echo "."
sleep 1
echo "quit"
) | telnet $mailserver $mailport
}
mail_error()
{
mailserver="128.199.206.7"
mailport="25"
(
echo "helo sg-zbx77.com"
sleep 1
echo "MAIL From:<replymonitor@sg-zbx77.com>"
sleep 1
echo "RCPT To:<admin@weststarinc.co>"
sleep 1
echo "DATA"
sleep 1
echo "From: replymonitor@sg-zbx77.com"
echo "Subject: $name_error"
echo "Content-type:multipart/mixed;Boundary="a""
echo "Content-Type: text/plain;charset="UTF-8" Content-Transfer-Encoding: base64"
echo "Content-Disposition:Attachment; filename="$name_error""
echo "$result"
echo "."
sleep 1
echo "quit"
) | telnet $mailserver $mailport
}
for ((i=0;i<=8;i++));do
echo "########################################################" >>$file
echo "start check ${clear_id[$i]} clear time...">>$file
echo "`cat $Path${clear_id[$i]} | egrep "Clear $date_f ${date_id[$i]}|( 24 )" | grep "$date_f"`">>$file
done
result=`cat $file`
num=`cat $file | grep "had Clear" | wc -l`
if [ $num == 10 ];then
mail_ok
else
mail_error
fi
rm -f $file