vnStat is a lightweight bandwidth monitoring tool for Linux and BSD that keeps a log of network traffic and provides monthly, weekly and daily tracking metrics. The following article will describe how to install and configure Vnstat on an Ubuntu VPS.
1. Installation
Login to your virtual server via ssh and enter the following command to update your system:
root@vps:~# apt-get update && apt-get upgrade
Next, run the following command to install vnStat on your Ubuntu VPS:
root@vps:~# apt-get install vnstat
And that’s it. You are done with the installation. It was that simple.
2. Usage
vnStat is one of the most capable and feature-rich tools for your Ubuntu VPS. In this tutorial, we’ll explore some of the usage examples of vnStat.
To view all the available interfaces on your system, execute:
root@vps:~# vnstat --iflist Available interfaces: lo venet0
To create a database for venet0:
root@vps:~# vnstat -u -i venet0
Start the vnstat daemon (vnstatd):
root@vps:~# /etc/init.d/vnstat start Starting vnStat daemon: vnstatd.
You can see all available options with the –help option. Use this more frequently to learn vnStat better. It has a lot of options. You can also use vnStat’s man page.
root@vps:~# vnstat --help vnStat 1.10 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".
Sample output for the venet0 interface:
root@vps:~# vnstat Database updated: Sun Apr 7 19:06:53 2013 venet0 since 04/07/13 rx: 521.41 MiB tx: 23.22 MiB total: 544.63 MiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Apr '13 521.41 MiB | 23.22 MiB | 544.63 MiB | 7.60 kbit/s ------------------------+-------------+-------------+--------------- estimated 2.25 GiB | 101 MiB | 2.34 GiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- today 521.41 MiB | 23.22 MiB | 544.63 MiB | 64.84 kbit/s ------------------------+-------------+-------------+--------------- estimated 654 MiB | 28 MiB | 682 MiB |
Live network statistic:
root@vps:~# vnstat -l -i venet0 Monitoring venet0... (press CTRL-C to stop) rx: 2 kbit/s 5 p/s tx: 2 kbit/s 4 p/s
As you can see, you can do a lot with vnStat For more documentation, refer to the vnStat website. Once you get the hang of it, you’ll start using vnStat on a daily basis and improve your Linux server workflow.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.