Tutorials and How-tos/Install vnStat

From BubbaWiki
< Tutorials and How-tos
Revision as of 11:41, 20 October 2010 by Rik Ellis (talk | contribs) (Updated to latest version of vnstat php frontend)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Author: asparak
If, like a lot of people, you want to keep track of your bandwidth usage, then this might help you. Just working on configuring the vnstat php frontend at the

moment and its pretty easy. I have wget installed, but you can install that easily if you don't have it

apt-get install wget 

1. Firstly install vnstat

apt-get install vnstat 

2. Download and put the vnstat frontend on your webserver. The filenames are for example, check their website for the latest version obviously :)

cd /home/web
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz
tar xvfz vnstat_php_frontend-1.5.1.tar.gz 

3. The next steps aren't essential, but I do it anyway, just for neatness

mv vnstat_php_frontend-1.5.1 vnstat
chown -R www-data:users vnstat 

4. Run vnstat to set up your databases for the interface(s) you want to monitor

vnstat -u -i eth0
vnstat -u -i eth1 

then it starts to record your data. After a few minutes, you might want to run vnstat from the command line, just to make sure its recording data properly. Leave it a few minutes, or it won't have had chance to gather anything.

5. cd into the vnstat frontend directory

6. edit the config.php file to set your interfaces the right way round and add /usr/bin/vnstat to the $vnstat_bin protocol and you should be good to go

7. Now you may want to download and install the daemon script from the vnstat homepage if you want to run vnstat on reboot, or you can just start it manually. http://humdi.net/vnstat/init.d/debian/vnstat You can use update-rc.d to set it up as well. This is the debian equivalent of chkconfig

cd /etc/init.d
wget http://humdi.net/vnstat/init.d/debian/vnstat
chmod a+x vnstat
update-rc.d -f vnstat defaults 

8. Up to you if you want to password control the directory using .htaccess file. I do