add flow_count
git-svn-id: http://172.17.0.253/svn/soft_pkgs/sys_nicmonitor@1225 09c3743a-b0dd-45d3-b506-aa74c7a2a6ef
This commit is contained in:
18
docs/flow_count.sh
Normal file
18
docs/flow_count.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
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"
|
||||
Reference in New Issue
Block a user