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

 This source package contains the required source files 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, libgd-dev in more recent releases). 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. This has
 mainly been an issue in some kernels from the 2.4 series.

     vnstat --testkernel

 The only way to fix a faulty kernel (afaik) is to compile/install a newer
 one.

 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 available interfaces. Configure init scripts
 so that the following command is executed once during system start:

     vnstatd -d

 The 'examples' directory contains suitable files for most commonly
 used service managers:

   systemd:
     cp -v examples/systemd/vnstat.service /etc/systemd/system/
     systemctl enable vnstat
     systemctl start vnstat

   upstart:
     cp -v examples/upstart/vnstat.conf /etc/init/
     initctl start vnstat

   init.d:
     Debian:
       cp -v examples/init.d/debian/vnstat /etc/init.d/
       update-rc.d vnstat defaults
       service vnstat start
     Red Hat / CentOS:
       cp -v examples/init.d/redhat/vnstat /etc/init.d/
       chkconfig vnstat on
       service vnstat start

 An alternative method 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 if nothing else suitable can be found.

 During first startup, the daemon (vnstatd) should list and add all
 available interfaces for monitoring. Depending on configuration, it may
 take some minutes for the 'vnstat' command to begin showing results.
 Monitoring of unwanted interfaces can be stopped with:

     vnstat --delete -i ethunwanted


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 content of your PATH variable.
 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 your home directory path, execute

     cd ; pwd

 The ouput should tell your home directory.

 Now it's time to add a crontab entry for vnStat in order to get the daemon
 running automatically after a system startup. Do that by executing the
 command 'crontab -e' and add the following line (without leading spaces,
 remember to change the path):

     @reboot ~/bin/vnstatd -d

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

 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 try starting the daemon with

     vnstat -d

 After that wait for (or generate) at least 1024 bytes of network traffic
 (and 5 min for the next database file save).

     vnstat

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