vnstat - vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s).
1. Ubuntu install vnstat
$sudo apt-get install vnstat
2. vnstat command
$vnstat --help
vnStat 1.11 by Teemu Toivola <tst at iki dot fi>
-q, --query query database
-h, --hours show hours
-d, --days show days
-m, --months show months
-w, --weeks show weeks
-t, --top10 show top10
-s, --short use short output
-u, --update update database
-i, --iface select interface (default: eth0)
-?, --help short help
-v, --version show version
-tr, --traffic calculate traffic
-ru, --rateunit swap configured rate unit
-l, --live show transfer rate in real time
See also "--longhelp" for complete options list and "man vnstat".
$vnstat
Database updated: Fri Feb 5 00:05:49 2016
eth0 since 02/05/16
rx: 80 KiB tx: 61 KiB total: 141 KiB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
Feb '16 80 KiB | 61 KiB | 141 KiB | 0.00 kbit/s
------------------------+-------------+-------------+---------------
estimated -- | -- | -- |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
today 80 KiB | 61 KiB | 141 KiB | 3.23 kbit/s
------------------------+-------------+-------------+---------------
estimated -- | -- | -- |
$vnstat -h
eth0 00:10
^ r
| r
| r
| r
| r
| rt
| rt
| rt
| rt
| rt
-+--------------------------------------------------------------------------->
| 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 00
h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) h rx (KiB) tx (KiB)
01 0 0 09 0 0 17 0 0
02 0 0 10 0 0 18 0 0
03 0 0 11 0 0 19 0 0
04 0 0 12 0 0 20 0 0
05 0 0 13 0 0 21 0 0
06 0 0 14 0 0 22 0 0
07 0 0 15 0 0 23 0 0
08 0 0 16 0 0 00 178 96
Goooooooooooood.