Created
August 5, 2019 17:54
-
-
Save Zibri/387f0bd0acf09f71384ce78dd45aa058 to your computer and use it in GitHub Desktop.
Get network data usage from Android phone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get android network usage statistics from phone. | |
# by Zibri | |
function getUsage () | |
{ | |
rb=0; | |
tb=0; | |
for a in $(adb shell dumpsys netstats|grep "rb="|cut -d "=" -f 3|cut -d " " -f 1); | |
do | |
rb=$((rb+a/1024)); | |
done; | |
rb=$((rb/2)); | |
for a in $(adb shell dumpsys netstats|grep "rb="|cut -d "=" -f 5|cut -d " " -f 1); | |
do | |
tb=$((tb+a/1024)); | |
done; | |
tb=$((tb/2)); | |
echo RX: $rb Kb TX: $tb Kb | |
echo Total: $(((rb+tb)/1024)) Mb | |
}; | |
getUsage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. May I ask why you are dividing by 2 in L17?