查看网卡流量的脚本
几点说明 : 该脚本用来放在服务器上查看网卡的目前流量. 该脚本只是大概统计流量,由于执行命令行需要消耗时间,故结果并不准确.但误差不大,可以看出流量趋势. 脚本的使用方法sh stream.sh $seconds,比如sh stream.sh 10表示10秒统计一次,sh stream.sh 1表示1秒一次. #!/bin/bash #monitor streams of LTS channels #Write by calfen 20090227 timeOld=`date +%s` eth0=`cat /proc/net/dev | grep eth0 | sed 's=^.*:==' ` eth1=`cat /proc/net/dev | grep eth1 | sed 's=^.*:==' ` eth0InOld=$(echo $eth0 | awk '{ print $1 }') eth0OutOld=$(echo $eth0 | awk '{ print $9 }') eth1InOld=$(echo $eth1 | awk '{ print $1 }') eth1OutOld=$(echo $eth1 | awk '{ print $9 }') while true do sleep ${1} eth0=`cat /proc/net/dev | grep eth0 | sed 's=^.*:==' ` eth1=`cat /proc/net/dev | grep eth1 | sed 's=^.*:==' ` timeNew=`date +%s` eth0InNew=$(echo $eth0 | awk '{ print $1 }') eth0OutNew=$(echo $eth0 | awk '{ print $9 }') eth1InNew=$(echo $eth1 | awk '{ print...
评论