(Updated 2.1.2010 for version 1.10)


Compiling the binaries
::::::::::::::::::::::

 This source package contains the required sources for vnStat including
 the daemon (vnstatd) and image output (vnstati). Executing

     make

 will compile 'vnstat' and 'vnstatd' without requiring additional libraries.
 The optional image output however requires libgd2 to be available. In 
 BSD ports libgd2 is usually named simply 'gd'. Executing

     make all

 will compile everything including the image output support.  An example
 cgi ('vnstat.cgi') to be used with http server with the image output
 support has been provided in the 'examples' directory. Configuration
 options for the cgi are in the beginning of the file.
 
 Some BSD users might need to use

     LIBRARY_PATH="/usr/local/lib" CPATH="/usr/local/include" make all

 instead if libgd2 is installed but still not found.


Installing as root
::::::::::::::::::

 Login as root and run the following command:

     make bsdinstall

 If there were no errors, vnStat binaries, man pages and a config file
 should now be installed. Next every interface that should be monitored 
 needs to be introduced to vnStat. Replace 'eth0' in the command with any
 available interface if needed.

     vnstat -u -i eth0

 Repeat that for every other interface you wish to use. If you are unsure
 of available interface names then run

     vnstat --iflist

 and select a suitable looking interface from the provided list. Usually
 'lo' isn't the one you are looking for.

 The configuration file /etc/vnstat.conf should also be checked at this
 point. See the vnstat.conf man page for documentation about available
 options.

 Finally make vnStat monitor the selected interface(s). There are two way
 for updating interface data, daemon and cron. It is suggested to use daemon
 based updating because it generated less disk access and is more accurate
 especially when monitoring interfaces that aren't always available. Select
 only one of these two:


 1) daemon based updating
 ::::::::::::::::::::::::

   Configure init scripts so that the following command is executed once
   during system start:

       vnstatd -d

   One suitable place is for example /etc/rc.local.


 2) cron based updating
 ::::::::::::::::::::::

   Add the following line to /etc/crontab (or with minor modifications
   to the personal crontab of the user responsible for updates):

       */5 * * * *  root  /usr/local/bin/vnstat -u

   That will update interface every 5 minutes. Modify the update interval
   if needed. See the vnStat man page 'restrictions' section for limitations
   regarding fast interfaces and 32 bit interface traffic counters. Devices
   like ppp0 also require vnStat enable and disable commands to be added
   to suitable script file when cron based updating is used. Example scripts
   can be found in the 'examples' directory.


Installing without root access
::::::::::::::::::::::::::::::

 Copy all needed binaries to some directory included in your $PATH
 (~/bin/ is an example) and make the database directory.

     cp src/vnstat src/vnstatd src/vnstati ~/bin/
     cp cfg/vnstat.conf ~/.vnstatrc
     mkdir ~/.vnstat

 Next open the config file ~/.vnstatrc with your favorite text editor and
 locate the following line:
 
     DatabaseDir "/var/lib/vnstat"

 and replace it with
 
     DatabaseDir "/pathtomyhomedir/.vnstat"

 and save the file. If you are unsure about you homedir path execute
 
     cd ; pwd

 The ouput should tell your homedir. 

 Next every interface that should be monitored needs to be introduced
 to vnStat. Replace 'eth0' in the command with any available interface if
 needed.

     vnstat -u -i eth0

 Repeat that for every other interface you wish to use. Now it's time to add
 a crontab entry for vnStat. Do that by executing the command 'crontab -e'
 and add the following line (without leading spaces, remember to change the
 path):

     */5 * * * * ~/bin/vnstat -u

 OR if the daemon can be used

     @reboot ~/bin/vnstatd -d

 If you found yourself using a strange editor then 'man vi' should help.

 If you choose to use the daemon then make sure the configuration file
 (~/.vnstatrc) has the log option either disabled or set to a file that
 is located in a place where you have write permissions, such as your
 home dir. Then (if using the daemon) try starting it with 'vnstat -d'.

 After that wait for (or generate) at least 1024 bytes of network traffic
 (and 5 min for the next cron/daemon update).

     vnstat

 Now you should get some stats about your network usage. See the config
 file ~/.vnstatrc for interface and other settings.

