Today, my company colleagues to my entire ADSL automatic redial shell, and detect whether connected to, so as to ensure that the internal test server does not drop the net, OK, I sent the script below.
System: CentOS 5.x
Script 1:
Copy Code code as follows:
cat/root/soft_shell/auto_adsl_1.sh
#!/bin/bash
Gateway= ' ifconfig ppp0 |grep p-t-p| Cut-f ":" |cut-f 1-d ""
Inter= ' ifconfig |grep Ppp0|awk ' {print $} '
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 $} ' |awk ' {print '} '
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
Script 2:
Copy Code code as follows:
cat/root/soft_shell/auto_adsl_2.sh
#!/bin/bash
Gateway= ' ifconfig ppp0 |grep p-t-p| Cut-f ":" |cut-f 1-d ""
Inter= ' ifconfig |grep Ppp0|awk ' {print $} '
n=2
if [[$inter!= Ppp0]]
Then
/sbin/adsl-start
Sleep 20
Pkgloss= ' ping-c4 $gateway |grep ' transm ' |awk-f ', ' {print $} ' |awk ' {print '} '
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: the function of script 2 is to detect whether ADSL dialing is connected.