(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. The
 required extra packages are usually named libgd2 and libgd2-dev (or
 libgd2-noxpm and libgd2-noxpm-dev in Debian/Ubuntu, xpm version can also
 be used). 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.


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

 Login as root and run the following command:

     make install

 If there were no errors, vnStat binaries, man pages and a config file
 should now be installed. Next the used kernel should be checked that it
 is able to provide static information about the system boot time.

     vnstat --testkernel

 The only way to fix a faulty kernel (afaik) is to compile/install a newer
 one. 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

   The examples/init.d directory contains suitable init.d scripts for
   some commonly used distributions. An alternative option is to just add
   the command to an already existing script that gets executed during 
   startup. In many distributions /etc/rc.local can be used for that.


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

   Copy the example cron file to /etc/cron.d

       cp examples/vnstat.cron /etc/cron.d/vnstat

   and edit the cron file if the default 5 minute update interval is too
   long. 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

 During version 1.0 it became clear that some kernels are broken and don't
 provide to correct boot time for the system. vnStat requires this information
 so there's a test to see if the kernel is working correctly.

     vnstat --testkernel

 If this gives 'command not found' then check your $PATH. The only way to fix
 a faulty kernel (afaik) is to compile/install a newer one. This can't be done
 without the root account so you'll have to solve this problem with your
 sysadmin if the kernel is broken.

 Now 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.
