Install bandwidth monitor vnstat

by Tweak on September 5, 2009
in Linux, Servers

vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s). vnStat isn’t a packet sniffer. The traffic information is analyzed from the /proc -filesystem, so vnStat can be used without root permissions. However at least a 2.2.x kernel is required.

  1. Install vnStat
    wget http://humdi.net/vnstat/vnstat-1.7.tar.gz
    tar zxvf vnstat-1.7.tar.gz
    cd vnstat-1.7
    make
    make install
  2. Create databases for NICs
    vnstat -u -i eth0
    vnstat -u -i eth1
  3. Set a cronjob to check bandwidth usage
    Add a crontab job entry for vnStat.
    crontab -e
    and add the following line
    */5 * * * * /bin/vnstat -u
  4. Install the frontend
    cd /var/www/
    wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.4.1.tar.gz
    tar zxvf vnstat_php_frontend-1.4.1.tar.gz
    mv vnstat_php_frontend-1.4.1 vnstat

    Edit vnstat/config.php and adjust the following lines to your preference:
    $iface_list = array('eth0', 'eth1');
    $iface_title['eth0'] = 'Extern';
    $iface_title['eth1'] = 'Intern';
    $vnstat_bin = '/usr/bin/vnstat';

Finally we open our browser and type

http://yourdomain.tld/vnstat/

You should see something like this

vnstat

Share and Enjoy:
  • email
  • Print
  • PDF
  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • MySpace
  • Live
  • Twitter
  • Yahoo! Buzz

Comments

2 Responses to “Install bandwidth monitor vnstat”
  1. Slover says:

    Every minutes I receive an email of Cron Daemon:

    Error: Unable create database backup “/var/lib/vnstat/.eth0″.

    How can I fix that ?

  2. MrKieu says:

    Edit the “/etc/cron.d/vnstat” config file and change “nobody” to “root”

    then restart the cron service

    “service crond restart”

Post a Comment