统计网卡TX(发送)RX(接受)流量的shell脚本
2014-10-16 16:04
1136 查看
#!/bin/bash
alias ifconfig="/sbin/ifconfig"
eth=eth0
while true; do
RXpre=$(ifconfig ${eth} | grep bytes | awk '{print $2}'| awk -F":" '{print $2}')
TXpre=$(ifconfig ${eth} | grep bytes | awk '{print $6}' | awk -F":" '{print $2}')
sleep 1
RXnext=$(ifconfig ${eth} | grep bytes | awk '{print $2}'| awk -F":" '{print $2}')
TXnext=$(ifconfig ${eth} | grep bytes | awk '{print $6}' | awk -F":" '{print $2}')
echo RX ----- TX
echo "$((((${RXnext}-${RXpre})/1024)/1024))MB/s $((((${TXnext}-${TXpre})/1024/1024)))MB/s"
done
脚本很简单,可以添加一些参数判断,比如多长时间显示一次等等。
执行结果:
RX ----- TX
5MB/s 7MB/s
RX ----- TX
5MB/s 7MB/s
RX ----- TX
4MB/s 6MB/s
RX ----- TX
4MB/s 6MB/s
RX ----- TX
本文原始链接:http://www.jbxue.com/LINUXjishu/1382.html
alias ifconfig="/sbin/ifconfig"
eth=eth0
while true; do
RXpre=$(ifconfig ${eth} | grep bytes | awk '{print $2}'| awk -F":" '{print $2}')
TXpre=$(ifconfig ${eth} | grep bytes | awk '{print $6}' | awk -F":" '{print $2}')
sleep 1
RXnext=$(ifconfig ${eth} | grep bytes | awk '{print $2}'| awk -F":" '{print $2}')
TXnext=$(ifconfig ${eth} | grep bytes | awk '{print $6}' | awk -F":" '{print $2}')
echo RX ----- TX
echo "$((((${RXnext}-${RXpre})/1024)/1024))MB/s $((((${TXnext}-${TXpre})/1024/1024)))MB/s"
done
脚本很简单,可以添加一些参数判断,比如多长时间显示一次等等。
执行结果:
RX ----- TX
5MB/s 7MB/s
RX ----- TX
5MB/s 7MB/s
RX ----- TX
4MB/s 6MB/s
RX ----- TX
4MB/s 6MB/s
RX ----- TX
本文原始链接:http://www.jbxue.com/LINUXjishu/1382.html
相关文章推荐
- 统计网卡TX(发送)RX(接受)流量脚本
- 统计网卡TX(发送)RX(接受)流量脚本
- Shell脚本 网卡流量统计
- Shell脚本 网卡流量统计(转)
- Shell脚本 网卡流量统计(转)
- 统计网卡流量的两段shell脚本(使用ifconfig)
- 统计网卡流量的两段shell脚本(使用ifconfig)
- 统计网卡流量的两段shell脚本(使用ifconfig) 详细出处参考:http://www.jb51.net/article/34290.htm
- linux 查看网卡流量的shell脚本
- 查看网卡流量shell脚本工具:network_top.sh
- shell脚本实现对网卡流量监控
- Shell脚本实现的单机流量统计功能
- 测试网卡流量的shell脚本
- shell脚本统计每秒话单发送量
- shell统计网卡流量速度
- Shell脚本监控网卡流量
- 测试网卡流量shell脚本
- linux下监控网卡流量的shell脚本
- 查看网卡流量shell脚本工具:network_top.sh
- shell脚本监控网卡流量