Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3324278
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类:

2008-05-24 10:42:27

echo -n "请输入需要查询的网卡的接口:"
read eth
echo "你要查询的网卡接口为"$eth
echo -n "输入需要等到的时间(秒):"
read sec
echo "你计算的是"$sec"秒内的平均流量"
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 $sec"秒内总流量为:"$sum"bytes"
aver=$(($sum/$sec))
echo "平均流量为:"$aver"bytes/sec"
阅读(1472) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~