这是一个简单的脚本,通过定时读取/proc/net/dev文件来得出某个时刻输出的速度和输入的速度。 代码如下:
File /Users/wgzhao/Sites/blog.wgzhao.com/source/downloads/code/netwidth.sh could not be found
执行的效果如下:
# ./netwidth.sh eth1 2
IN: 14293 Byte/s OUT: 33869 Byte/s
IN: 123571 Byte/s OUT: 88281 Byte/s
IN: 6485 Byte/s OUT: 38938 Byte/s
其实ifconfig eth1输出结果中的 RX和TX数据一致的。
RX bytes:1662142572 (1.5 GiB) TX bytes:3408404141 (3.1 GiB)