vnStat is a network tranffic monitor for specific interface like (eth0, eth1,..), we can monitoring bandwidth on console.
Features:
Its a light weight and minimal resource usage
Set the network traffic report at specific time in cronjob
Can monitoring multiple interfaces (ethX) at the same time
Its shows the reports possibilities are hourly, daily, monthly, weekly, average, top 10 days,
Can be used without root permission
Easy way install and configure it.
Set the network traffic report at specific time in cronjob
Can monitoring multiple interfaces (ethX) at the same time
Its shows the reports possibilities are hourly, daily, monthly, weekly, average, top 10 days,
Can be used without root permission
Easy way install and configure it.
1. How to Install a vnStat:
Centos/Fedora/RHEL
# yum install vnstat
Debian/Ubuntu
# apt-get install vnstat
Install Manually:
Download the package from the below url and install it
# wget http://humdi.net/vnstat/vnstat-1.11.tar.gz
# cd vnstat-1.11
# ./configure
# make && make install
Once you have installed it can find out installed location,
# whereis vnstat
vnstat: /usr/bin/vnstat /usr/sbin/vnstat.cron /usr/share/man/man1/vnstat.1.gz
# which vnstat
/usr/bin/vnstat
Update Bandwidth :
execute the below command to update,
# vnstat -u
Network Bandwidth Reports:
TX= transmitted traffic RX= Received traffic
# vnstatDatabase updated: Wed Aug 27 20:10:01 2014 eth0 since 05/28/14 rx: 173.25 GiB tx: 592.98 GiB total: 766.23 GiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jul '14 30.49 GiB | 218.83 GiB | 249.32 GiB | 780.85 kbit/s Aug '14 21.76 GiB | 192.70 GiB | 214.46 GiB | 775.79 kbit/s ------------------------+-------------+-------------+--------------- estimated 25.13 GiB | 222.57 GiB | 247.70 GiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- yesterday 886.22 MiB | 8.15 GiB | 9.01 GiB | 874.93 kbit/s today 812.13 MiB | 6.37 GiB | 7.16 GiB | 827.09 kbit/s ------------------------+-------------+-------------+--------------- estimated 966 MiB | 7.57 GiB | 8.52 GiB |
Query Database Report:
# vnstat -qDatabase updated: Wed Aug 27 20:10:01 2014 eth0 since 05/28/14 rx: 173.25 GiB tx: 592.98 GiB total: 766.23 GiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jul '14 30.49 GiB | 218.83 GiB | 249.32 GiB | 780.85 kbit/s Aug '14 21.76 GiB | 192.70 GiB | 214.46 GiB | 775.79 kbit/s ------------------------+-------------+-------------+--------------- estimated 25.13 GiB | 222.57 GiB | 247.70 GiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- yesterday 886.22 MiB | 8.15 GiB | 9.01 GiB | 874.93 kbit/s today 812.13 MiB | 6.37 GiB | 7.16 GiB | 827.09 kbit/s ------------------------+-------------+-------------+--------------- estimated 966 MiB | 7.57 GiB | 8.52 GiB |
Show Hourly Reports
# vnstat -heth0 20:10 ^ t | t t | t t t | t t t t t t t t t | t t t t t t t t t t | t t t t t t t t t t t t t | t t t t t t t t t t t t t t t t t | t t t t t t t t t t t t t t t t t t t | t t t t t t t t t t t t t t t t t rt t t t t t | t t t t t t t t t t t t t t t rt t rt t t t t t -+---------------------------------------------------------------------------> | 21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) h rx (KiB) tx (KiB) 21 40781 421358 05 29270 129691 13 40147 451605 22 26993 351584 06 16354 167081 14 170773 442355 23 31056 399914 07 20764 212141 15 36508 439376 00 20413 270040 08 25438 249406 16 51216 587212 01 18229 211535 09 25359 330828 17 53637 504272 02 15236 135354 10 36803 451424 18 34071 280340 03 13034 148547 11 49231 437033 19 40051 352470 04 45167 242102 12 86296 588615 20 3622 42860
Show Daily Reports
# vnstat -deth0 / daily day rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- 07/29/14 735.79 MiB | 8.06 GiB | 8.78 GiB | 852.01 kbit/s 07/30/14 1.00 GiB | 7.79 GiB | 8.79 GiB | 853.74 kbit/s 07/31/14 727.67 MiB | 6.81 GiB | 7.53 GiB | 730.63 kbit/s 08/01/14 744.88 MiB | 6.37 GiB | 7.10 GiB | 689.40 kbit/s 08/02/14 774.92 MiB | 5.89 GiB | 6.65 GiB | 645.55 kbit/s 08/03/14 622.54 MiB | 5.97 GiB | 6.58 GiB | 638.88 kbit/s 08/04/14 1.20 GiB | 7.13 GiB | 8.33 GiB | 808.94 kbit/s ------------------------+-------------+-------------+--------------- estimated 966 MiB | 7.57 GiB | 8.52 GiB |
Show Monthly Reports
# vnstat -meth0 / monthly month rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- May '14 20.12 GiB | 1.96 GiB | 22.08 GiB | 69.15 kbit/s Jun '14 100.88 GiB | 179.49 GiB | 280.37 GiB | 907.38 kbit/s Jul '14 30.49 GiB | 218.83 GiB | 249.32 GiB | 780.85 kbit/s Aug '14 21.76 GiB | 192.70 GiB | 214.46 GiB | 775.79 kbit/s ------------------------+-------------+-------------+--------------- estimated 25.13 GiB | 222.57 GiB | 247.70 GiB |
Show Weekly Reports
# vnstat -weth0 / weekly rx | tx | total | avg. rate ---------------------------+-------------+-------------+--------------- last 7 days 5.22 GiB | 49.08 GiB | 54.30 GiB | 770.74 kbit/s last week 5.24 GiB | 48.98 GiB | 54.22 GiB | 752.05 kbit/s current week 2.50 GiB | 22.70 GiB | 25.20 GiB | 861.37 kbit/s ---------------------------+-------------+-------------+--------------- estimated 6.17 GiB | 56.08 GiB | 62.25 GiB |
Show Top 10 Reports
# vnstat -teth0 / top 10 # day rx | tx | total | avg. rate -----------------------------+-------------+-------------+--------------- 1 06/04/14 24.08 GiB | 5.15 GiB | 29.23 GiB | 2.84 Mbit/s 2 06/05/14 22.75 GiB | 5.57 GiB | 28.32 GiB | 2.75 Mbit/s 3 06/02/14 21.11 GiB | 3.68 GiB | 24.78 GiB | 2.41 Mbit/s 4 06/03/14 11.68 GiB | 4.48 GiB | 16.16 GiB | 1.57 Mbit/s 5 05/31/14 12.22 GiB | 1.66 GiB | 13.88 GiB | 1.35 Mbit/s 6 07/10/14 3.80 GiB | 6.67 GiB | 10.47 GiB | 1.02 Mbit/s 7 07/25/14 723.59 MiB | 9.60 GiB | 10.31 GiB | 1.00 Mbit/s 8 07/24/14 943.91 MiB | 9.15 GiB | 10.08 GiB | 978.28 kbit/s 9 08/14/14 935.94 MiB | 8.92 GiB | 9.83 GiB | 954.81 kbit/s 10 08/13/14 817.88 MiB | 9.00 GiB | 9.80 GiB | 951.08 kbit/s -----------------------------+-------------+-------------+---------------
Short Output
# vnstat -srx / tx / total / estimated eth0: Jul '14 30.49 GiB / 218.83 GiB / 249.32 GiB Aug '14 21.76 GiB / 192.70 GiB / 214.46 GiB / 247.70 GiB yesterday 886.22 MiB / 8.15 GiB / 9.01 GiB today 812.13 MiB / 6.37 GiB / 7.16 GiB / 8.52 GiB
Calculate Tranffic
# vnstat -tr
282 packets sampled in 5 seconds Traffic average for eth0 rx 60.80 kbit/s 37 packets/s tx 72.00 kbit/s 19 packets/s
Rate Unit Montly / Daily
# vnstat -ru
Database updated: Wed Aug 27 20:15:16 2014 eth0 since 05/28/14 rx: 173.25 GiB tx: 593.01 GiB total: 766.26 GiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Jul '14 30.49 GiB | 218.83 GiB | 249.32 GiB | 97.61 KiB/s Aug '14 21.76 GiB | 192.73 GiB | 214.49 GiB | 96.97 KiB/s ------------------------+-------------+-------------+--------------- estimated 25.13 GiB | 222.57 GiB | 247.70 GiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- yesterday 886.22 MiB | 8.15 GiB | 9.01 GiB | 109.37 KiB/s today 815.35 MiB | 6.39 GiB | 7.19 GiB | 103.38 KiB/s ------------------------+-------------+-------------+--------------- estimated 965 MiB | 7.58 GiB | 8.52 GiB |
Show Live Transfer Rate:
# vnstat -lMonitoring eth0... (press CTRL-C to stop) rx: 20 kbit/s 44 p/s tx: 16 kbit/s 18 p/s^C eth0 / traffic statistics rx | tx --------------------------------------+------------------ bytes 52 KiB | 751 KiB --------------------------------------+------------------ max 44 kbit/s | 968 kbit/s average 32.00 kbit/s | 462.15 kbit/s min 20 kbit/s | 16 kbit/s --------------------------------------+------------------ packets 842 | 442 --------------------------------------+------------------ max 98 p/s | 55 p/s average 64 p/s | 34 p/s min 44 p/s | 18 p/s --------------------------------------+------------------ time 13 seconds
vnStat Help:
# vnstat --help or # help -?vnStat 1.11 by Teemu Toivola -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".
Set cronjob execute every 30 minutes Open cronjob file and add the below line# crontab -e
*/30 * * * * /usr/bin/vnstat -u
# /etc/init.d/crond restartError / Solution : You may get an below error when execute vnstat command, you need to set the network interface ( ethX )
# vnstat No database found, nothing to do. Use --help for help.
To check your network interface using ifconfig command,
# ifconfig
You can configure it
# vnstat -u -i eth0
Comments (0)