#! /bin/bash
while true
do
receive1=`ifconfig eth0 |grep 'RX bytes' | awk '{print$2}'|sed -s 's/bytes://g'`
echo $receive1 > /dev/null
send1=`ifconfig eth0 |grep 'RX bytes' | awk '{print$6}'|sed 's/bytes://g'`
echo $send1 > /dev/null
sleep 3
receive2=`ifconfig eth0 |grep 'RX bytes'| awk '{print$2}'|sed -s 's/bytes://g'`
echo $receive2 > /dev/null
receive_cnt=`expr $receive2 - $receive1`
receive_cnt=`expr $receive_cnt / 1024`
send2=`ifconfig eth0|grep 'RX bytes' | awk '{print$6}' |sed 's/bytes://g'`
send_cnt=`expr $send2 - $send1`
send_cnt=`expr $send_cnt / 1024`
echo $receive_cnt > /var/tmp/rs
echo $send_cnt >> /var/tmp/rs
done