Tag Archives: traffic information

Using vnstat for simple traffic accounting

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

Quick install guide (I have set it up on a Centos 5.3 box):
[[email protected]] $ wget http://tinyurl.com/mx9yrf
[[email protected]] $ tar zxvf vnstat-1.7.tar.gz
[[email protected]] $ cd vnstat-1.7
[[email protected]] $ make
[[email protected]] $ su
Password:
[[email protected]] # make install

#create databases for NICs
[[email protected]] # vnstat -u -i eth0
[[email protected]] # vnstat -u -i eth1
[[email protected]] # crontab -e


Add the following entry in the crontab:
*/5 * * * * /usr/bin/vnstat -u

Install the frontend:
[[email protected]] # cd /var/www/htdocs
[[email protected]] # wget -O http://tinyurl.com/kmn3u8
[[email protected]] # tar zxvf vnstat_php_frontend-1.4.1.tar.gz
[[email protected]] # 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';

That’s all, assuming apache is properly configured with php enabled, you can access the interface at http://your-domain.com/vnstat/