netstat 计算流量


s=`netstat -I net0 -n`
sdown=`echo $s|cut -f 15 -d\\ `
sup=`echo $s|cut -f 17 -d\\ `
echo "$sdown $sup">>test2
s1=`tail -1 test2|cut -f 1 -d\\ `
s2=`tail -2 test2|head -1|cut -f 1 -d\\ `
sok=`echo "scale=3;($s1-$s2)*1500/10/1024"|bc`
echo "$sok KB/s">>test3