全部博文(89)
分类: LINUX
2009-08-03 09:20:08
#################################
#
# Tomcat 检测重启 短信报警
#
# debian5.1_lenny_i386_x32
# apache-tomcat-6.0.20
# jdk-6u10-linux-i586
# fetion_linux_20080402
# fetion_library32
#
#################################
######################
#
# 安装飞信lib库
#
######################
wget
# 解压缩后为四个文件
libACE.so.5.4.7
libACE_SSL.so.5.4.7
libcrypto.so.0.9.8
libssl.so.0.9.8
cp libACE.so.5.4.7 libACE_SSL.so.5.4.7 libcrypto.so.0.9.8 libssl.so.0.9.8 /lib /usr/lib
cp libACE.so.5.4.7 libACE_SSL.so.5.4.7 libcrypto.so.0.9.8 libssl.so.0.9.8 /usr/lib
######################
#
# 安装飞信机器人
#
######################
wget
tar xvfz fetion_linux_20080402.tar.gz
cp sms /usr/bin
######################
#
# Nagios飞信测试
#
######################
sms -f 136933XXXXX -p password -t 136833XXXXX -m hello,this is test
# 也可以要发的消息在一个文本文件里,如 message.txt
sms -f 136933XXXXX -p password -t 136833XXXXX,136733XXXXX -i message.txt
# 如果不在好友列表里,发送是不成功的。如果你想让程序邀请他们加入,那么就用 -a 参数
sms -f 136933XXXXX -p password -t 136833XXXXX,136733XXXXX -m 你好,飞信 -a UBUNTU
########################
#
# Check_Tomcat.sh#
#
########################
#!/bin/bash
# Check_Tomcat.sh 1.0 2009.08.02 Mr.hu
# if tomcat down. startup now. a note of the log. and SMS Alarm.
tomPatch=/usr/local/tomcat6020
tomreblogPatch=$tomPatch/logs/tomreboot.log
ndate="date +%Y-%m-%d---%T"
tomsms=/root/tomsms.txt
if netstat -tnl |grep "8080" >> /dev/null
then
:
else
$ndate >> $tomreblogPatch
echo "____________________________________" >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== tomcat is down , startup now... ===" >> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
$tomPatch/bin/startup.sh >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== catalina.out of The last 30 lines" ===>> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
sleep 10
tail -n 30 $tomPatch/logs/catalina.out>> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
sms -f xxxxxxxxxxx -p ********* -t xxxxxxxxxx -i $tomsms >> $tomreblogPatch
fi
#################################
#
# 通过 sms.api.bz 在线发短信
#
# 脚本如下
#
#################################
#!/bin/bash
# tomcat_reboot.sh 1.0 2009.08.02 Mr.hu
# if tomcat down. startup now. a note of the log. and SMS Alarm.
tomPatch=/usr/local/tomcat6020
tomreblogPatch=$tomPatch/logs/tomreboot.log
ndate="date +%Y-%m-%d---%T"
if netstat -tnl |grep "8080" >> /dev/null
then
:
else
$ndate >> $tomreblogPatch
echo "____________________________________" >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== tomcat is down , startup now... ===" >> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
$tomPatch/bin/startup.sh >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== catalina.out of The last 30 lines" ===>> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
sleep 10
tail -n 30 $tomPatch/logs/catalina.out>> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
curl "?
username=1381xxxxxxx&password=xxxxxxxx&sendto=1381xxxxxxx&message=tomcatdown,startup_now~"
fi