#!/bin/sh
LANG=zh_cn
sendmsgfile=/home/lsc/fetion/install/cmd.txt
send_sms_mobile_telephone()
{
log_time=`cat ftpstat_time`
local_time=`date +%s`
n=$(( ${local_time}-${log_time} ))
if [ "$n" -gt "1800" ]; then
# 距离上次发送报警短信已经超过30分钟,可以再次发送。
echo $local_time > ftpstat_time
echo "sms 0 ${msg}" > $sendmsgfile
echo "exit" >> $sendmsgfile
/home/lsc/fetion/install/fetion -u 手机号码 -p 飞信密码 -EN -b $sendmsgfile
else
echo "距离上次发送报警短信还没有超过30分钟。"
fi
}
if wget -t 3 -T 3 --spider ftp://test:test的密码@127.0.0.1/ftpstat > /dev/null 2>&1 ; then
echo "FTP正常"
else
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
sleep 10 #延迟10秒
if wget -t 3 -T 3 --spider ftp://test:test的密码@127.0.0.1/ftpstat > /dev/null 2>&1 ; then
msg="服务器 IP地址 警报:FTP服务器无法登陆,已经成功启动。(监控使用测试连接帐号为test)。"
send_sms_mobile_telephone
else
msg="服务器 IP地址 警报:FTP服务器无法登陆,尝试启动失败。(监控使用测试连接帐号为test)。"
send_sms_mobile_telephone
fi
fi