check network speed in suse

I wrote a script that shows you in a condensed way if you’re in network card speed trouble:
# ——————— server app213
bond0= eth1 eth2
bond0 : : : : : 10.20.9.38
eth0 : 100Mb/s : Half : on : yes : 192.168.5.119
eth1 : 100Mb/s : Half : on : yes :
eth2 : 100Mb/s : Half : on : yes :
eth3 : Unknown! (65535) : Unknown! (255) : on : no :
Here it goes:
#!/bin/bash
DIR=/tmp/.dir
mkdir $DIR > /dev/null 2>&1
HB=`ifconfig -a | grep -i bond | wc -l | sed ‘s/ //g’`
if [ “$HB” -ne “0” ];then
for i in `ifconfig -a | cut -c0-10 | egrep -i ‘bond’| grep -v ‘:’`;do
echo -n “$i=”
for i in `cat /etc/sysconfig/network/ifcfg-$i | grep “BONDING_SLAVE” | awk -F”=” ‘{ print $2 }’ | awk -F”‘” ‘{
print $2 }’`;do
echo -n ” $i”
done
echo “”
done
fi
for i in `ifconfig -a | cut -c0-10 | egrep -i ‘bond|eth’| grep -v ‘:’`;do
SP=`ethtool $i | grep “Speed:” | awk -F: ‘{ print $2 }’`
DU=`ethtool $i | grep “Duplex:” | awk -F: ‘{ print $2 }’`
AU=`ethtool $i |grep “Auto-negotiation:” | awk -F: ‘{ print $2 }’`
LI=`ethtool $i | grep “Link detected: ” | awk -F: ‘{ print $2 }’`
(for w in `ifconfig $i`;do
echo “$w”
done) | grep “addr:” | awk -F”:” ‘{ print $2 }’ > $DIR/addr
echo “$i : $SP : $DU : $AU : $LI : `cat $DIR/addr` ”
done
set network card speed by default in redhat.
If your interface is eth0, in the etc/sysconfig/network-scripts folder, vi the ifcfg-eth0 script. add the parameters
ETHTOOL_OPTS=”speed 100 duplex full autoneg on”, and you’re set
Next time the server reboots you have the right speed set
215/433
216/433

Leave a Reply

Your email address will not be published. Required fields are marked *