该工具的行为如下:
#iftop eth0 1 3
ifname in _ bytes/sout _ bytes/s total _ bytes/s
eth0 446 418 864
eth0 70 182 252
eth0 70 182 252脚本的内容如下。
请参阅--------------bin/bash
# # # # 2012.10.22 monitortheinterfacenetworktraffic.if [ $ #-ne3 ]; then
echo example: ntop eth0 1 10
退出
fieth=$1
count=$3
interval=$2in first=$ { cat/proc/net/dev|tr ' : ' '|awk '/' $ eth '/{打印$2} ' }
if [ -z '$infirst' ]; then
echothenetworkinterface $ ethisnotexits!
exit 1;
fiout first=$ (cat/proc/net/dev|tr ' : ' '|awk '/' $ eth '/{打印$ 10 } ' ) )
echo ' ifname ' ' in _ bytes/s ' ' out _ bytes/s ' ' total _ bytes/s '|awk ' { printf } ' SSSSn ',$1,$2,
sleep $interval's '
i=0
while [ '$i' -lt '$count' ]
do
inend=$ (cat/proc/net/dev|tr ' : ' '|awk '/' $ eth '/{ print $2} ) )
outend=$ (cat/proc/net/dev|tr ' : ' '|awk '/' $ eth '/{ print $ 10 } ) )
sumin=$((inend-$infirst )/$interval ) )
sumout=$ () (outend-$outfirst )/$interval ) )
sum=$((sumin$sumout ) ) echo $ eth $ sumin $ sumout $ sum|awk ' { printf ) ss(n ),$1,$2,$3,$4) )
infirst=$inend
outfirst=$outend
I=$ () (I1 ) )
sleep $interval's '
(done ) ) ) ) ) ) ) ) ) ) done ) ) ) done ) )