Shell应用:监控下载速度
Shell应用:监控下载速度
事例:
- #!/bin/bash
- # author: madding.lip
- # date: 2011.10.08
- 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"
相关推荐
tianhuak 2020-11-24
huha 2020-10-16
lianshaohua 2020-09-23
laisean 2020-11-11
zhangjie 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
CARBON 2020-10-20
彼岸随笔 2020-10-20
lianshaohua 2020-10-20
yutou0 2020-10-17
JohnYork 2020-10-16
xiaonamylove 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
ourtimes 2020-10-16