Install and run vnStat as a Non-Root user
One of the advantages of vnStat is that it can be installed and run as a Non-Root user. This can be of a great help to query vnStat of scripts or allow operators to run the vnStat utility.
Download vnStat
Download vnStat from here
DebianSystem# wget http://humdi.net/vnstat/vnstat-1.6.tar.gz
Unzip & Untar the downloaded the file
DebianSystem# tar -zxvf vnstat-1.6.tar.gz
ChangeDirectory & Compile
DebianSystem# cd vnstat-1.6
DebianSystem:/vnstat-1.6# make
Create Database Directory
If there was no errors, copy src/vnstat to some directory included in $PATH variable(say ~/bin/) and create the database directory.
DebianSystem# cp src/vnstat ~/bin/
DebianSystem# cp cfg/vnstat.conf ~/.vnstatrc
DebianSystem# mkdir ~/.vnstat
Test Kernel compatibility
DebianSystem# vnstat –testkernel
Edit Config file & Add Database Directory
DebianSystem# vi ~/.vnstatrc
Locate
DatabaseDir “/var/lib/vnstat”
and replace with
DatabaseDir “/pathtoyourhomedir/.vnstat”
and save the file.
Next every interface that should be monitored needs to be added to vnStat. This creates a database for each of the interface.
DebianSystem# vnstat -u -i eth0
where eth0 is the interface name. Change it to the interface on your system.
CRON Job
Add a crontab job entry for vnStat.
DebianSystem# crontab -e
and add the following line
*/5 * * * * ~/bin/vnstat -u
Allow it to collect enough traffic information after which run vnstat
DebianSystem# vnstat
Also, in any case you can check the config file ~/.vnstatrc for interface and other settings.
For more options and examples for the command, click here
Comments
Leave a Reply

