Hello,
I have a small bandwidth mobile phone contract so I need to control my usage of bandwith.
I use vnstat (https://humdi.net/vnstat/)
It is not sophisticated but it works.
Example of result:
phablet@ubuntu-phablet:~/Scripts$ ./consum.sh
rx / tx / total / estimated
ccmni0:
jul '18 2,08 MiB / 289 KiB / 2,36 MiB / 0 KiB
yesterday 0 KiB / 0 KiB / 0 KiB
today 0 KiB / 0 KiB / 0 KiB / --
I haven't found no ubuntu repo with vnstat compiled for our platform so I get it from debian.
Here I get the version of debian depending on my version of ubuntu:
So I'll download for version 15:
https://packages.debian.org/jessie/vnstat
And for version 16 (Sorry Haven't tried it, still on 15!!!) should be
https://packages.debian.org/stretch/vnstat
Next I need to check my arquitecture so I open a console on my phone and
dpkg --print-architecture
In my case the answer is
armf ( vegeta)
So I download the correct version
http://ftp.de.debian.org/debian/pool/main/v/vnstat/vnstat_1.12-2_armhf.deb for ubuntu 15.
In order to dpkg a file the filesystem needs to be on read write mode.
mount /dev/loop0 / -o remount,rw
sudo dpkg <filename>
My root filesystem is on readOnly mode most of the time. Vnstat needs to keep info and It can't be on base filesystem.
I Edit the /etc/vnstat.conf and put the database dir inside the home.
DatabaseDir "/home/phablet/.vnstat"
and reboot the phone (I don't know if this is mandatory ).
create dir /home/phablet/.vnstat
First I need to tell vnstat to control the ccmni0 connection.
vnstat —create -i ccmni0
finally I have a script with this instructions:
sudo vnstat -u
sudo vnstat -i ccmni0 -d -s
The first one updates vnstat internal counters and the next one gives the already shown result.
PS: Feel free to move this post where it should be if it's not in the rigth place.
Feel free to correct, change or update anything.
Thanks to all active people that are making UBPORTS REAL.
Salut!