测试网卡流量脚本
2012-02-09 11:31
337 查看
下面是一个测试网卡流量的脚本,脚本内容如下:
#!/bin/bash
function usage
{
echo "use ./test_net.sh ethX time"
echo "$1 is you network interface "
echo "$2 is the last time!"
echo "for example: ./test_net.sh eth0 2"
exit 100
}
if [ $# -lt 2 -o $# -gt 2 ];then
usage
fi
eth=$1
time=$2
old_inbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $3}'`
old_outbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $11}'`
while true
do
sleep $time
new_inbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $3}'`
new_outbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $11}'`
inbw=`expr $((($new_inbw-$old_inbw)/$time))`
outbw=`expr $((($new_outbw-$old_outbw)/$time))`
echo "$eth: IN:$inbw bytes OUT:$outbw bytes"
old_inbw=${new_inbw}
old_outbw=${new_outbw}
done
exit 0
运行效果:
[root@bogon shell]# ./test_net.sh eth0 2
eth0: IN:3097 bytes OUT:50374 bytes
eth0: IN:3158 bytes OUT:44202 bytes
eth0: IN:2587 bytes OUT:58932 bytes
eth0: IN:2104 bytes OUT:51543 bytes
文章出处:飞诺网(www.diybl.com):http://www.diybl.com/course/6_system/linux/Linuxjs/20100609/208864.html
#!/bin/bash
function usage
{
echo "use ./test_net.sh ethX time"
echo "$1 is you network interface "
echo "$2 is the last time!"
echo "for example: ./test_net.sh eth0 2"
exit 100
}
if [ $# -lt 2 -o $# -gt 2 ];then
usage
fi
eth=$1
time=$2
old_inbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $3}'`
old_outbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $11}'`
while true
do
sleep $time
new_inbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $3}'`
new_outbw=`cat /proc/net/dev | grep $eth | awk -F'[: ]+' '{print $11}'`
inbw=`expr $((($new_inbw-$old_inbw)/$time))`
outbw=`expr $((($new_outbw-$old_outbw)/$time))`
echo "$eth: IN:$inbw bytes OUT:$outbw bytes"
old_inbw=${new_inbw}
old_outbw=${new_outbw}
done
exit 0
运行效果:
[root@bogon shell]# ./test_net.sh eth0 2
eth0: IN:3097 bytes OUT:50374 bytes
eth0: IN:3158 bytes OUT:44202 bytes
eth0: IN:2587 bytes OUT:58932 bytes
eth0: IN:2104 bytes OUT:51543 bytes
文章出处:飞诺网(www.diybl.com):http://www.diybl.com/course/6_system/linux/Linuxjs/20100609/208864.html
相关文章推荐
- 测试网卡流量shell脚本
- 测试网卡流量的shell脚本
- 一个监控网卡流量的shell脚本
- Shell脚本 网卡流量统计
- 基于dstat监控网卡流量,服务器状态简单脚本
- 【Python运维脚本】Python监控网卡流量
- Linux通过shell脚本计算网卡流量
- 【Python运维脚本】Python监控网卡流量
- shell awk实现实时监控网卡流量脚本(常见应用二)
- linux查看网卡流量的脚本
- shell awk实现实时监控网卡流量脚本(常见应用二)
- zabbix自定义网卡流量监控脚本and解决图形字体方块问题
- 统计网卡TX(发送)RX(接受)流量脚本
- shell awk实现实时监控网卡流量脚本(常见应用二)
- 统计网卡TX(发送)RX(接受)流量的shell脚本
- Linux下网络流量监控工具大全,查看网卡的实时流量脚本
- 统计网卡TX(发送)RX(接受)流量脚本
- shell脚本监控网卡流量
- 统计网卡流量的两段shell脚本(使用ifconfig) 详细出处参考:http://www.jb51.net/article/34290.htm
- 监控网卡流量脚本