知乎:https://www.zhihu.com/people/monkey.d.luffy Android高级开发交流群2: 752871516
全部博文(315)
分类:
2012-07-13 17:12:48
原文地址: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