Skip to content

Instantly share code, notes, and snippets.

@Zibri
Created Aug 5, 2019
Embed
What would you like to do?
Get network data usage from Android phone.
#!/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
@Zibri

This comment has been minimized.

Copy link
Owner Author

@Zibri Zibri commented Aug 5, 2019

$ ./getusage.sh
RX: 34189714 Kb TX: 872715 Kb
Total: 34240 Mb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment