将下列脚本保存为可执行脚本文件,比如叫traff.sh。 1、本脚本默认监视eth0流量,因为换算成KB所以精度不高,如要精确度可不除以1024。 2、限于sleep命令的间隔最小为秒,所以速度的实时性有限。 3、此脚本不需要额外再安装软件,可在急用情况下应付一下,比如临时想看一下是否有流量通过,大概为多少等。 用法为watch -n 1 ./traff.sh即可开始监看流量,按ctrl+c退出。[code]#!/bin/bash eth=eth0 RXpre=$(ifconfig ${eth} |...
by 堆码狂人 - Shell - 2011-01-26 16:40:08 阅读(3802) 回复(0)
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。 http://jasonyong.blog.51cto.com/47753/174197 v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} linux 查看网卡流量 我的系统式RHEL5. 在linux...
工具运行效果如下: #iftop eth0 1 3 ifname in_bytes/s out_bytes/s total_bytes/s eth0 446 418 864 eth0 70 182 252 eth0 70 182 252 脚本内容如下: #!/bin/bash # osdba 2008.11.09 monitor the interface's network traffic. # [email=chengdata@gmail.c...
#!/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 |s...
#!/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 |s...
用法: ./traff.rb or ./traff.rb eth0 or ./traff.rb eth1 [code]#!/usr/bin/ruby # # usage: ./traff.rb [ethX] # author: zuerrong # dev = ARGV[0] || 'eth0' def getTraff(device) throuIn,throuOut = 0,0 File.open("/proc/net/dev").each do |s| if s =~ /#{device}:\d+/ arr = s.split throuOut = arr[8].to_i throuIn = arr[0].split(/:/).pop.to_i en...