今天又把原来写的脚本进行了修正处理:
脚本2:
---tomcat被点住的情况
#!/bin/sh
#no back date check program
while true;do
TIME=`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $2}' |awk -F: '{print $2}'`
if [ $TIME -gt 20 ]
then
mplayer /opt/autotest/love.mp3
echo "`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $6}'`, Tomcat has been hitted.">/opt/autotest/test1.txt
mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test1.txt
rm -rf /opt/autotest/test1.txt
fi
sleep 5s
早上9点之前,晚上10点之后,监控程序会发短信给相关人员,同时会对ps_autotest邮箱发邮件。其他时间是播放音乐和发邮件。
2.在tomcat被点住之后,系统会播放音乐和发邮件。
脚本内容如下:
脚本1:
#!/bin/bash
#website test scripts
while true;do
for cycle_temp in `cat /opt/autotest/websit_url_links`
do
temp=1
i=1
character_sign_1=10
character_sign_2=5
while [ ${i} -lt $character_sign_1 ]
do
if lynx -connect_timeout=2 -dump `echo ${cycle_temp}` -accept_all_cookies|grep "true"
then
let "temp=$temp+0"
else
let "temp=$temp+1"
fi
let "i=${i}+1"
echo ${cycle_temp}
sleep 5s
done
if [ ${temp} -gt $character_sign_2 ]
then
dateday=`date +%T`
datehour=`expr substr ${dateday} 1 2`
echo "${cycle_temp} has been down"
echo "${cycle_temp} has been offline,please attend it now!">/opt/autotest/test.txt
mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test.txt
if[${hourtime}<9 && ${hourtime} <20]
then
mplayer /opt/autotest/love.mp3
else
for read_phone in `cat /opt/autotest/PS_MobilePone.txt`
do
echo -e "`echo $cycle_temp` 网站宕机,请及时处理!" |gnokii -sendsms `echo $read_phone`
done
fi
rm -rf /opt/autotest/test.txt
fi
done
sleep 5m
done
脚本内容如下:
脚本1:
#!/bin/bash
#website test scripts
while true;do
for cycle_temp in `cat /opt/autotest/websit_url_links`
do
temp=1
i=1
character_sign_1=10
character_sign_2=5
while [ ${i} -lt $character_sign_1 ]
do
if lynx -connect_timeout=2 -dump `echo ${cycle_temp}` -accept_all_cookies|grep "true"
then
let "temp=$temp+0"
else
let "temp=$temp+1"
fi
let "i=${i}+1"
echo ${cycle_temp}
sleep 5s
done
if [ ${temp} -gt $character_sign_2 ]
then
dateday=`date +%T`
datehour=`expr substr ${dateday} 1 2`
echo "${cycle_temp} has been down"
echo "${cycle_temp} has been offline,please attend it now!">/opt/autotest/test.txt
mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test.txt
if[${hourtime}<9 && ${hourtime} <20]
then
mplayer /opt/autotest/love.mp3
else
for read_phone in `cat /opt/autotest/PS_MobilePone.txt`
do
echo -e "`echo $cycle_temp` 网站宕机,请及时处理!" |gnokii -sendsms `echo $read_phone`
done
fi
rm -rf /opt/autotest/test.txt
fi
done
sleep 5m
done
脚本2:
---tomcat被点住的情况
#!/bin/sh
#no back date check program
while true;do
TIME=`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $2}' |awk -F: '{print $2}'`
if [ $TIME -gt 20 ]
then
mplayer /opt/autotest/love.mp3
echo "`ps -e -o pid -o etime -o args|grep http |grep lynx |awk '{print $6}'`, Tomcat has been hitted.">/opt/autotest/test1.txt
mail -s "website down mail" ps_autotest@****.com.cn</opt/autotest/test1.txt
rm -rf /opt/autotest/test1.txt
fi
sleep 5s
done
本文转自guoli0813 51CTO博客,原文链接:http://blog.51cto.com/guoli0813/285463,如需转载请自行联系原作者