2.一段时间网口down掉
其实只要
/etc/init.d/network restart
并不需要重启。
在/etc/rc.d/rc.local最下面加一句话
network.sh &
把下面脚本放到/usr/bin/目录
并且给她加权限
chmod +x /usr/bin/network.sh
network.sh脚本:
#!/bin/sh
#echo "请输入你的网关地址"
#read sgateway
sgateway="192.168.3.187"
echo "连接的的网关是$sgateway"
delay=5000
echo "设置最大延迟不超过$delay毫秒"
nexttime=18
echo "每隔$nexttime秒进行一次检查"
echo "########################################"
while :
解答:
#!/bin/bashrmail=12345@qq.com
export LANG=zh_CN.UTF-8
ping -c50 192.168.1.10 >/tmp/ping.txt
if [ "$?" != "0" ] then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192.168.1.10 网络不通,请检查网络!" >>/tmp/pkgloss.txt
mail -s "测试IP网络异常报警" $rmail</tmp/pkgloss.txt
fi
loss1=`cat /tmp/ping.txt |grep loss|awk '{print $6}'|awk -F% '{print $1}'`
if [ $loss1 -gt 40 ] then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192.168.1.10 丢包率超过40" >>/tmp/pkgloss.txt
mail -s "测试IP网络异常报警" $rmail</tmp/pkgloss.txt
fi
if [ $loss1 -gt 80 ] then
echo "`date +"%Y-%m-%d %H:%M:%S"` IP地址:192.168.1.10 丢包率超过80" >>/tmp/pkgloss.txt
mail -s "测试IP网络异常报警" $rmail</tmp/pkgloss.txt
fi
echo "" >/tmp/pkgloss.txt:
iptables -I INPUT -p tcp --dport 80 -j DROPiptables -I OUTPUT -p tcp --dport 80 -j DROP
把80端口屏蔽就好了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)