#!/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 本文出自 “津津IT技术” 博客,请务必保留此出处http://shenhui.blog.51cto.com/1235972/748257
|