9394952

导航

查看网卡实时流速的脚本

原代码来自互联网,具体出处忘记了
#!/bin/sh

if [ "$1" == "" ]; then
ifcard="bond0"
else
ifcard=$1
fi

LANG=""
while true
do
up_time1=`ifconfig $ifcard | grep "TX bytes" | awk '{print $6}' | cut -d ":" -f 2`
down_time1=`ifconfig $ifcard | grep "RX bytes" | awk '{print $2}' | cut -d ":" -f 2`
sleep 1
clear
up_time2=`ifconfig $ifcard | grep "TX bytes" | awk '{print $6}' | cut -d ":" -f 2`
down_time2=`ifconfig $ifcard | grep "RX bytes" | awk '{print $2}' | cut -d ":" -f 2`
up_time=`expr $up_time2 - $up_time1`
down_time=`expr $down_time2 - $down_time1`
up_time=`expr $up_time / 1024`
down_time=`expr $down_time / 1024`
echo $up_time1, $down_time1, $up_time2, $down_time2
echo 上传速度: $up_time KB/s
echo 下载速度: $down_time KB/s
done

 

posted on 2022-09-11 10:42  9394952  阅读(34)  评论(0编辑  收藏  举报