You are here

how to set up vnstat - a lightweight network bandwidth monitoring tool

vnstat is a network bandwidth monitoring application. it uses data collected by the kernel and so is quite light on the system.

the installation is dependent on your OS but once done, the program requires a little bit more to complete the setup:

this command will create databases to record the bandwidth for all interfaces on the system

for int in `vnstat --iflist| sed 's/Available interfaces://'` 
do
        vnstat -u -i $int
done

this next command is needed to allow vnstat to write to the db that was created as root

chown vnstat.vnstat  `cat /etc/vnstat.conf | grep DatabaseDir |sed 's/"//g' |awk '{print $2 "/*"}'`

we also will need to start the daemon when the box is started

systemctl enable vnstat.service

it is the modern equivalent of

chkconfig vnstat on

this last command will start up the service for your current boot up

service vnstat restart

and with that you are done.

enjoy!