LogDay=`date +'%Y%m%d'`
LogFileName=/wle/forest_hou/log/monitor_weblogic.log.$LogDay
SQL_FN=/wle/forest_hou/bin/insert_sms.sql
# inteval time
M_INTERVAL=180
StartTime=`date +'%Y-%m-%d %H:%M:%S'`
echo "====================Monitoring time is :${StartTime}===================="'/n' >> $LogFileName
times_send=1
times_this=1
while [ true ]
do
LogDay=`date +'%Y%m%d'`
LogDay1=`date +'%Y%m%d-%H:%M:%S'`
LogFileName=/wle/forest_hou/log/monitor_weblogic1009.log.$LogDay
CFG_FILE=`cat /wle/forest_hou/bin/monitor_1009.txt|awk '{print $1}'`
sendtext="${LogDay1}WEB Machine is no response"
H=""
for F in $CFG_FILE
do
m=`/usr/java14/bin/java -cp /bea/weblogic81/server/lib/weblogic.jar weblogic.Admin -url t3://$F -username weblogic -password gxn
gweb123 PING`
k=`echo $m|grep RTT|wc -l|tr -d " "`
StartTime=`date +'%Y-%m-%d %H:%M:%S'`
if [ "$k" -ne 1 ]
then
times_this=`expr $times_this + 1`
sendtext="${sendtext}/$F"
echo $F
Server=`cat /wle/houfl/bin/monitor_1009.txt | grep $F | awk '{print $2}'`
echo "==${StartTime}==$m==" >> $LogFileName
echo "==${StartTime}==kill server ==$Server==" >> $LogFileName
ps -ef|grep $Server |grep wle|grep weblogic |awk '{print ($2)}'|xargs -i kill -9 {}
sleep 3
mv /wle/NGBOSS/log/$Server.out /wle/NGBOSS/log/$Server.$LogDay.out
cd /wle/NGBOSS/user_projects/domains/mydomain
echo "==${StartTime}==reboot==$Server==" >> $LogFileName
nohup ./startManagedWebLogic.sh $Server > /wle/NGBOSS/log/$Server.out 2>&1 &
else
k=`echo $m|grep RTT|awk -F~ '{print $2}'|awk -Fm '{print $1}'`
H="$H:$k"
fi
done
if [ "$times_this" -eq 1 ]
then
echo "=${StartTime}==WEB Machnie weblogic'service is normal==$H==" >> $LogFileName
times_send=1
M_INTERVAL=180
else
times_send=`expr $times_send + 1`
p=`date +%H`
if [ $p -gt 8 ]
then
if [ ${times_send} -le 7 ]
then
echo "发送短信内容 省略。。。。。。。。。。"
rm -f $SQL_FN >> $LogFileName
else
echo "==${StartTime}==sms don't sent:==${sendtext}==" >> $LogFileName
fi
else
echo "==${StartTime}==Non-working don't send sms:==${sendtext}==" >> $LogFileName
fi
if [ $times_send -gt 30 ]
then
times_send=1
fi
M_INTERVAL=40
fi
times_this=1
sleep $M_INTERVAL
done