国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

shell實現自動adsl撥號并檢測連接狀況腳本分享

2019-10-26 18:43:22
字體:
來源:轉載
供稿:網友

今天公司同事要我整個adsl自動重撥的shell,并檢測是否連上了,這樣才能保證內部測試服務器不掉網,好吧,下面我把腳本發出來.

系統:centos 5.x

腳本1:
代碼如下:
cat /root/soft_shell/auto_adsl_1.sh
#!/bin/bash
gateway=`ifconfig ppp0 |grep P-t-P| cut -f 3 -d ":"|cut -f 1 -d " "`
inter=`ifconfig |grep ppp0|awk '{print $1}'`
N=2
if [[ $inter -eq ppp0 ]]
then
/sbin/adsl-stop
sleep 10
/sbin/adsl-start
sleep 20
pkgloss=`ping -c4 $gateway|grep 'transm' |awk -F',' '{print $2}' |awk '{print $1}'`
if [[ $pkgloss -lt $N ]]
then
echo "`date +%Y-%m-%d/%T` The network is not stable">>/root/adsl.txt
else
echo "`date +%Y-%m-%d/%T` The network is normal">>/root/adsl.txt
fi
fi

腳本2:
代碼如下:
cat /root/soft_shell/auto_adsl_2.sh
#!/bin/bash
gateway=`ifconfig ppp0 |grep P-t-P| cut -f 3 -d ":"|cut -f 1 -d " "`
inter=`ifconfig |grep ppp0|awk '{print $1}'`
N=2
if [[ $inter != ppp0 ]]
then
/sbin/adsl-start
sleep 20
pkgloss=`ping -c4 $gateway|grep 'transm' |awk -F',' '{print $2}' |awk '{print $1}'`
if [[ $pkgloss -lt $N ]]
then
echo "`date +%Y-%m-%d/%T` The network is not stable">>/root/adsl.txt
else
echo "`date +%Y-%m-%d/%T` The network is normal">>/root/adsl.txt
fi
fi

ps:腳本2的作用就是檢測adsl撥號是否有連上.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鱼台县| 渝北区| 三明市| 高陵县| 南靖县| 上思县| 原平市| 冕宁县| 鹤峰县| 彝良县| 镇赉县| 兰州市| 伊吾县| 贵定县| 辛集市| 昔阳县| 关岭| 淳安县| 阜南县| 任丘市| 措勤县| 陇川县| 汉沽区| 眉山市| 凤台县| 濉溪县| 邵阳县| 青铜峡市| 根河市| 岳阳县| 宁国市| 同仁县| 元江| 尼勒克县| 长兴县| 科技| 长寿区| 中西区| 铁岭市| 洞口县| 西城区|