CactiEZ中求linux系统中网卡的总平均流量

 #!/bin/bash
 eth0=/var/www/eth0=/var/www/html/rra/*408.rrd
 rrdtool fetch $eth0  AVERAGE | grep  [.] > sumavg.txt
 awk '{print $2 + $3}' sumavg.txt > sum.txt
   for ((num=1;num<=(`wc -l sum.txt | awk '{print $1}'`);num++))
       do
       bb=`awk 'NR=='$num'' sum.txt`
       num=`expr $num+1`
       dd=`awk 'NR=='$num'' sum.txt`
#  aa=`echo ${bb%e*}`
#  ss=`echo ${dd%e*}`
       tt=`echo $bb $dd $tt | awk '{print ($1 + $2 + $3)}'`

       done
echo 现在eth0的总流量是: `expr $tt / 8 / 1024 / 1024` mb

echo ##########################################################

 eth1=/var/www/eth0=/var/www/html/rra/*409.rrd
 rrdtool fetch $eth1  AVERAGE | grep  [.] > sumavg.txt
 awk '{print $2 + $3}' sumavg.txt > sum.txt
   for ((num=1;num<=(`wc -l sum.txt | awk '{print $1}'`);num++))
     do
     bb=`awk 'NR=='$num'' sum.txt`
     num=`expr $num+1`
     dd=`awk 'NR=='$num'' sum.txt`
#  aa=`echo ${bb%e*}`
#  ss=`echo ${dd%e*}`
     tt=`echo $bb $dd $tt | awk '{print ($1 + $2 + $3)}'`
     done
echo 现在eth1的总流量是: `expr $tt / 8 / 1024 / 1024` mb

你可能感兴趣的:(linux,职场,网卡,休闲,流量)