脚本测速

来源:互联网 发布:mysql数据库免安装 编辑:程序博客网 时间:2024/05/17 03:32
#!/bin/bash
 
INTERVAL="1"  # update interval in seconds
 
if[ -z"$1" ];then
        echo
        echousage:$0[network-interface]
        echo
        echoe.g.$0eth0
        echo
        exit
fi
 
IF=$1
 
while true
do
        R1=`cat/sys/class/net/$1/statistics/rx_bytes`
        T1=`cat/sys/class/net/$1/statistics/tx_bytes`
        sleep$INTERVAL
        R2=`cat/sys/class/net/$1/statistics/rx_bytes`
        T2=`cat/sys/class/net/$1/statistics/tx_bytes`
        TBPS=`expr$T2- $T1`
        RBPS=`expr$R2- $R1`
        TKBPS=`expr$TBPS/ 1024`
        RKBPS=`expr$RBPS/ 1024`
        echo"TX $1: $TKBPS kb/s RX $1: $RKBPS kb/s"
done
0 0