系统相关
首页 > 系统相关> > shell测试网卡速度???

shell测试网卡速度???

作者:互联网

#!/bin/sh

Ifconfig="/sbin/ifconfig"
eth="enp3s0"

while true;do
RXpre=$($Ifconfig ${eth} | grep bytes | awk '{printf $2}' | awk -F":" '{printf $2}')
TXpre=$($Ifconfig ${eth} | grep bytes | awk '{printf $6}' | awk -F":" '{printf $2}')
sleep 1
RXnext=$($Ifconfig ${eth} | grep bytes | awk '{printf $2}' | awk -F":" '{printf $2}')
TXnext=$($Ifconfig ${eth} | grep bytes | awk '{printf $6}' | awk -F":" '{printf $2}')
TotalRXMin=$(expr `expr ${RXnext} - ${RXpre}` / 1024)
TotalTXMin=$(expr `expr ${TXnext} - ${TXpre}` / 1024)
echo "$(date +'%Y-%m-%d %H:%M:%S') Total Recive: ${TotalRXMin} kB/s,Total Transfer: ${TotalTXMin} kB/s" > /tmp/e.log
done

  

标签:shell,grep,expr,Ifconfig,网卡,awk,测试,printf,eth
来源: https://www.cnblogs.com/hshy/p/16385591.html