Saturday 28 June 2014

Installing VNSTAT

A command-line network bandwidth monitoring tool, must be installed, configured and should collect network bandwidth statistics.
Software Package Requirements
  • VnStat
  • Apache
  • PHP 5
  • php-gd extension
VnStat 
  • # yum install -y vnstat 
  • # vnstat -u -i p4p1
    • You will see the following output
      • Error: Unable to read database "/var/lib/vnstat/p4p1".  
      • Info: -> A new database has been created. 
  • Make a Crontab entry 
    • # crontab -e 
      • add the following lines and exit: 
      • */5 * * * * /usr/bin/vnstat -u >/dev/null 2>&1
Apache, Php and Php-gd Extension 
  • # yum install httpd php php-gd -y 
  • # chkconfig httpd on 
  • # service httpd start 
  • # iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 
  • # service iptables restart
VnStat PHP Frontend 
  • Download
  • cd /tmp 
  • # wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz 
  • # tar xvf vnstat_php_frontend-1.5.1.tar.gz
  • Install
  • # cp -fr vnstat-php-frontend-master/ /var/www/html/vnstat 
  • # cd /var/www/html/vnstat 
  • # restorecon -Rv /var/www/html/vnstat/
  • Configure
    • # vi /var/www/html/vnstat/config.php
    • Set Lagrange.
      • // edit these to reflect your particular situation
        $locale = 'en_US.UTF-8';
        $language = 'en';

    •  Setting network interfaces to be monitored.
      • // list of network interfaces monitored by vnStat
        $iface_list = array('eth0', 'eth1');

    • You can set custom names for your network interfaces.
      • // optional names for interfaces
        // if there's no name set for an interface then the interface identifier.
        // will be displayed instead
        $iface_title['eth0'] = 'Internal';
        $iface_title['eth1'] = 'External';
Accessing the Graphs
  •  Go to your browser and type the url
    • http://localhost/vnstat

No comments:

Post a Comment