Liunx流量统计
上一篇 /
下一篇 2011-06-14 09:52:36
/ 个人分类:Linux
#!/bin/bash
echo -n "Input the eth: "
read eth
echo "The eth is "$eth
echo -n "Input seconds: "
read sec
echo "Please wait ...."
infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://')
outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev)
sumfirst=$(($infirst+$outfirst))
sleep $sec"s"
inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://')
outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev)
sumend=$(($inend+$outend))
sum=$(($sumend-$sumfirst))
echo
echo "==========Duration is "$sec" seconds=========="
echo "Total: " $sum "Bytes"
aver=$(($sum/$sec))
echo "Avrage: " $aver "Bytes/sec"
echo "========================================="
echo
收藏
举报
TAG: