全部博文(1015)
分类:
2012-06-05 21:38:25
原文地址:Linux下如何利用飞信发送告警短信 作者:fengzhanhai
#!/bin/bash
#Author fengzhanhai
#Create date 20120601
#The program is used by mon heartbeat
sendsms()
{
mypath=/root/mon
cd $mypath
admin=your telphone
mykey=yourpassword
for mynum in `cat userphone.doc`
#userphone.doc 为需要发送的电话薄列表
do
LD_LIBRARY_PATH=. ./fetion --mobile=$admin --pwd=$mykey --to=$mynum --msg-utf8="The master server disaster,the slave server has been boot" >>sms.log
done
}
mydir=/root/mon
cd $mydir
/sbin/ifconfig eth0:0 >myip
grep '192.168.202.56' myip >> /dev/null 2>&1
if [ $? -eq 0 ] && ! [ -f ha.lock ]
then
touch ha.lock ;
echo "`date` The shell is flushing route table" >>ha.log
/sbin/arping -I eth0 -c 3 -s 192.168.202.56 192.168.202.1 >>ha.log
sendsms ;
echo "`date` the route table has been success update">>ha.log
else
grep '192.168.202.56' myip >> /dev/null 2>&1
if [ $? -eq 1 ];
then
if [ -f ha.lock ];
then
rm -rf ha.lock;
fi
fi
fi