码迷,mamicode.com
首页 > 其他好文 > 详细

Openwrt 获取客户端实时流量

时间:2014-08-27 18:26:28      阅读:885      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   for   ar   div   cti   log   sp   

echo "Collecting data..."
echo ""
cat /proc/net/arp | grep : | grep ^192 | grep -v 00:00:00:00:00:00 | awk {print $1} > mac-ip
iptables -N UPLOAD
iptables -N DOWNLOAD
while read line;do iptables -I FORWARD 1 -s $line -j UPLOAD;done < mac-ip
while read line;do iptables -I FORWARD 1 -d $line -j DOWNLOAD;done < mac-ip
sleep 1
echo "Download speed:"
echo ""
iptables -nvx -L FORWARD | grep DOWNLOAD | awk {print $2/1024/1" KB/s ",$1/10" packets/s", $9} | sort -n -r
echo ""
echo "Upload speed:"
echo ""
iptables -nvx -L FORWARD | grep UPLOAD | awk {print $2/1024/1" KB/s ",$1/10" packets/s", $8} | sort -n -r
 
while read line;do iptables -D FORWARD -s $line -j UPLOAD;done < mac-ip
while read line;do iptables -D FORWARD -d $line -j DOWNLOAD;done < mac-ip
iptables -X UPLOAD
iptables -X DOWNLOAD

 

Openwrt 获取客户端实时流量

标签:style   blog   color   for   ar   div   cti   log   sp   

原文地址:http://www.cnblogs.com/jzyuchen/p/3939985.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!