The graphical front end is what makes VnStat different other monitoring tools available today. It is used to view and monitor bandwidth usage in network traffic. It uses a web based interface to establish connection and represent those findings in a nice graphical interface, which is developed using PHP.
It is helpful for administrative activities like identifying fault in network interface, detecting the root cause of traffic related issues, identifying traffic overload etc. it also helps the end user to monitor the excessive traffic flow in ISP end. It is also useful to avoid abusive bandwidth consumption. There are added features of VnStat like summarizing output on hourly, daily, monthly, weekly, basis, monitoring can be done for a particular set of defined connected interfaces and the generated output can be logged in the database for further analysis. All these features can be accessed without root privileges.
Coming to the installation part, there are different prerequisites to be taken before the installation begins. Initially all the dependencies for VnStat and PHP have to be installed using the YUM utility.
>> yum install wget epel-release php httpd php-gd
To install vnStat just execute the following command
>> yum install vnstat
To view all the available interfaces on your system that vnStat can monitor, use the following command:
>> vnstat –iflist
Available interfaces: lo eth0 eth1 |
Now add the eth0 and eth1 interfaces for monitoring traffic, as follows:
>> vnstat -u -i eth0
Error: Unable to read database /var/lib/vnstat/eth0 Info: -> A new database has been created |
For the first time, it will display the above error. Ignore this as sufficient data is not available for display.
Similarly, add the second interface, i.e., eth1, as follows:
>> vnstat -u -i eth1
Error: Unable to read database /var/lib/vnstat/eth1. Info: -> A new database has been created. Method for updating the database
:wq save and quit
Enable service at boot time
To start traffic monitoring for selected interfaces, start vnstat service.
Download the latest vnStat PHP frontend. Extract the downloaded archive in a Web-accessible directory, e.g. /var/www/html/
Edit the config.php file and set the following parameters as per your set-up:
If you are using SELinux, restore the file(s) default SELinux security contexts by using the restorecon command:
Make sure that the correct local time zone is set in php.ini. Edit php.ini and set date.timezone =Asia/Kolkata
Now enable web service at boot
Start the Web service httpd as follows:
You can access vnStat with the PHP frontend by pointing your browser to http://ipaddress/vnstat
Allow port 80 on the server from outside, add rule in iptables by executing below command:
To secure the vnStat PHP frontend with user authentication, add an entry in httpd.conf at the end as shown below:
After making changes in the httpd.conf file, restart the httpd service:
Create file /var/www/vnstat-htpasswd
This will add the user, with Force SHA encryption of the password. |