#!/system/bin/sh
while [ "1" ]
do
eth=rmnet_data0
RXpre=$(cat /proc/net/dev | busybox grep rmnet_data0 | busybox tr : " " | busybox awk '{print $2}')
TXpre=$(cat /proc/net/dev | busybox grep rmnet_data0 | busybox tr : " " | busybox awk '{print $10}')
sleep 1
RXnext=$(cat /proc/net/dev | busybox grep rmnet_data0 | busybox tr : " " | busybox awk '{print $2}')
TXnext=$(cat /proc/net/dev | busybox grep rmnet_data0 | busybox tr : " " | busybox awk '{print $10}')
#本次流量
setprop mifi.total.rx $RXnext
setprop mifi.total.tx $TXnext
clear
echo -e "\t RX `date +%k:%M:%S` TX"
RX=$((${RXnext}-${RXpre}))
TX=$((${TXnext}-${TXpre}))
RXtemp=`getprop persist.mifi.total.rx`
TXtemp=`getprop persist.mifi.total.tx`
#总流量
setprop persist.mifi.total.rx $((${RXtemp}+${RX}))
setprop persist.mifi.total.tx $((${TXtemp}+${TX}))
if [[ $RX -lt 1024 ]];then
RX="${RX}B/s"
elif [[ $RX -gt 1048576 ]];then
RX=$(echo $RX | busybox awk '{print $1/1048576 "MB/s"}')
else
RX=$(echo $RX | busybox awk '{print $1/1024 "KB/s"}')
fi
if [[ $TX -lt 1024 ]];then
TX="${TX}B/s"
elif [[ $TX -gt 1048576 ]];then
TX=$(echo $TX | busybox awk '{print $1/1048576 "MB/s"}')
else
TX=$(echo $TX | busybox awk '{print $1/1024 "KB/s"}')
fi
#即时网速
setprop mifi.current.rx $RX
setprop mifi.current.tx $TX
echo -e "$eth \t $RX $TX "
done
阅读(2803) | 评论(0) | 转发(0) |