adsl掉线自动重拨并减少重复报警次数
2013-07-18 19:16
295 查看
注:原脚本存在大量重复报警的问题,改写后问题得以解决
实现一:借助临时文件
实现二:
实现一:借助临时文件
#!/bin/bash # PF=0 while true do touch /tmp/reppoe.txt PPP=`ifconfig -a | grep -o ppp` PING=` ping -c 4 www.baidu.com 2>&1 | grep ttl | wc -l` LINE=`cat /tmp/reppoe.txt | wc -l` if [ "$PPP" != 'ppp' ] || [ "$PING" -eq 0 ];then echo "`date` pppoe is down" >> /tmp/reppoe.txt if [ $LINE -gt 20 ]; then echo "pppoe is dowm " | mail -s "pppoe is down" mailaddr && PF=1 true > /tmp/reppoe.txt fi adsl-start; PING2=` ping -c 4 www.baidu.com 2>&1 | grep ttl | wc -l` if [ $PING2 != 0 -a $PF != 0 ];then IP=`LC_ALL=C ifconfig | grep -P -A2 "ppp" | grep 'inet addr' | cut -d: -f2 | awk '{ print $1}' ` echo "pppoe is up and ip is $IP" | mail -s "pppoe is up" mailaddr && PF=0 fi fi sleep 10 done
实现二:
#!/bin/bash mfcount=0 while true do PPP=`ifconfig -a | grep -o ppp` PING=` ping -c 4 www.baidu.com 2>&1 | grep ttl | wc -l` [ "$PPP" != 'PPP' ] || [ "$PING" -eq 0 ] status=$? if [ $status != 1 ] ;then mccount=`expr $mfcount + 1` [ $mfcount -lt 1 -o $mccount -gt 3 ] && echo "pppoe is down" | mail -s "pppoe is down" mailaddr && mfcount=`expr $mfcount + 1` ppstatus=1 while [ $ppstatus != 0 -o $PING = 0 ] do adsl-start; ppstatus=$? PING=` ping -c 4 www.baidu.com 2>&1 | grep ttl | wc -l` if [ $PING != 0 ] ;then echo ok && echo "pppoe is up and ip is $IP" | mail -s "pppoe is up" mailaddr && mfcount=0 fi sleep 3 done IP=`LC_ALL=C ifconfig | grep -P -A2 "eth0" | grep 'inet addr' | cut -d: -f2 | awk '{ print $1}' ` fi sleep 10 done
相关文章推荐
- ubuntu adsl 自动掉线的一个解决办法
- eclipse 关闭自动加载(重启),使用jreloader更新代码,减少重启次数。
- 减少重复工作,通过 Annotation Processor 自动完成源码的生成
- 要将五张100元的大钞票,换成等值的50元,20元,10元,5元一张的小钞票,每种面值至少1张,编程输出所有可能的换法,程序应适当考虑减少重复次数
- Windows ADSL自动拨号 ADSL自动掉线(断线)代码
- windows8系统ADSL空闲时自动掉线的原因分析及解决
- 使用C#实现ADSL自动拨号
- 设计文件系统时应尽量减少访问磁盘的次数,以提高文件系统的性能.下列各种措施中,哪些可以减少磁盘服务时间?
- Java 中的检测输入的重复数据并计算重复次数
- 向Nagios添加飞信机器人(FetionROBOT)自动报警功能!
- 内置虚拟化,自动分层,重复数据删除,固态硬盘,IBM Storwize V7000亮点解析
- 2015网易游戏笔试第一题(找9706的重复次数)
- KMP求最小重复子串的重复次数(poj2406)
- GG有这个提醒怎么办 合并外部 JavaScript 尽量减少 DNS 查询次数 由同一网址提供资源
- Oracle 减少数据库访问次数
- 统计每个数的重复次数,并按照重复次数由高到低排序的批处理
- 续ADSL自动断线之迷
- js 数组中的值出现的重复次数附加简单数组去重
- 减少oracle sql回表次数 提高SQL查询性能