#!/bin/sh
let interval=2
t=`date +%T`
result=`cat /proc/net/dev |grep p2p2|sed 's/p2p2://g'`
rb1=`echo $result|awk '{print $1}'`
rp1=`echo $result|awk '{print $2}'`
sb1=`echo $result|awk '{print $9}'`
sp1=`echo $result|awk '{print $10}'`
dw1=`iostat -dm |awk ' {sum += $6;print sum}'|tail -1`
while [ 2 ]
do
sleep $interval
result=`cat /proc/net/dev |grep p2p2|sed 's/p2p2://g'`
rb2=`echo $result|awk '{print $1}'`
rp2=`echo $result|awk '{print $2}'`
sb2=`echo $result|awk '{print $9}'`
sp2=`echo $result|awk '{print $10}'`
dw2=`iostat -dm |awk ' {sum += $6;print sum}'|tail -1`
let rb=(rb2-rb1)/2/1024/1024
let rp=(rp2-rp1)/2
let sb=(sb2-sb1)/2/1024/1024
let sp=(sp2-sp1)/2
let dw=(dw2-dw1)/2
let rb1=rb2
let rp1=rp2
let sb1=sb2
let sp1=sp2
let dw1=dw2
#echo $rb"MB" $sb"MB">>NetData$t
echo `date +%T` $rb $dw >>NetDiskData$t
done