The vnstat facility allows for the logging of network traffic on an interface. This can be useful for instance, for keeping track of broadband usage. Some ISPs in Australia provide usage meters which are sophisticated, but mostly designed for Windows OS. Vnstat provides a simple readout of date Tx/Rx which can be a useful feature on a 'nix based gateway.
See below for obtaining source with other distributions. To install under Debian/Ubuntu/Mint, use the apt-get command..
sudo apt-get install vnstat
This grabs and installs the application and lobs the executable into /usr/bin/vnstat
To initialise the database, run the vnstat command with the following switches..
- -u :forces a database update or creates the database if it doesn’t exist
- -i eth0 : specifies the network interface to monitor
vnstat -u -i eth1
The database gets updated by cron. Check with crontab -e to see if vnstat has been added by the installation routine. If it hasn't, add the following line..
*/5 * * * * /usr/bin/vnstat -u
This will update the database every 5 minutes. Adjust the time as preferred.
To view statistics, simply run vnstat
To view daily statistics, run vnstat -d
To view monthly statistics, run vnstat -m
To view the all time top 10 traffic, run vnstat -t
To get help, type vnstat --help
For more information on configuration, switches, customisation and obtaining source, check out humdi.net/vnstat/