Linux系统查看网络吞吐速度---脚本
用一个bash脚本存储下面内容:
#!/bin/sh
date1=`date --utc`
RX1=`cat /proc/net/dev | grep wlp0s20f3 | awk '{print $2}'`
TX1=`cat /proc/net/dev | grep wlp0s20f3 | awk '{print $10}'`
sleep 60
date2=`date --utc`
RX2=`cat /proc/net/dev | grep wlp0s20f3 | awk '{print $2}'`
TX2=`cat /proc/net/dev | grep wlp0s20f3 | awk '{print $10}'`
RX=$(($RX2-$RX1))
TX=$(($TX2-$TX1))
RXBAND=$(($RX*8/60/1024)) # Receive Rate: Kb per second
TXBAND=$(($TX*8/60/1024)) # Send Rate: Kb per second
echo "Time Range: $date2 - $date1"
echo "Network In Bytes: $RX bytes"
echo "Network Out Bytes: $TX bytes"
echo "Network In BandWidth: $RXBAND bytes"
echo "Network Out BandWidth: $TXBAND bytes"
脚本会统计指定网口'wlp0s20f3'在一分钟内的流入、流出的流量速度。