V6rgudiagnoosiskript: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
- võrguliidese restart | - võrguliidese restart | ||
- kui ühendus pole taastunud, siis logi sisse ruuterisse ja tee sellele restart | - kui ühendus pole taastunud, siis logi sisse ruuterisse ja tee sellele restart (eraldi skript) | ||
</pre> | </pre> | ||
<source lang="bash"> | |||
#!/bin/sh | |||
viga='0' | |||
liides=`/sbin/route | grep default | awk '{print $8}'` | |||
echo 'Ruutingu tabeli järgi paistab, et vaikimisi kasutatakse liidesest' $liides | |||
ip=`/sbin/ip addr show eth0 | grep inet| awk '{print $2}' | head -c -4` | |||
echo 'Liidese' $liides 'all on IP aadressiks' $ip | |||
#GW KONTROLL | |||
gw=`/sbin/route | grep default | awk '{print $2}'` | |||
gwping=`/bin/ping -c 1 $gw | grep received | awk '{print $4}'` | |||
#echo 'gw =' $gw | |||
if [ `/bin/ping -c 1 $gw | grep received | awk '{print $4}'` == "1" ]; then | |||
echo 'Gateway' $gw 'vastab pingile' | |||
else | |||
echo '!!! Gateway' $gw 'ei vasta pingile !!!' | |||
viga='1' | |||
fi | |||
echo '' | |||
#NS KONTROLL | |||
ipd=`cat /etc/resolv.conf | grep nameserver | awk '{print $2}'` | |||
for i in $ipd; do | |||
if [ `/bin/ping -c 1 $i | grep received | awk '{print $4}'` == "1" ]; then | |||
echo 'Nimeserver' $i 'vastab pingile' | |||
else | |||
echo '!!! Nimeserver' $i 'ei vasta pingile !!!' | |||
viga='1' | |||
fi | |||
done | |||
echo '' | |||
#KODUMAISE LEHE WGET | |||
echo 'Laen alla www.neti.ee avalehte' | |||
wget -O /dev/null www.neti.ee -t 1 -T 3 -o /dev/null | |||
if [ $? != "0" ]; then | |||
echo ' !!! Sellega on probleem !!!' | |||
viga='1' | |||
else | |||
echo 'OK' | |||
fi | |||
#V2LISMAISE LEHE WGET | |||
echo 'Laen alla www.google.com avalehte' | |||
wget -O /dev/null www.google.com -t 1 -T 3 -o /dev/null | |||
if [ $? != "0" ]; then | |||
echo ' !!! Sellega on probleem !!!' | |||
viga='1' | |||
else | |||
echo 'OK' | |||
fi | |||
echo '' | |||
echo '#########################################################################' | |||
if [ $viga == "1" ]; then | |||
echo 'Võrguyhendusel on mingi probleem. Kas soovid v6rguliidest restartida? y/n' | |||
read restartida | |||
if [ $restartida == "y" ]; then | |||
echo '' | |||
echo 'Liides' $liides 'lylitatakse v2lja' | |||
echo '' | |||
ifdown $liides | |||
echo '' | |||
echo 'Liides' $liides 'k2ivitatakse uuesti' | |||
echo '' | |||
ifup $liides | |||
fi | |||
else | |||
echo 'V6rguyhendusel ei leitud vigu' | |||
fi | |||
echo '#########################################################################' | |||
</source> |
Latest revision as of 12:18, 25 January 2011
Skript, mis kontrollib võrguühenduse olemasolu. - kas võrguliides on olemas - kas võrguliidesel on olemas IP, GW, DNS - kas on ühendus GW'ga - kas on ühendus nimeserveriga - kas saab midagi Eesti serverist kätte - kas saab midagi rahvusvahelistest vetest alla sikutada - võrguliidese restart - kui ühendus pole taastunud, siis logi sisse ruuterisse ja tee sellele restart (eraldi skript)
#!/bin/sh
viga='0'
liides=`/sbin/route | grep default | awk '{print $8}'`
echo 'Ruutingu tabeli järgi paistab, et vaikimisi kasutatakse liidesest' $liides
ip=`/sbin/ip addr show eth0 | grep inet| awk '{print $2}' | head -c -4`
echo 'Liidese' $liides 'all on IP aadressiks' $ip
#GW KONTROLL
gw=`/sbin/route | grep default | awk '{print $2}'`
gwping=`/bin/ping -c 1 $gw | grep received | awk '{print $4}'`
#echo 'gw =' $gw
if [ `/bin/ping -c 1 $gw | grep received | awk '{print $4}'` == "1" ]; then
echo 'Gateway' $gw 'vastab pingile'
else
echo '!!! Gateway' $gw 'ei vasta pingile !!!'
viga='1'
fi
echo ''
#NS KONTROLL
ipd=`cat /etc/resolv.conf | grep nameserver | awk '{print $2}'`
for i in $ipd; do
if [ `/bin/ping -c 1 $i | grep received | awk '{print $4}'` == "1" ]; then
echo 'Nimeserver' $i 'vastab pingile'
else
echo '!!! Nimeserver' $i 'ei vasta pingile !!!'
viga='1'
fi
done
echo ''
#KODUMAISE LEHE WGET
echo 'Laen alla www.neti.ee avalehte'
wget -O /dev/null www.neti.ee -t 1 -T 3 -o /dev/null
if [ $? != "0" ]; then
echo ' !!! Sellega on probleem !!!'
viga='1'
else
echo 'OK'
fi
#V2LISMAISE LEHE WGET
echo 'Laen alla www.google.com avalehte'
wget -O /dev/null www.google.com -t 1 -T 3 -o /dev/null
if [ $? != "0" ]; then
echo ' !!! Sellega on probleem !!!'
viga='1'
else
echo 'OK'
fi
echo ''
echo '#########################################################################'
if [ $viga == "1" ]; then
echo 'Võrguyhendusel on mingi probleem. Kas soovid v6rguliidest restartida? y/n'
read restartida
if [ $restartida == "y" ]; then
echo ''
echo 'Liides' $liides 'lylitatakse v2lja'
echo ''
ifdown $liides
echo ''
echo 'Liides' $liides 'k2ivitatakse uuesti'
echo ''
ifup $liides
fi
else
echo 'V6rguyhendusel ei leitud vigu'
fi
echo '#########################################################################'