How To Install VnStat Network Monitoring on CentOS 7

Install VnStat Network Monitoring on CentOS 7

In this tutorial, we will show you how to install and configuration of VnStat network monitoring on your CentOS 7. For those of you who didn’t know, VnStat is a console-based network traffic monitoring tool designed for Linux and BSD. It allows the users to maintain a log of network traffic for the selected interfaces. In this Vnstat tool, the interface bandwidth will reduce automatically.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation VnStat network monitoring tool on a CentOS 7 server.


  • A server running one of the following operating systems: CentOS 7.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

VnStat Features

  • Multiple output options.
  • Generate png graphic output.
  • Consumes lite portion of system resources.
  • Monitor multiple network interfaces at the same time.
  • Sort the data by month, week, hour, and day.
  • Low CPU usage.

Install VnStat Network Monitoring on CentOS 7

Step 1. First, you will need to enable the EPEL repositories package for your version of Linux

yum -y install epel-release
yum -y update

Step 2. Installing VnStat.

Use yum command-line utility to install VnStat package on your system:

yum -y install vnstat

Once installed, start and enable the Vnstat services:

systemctl start vnstat
systemctl enable vnstat
chkconfig vnstat on

Step 3. Show Statics using vnStat Command-Line.

Using VnStat command-line utility you can view statistics on bandwidth per day, per month, and per hour basis. It also provides an option to show statistics in real-time:

### Show Statistics for a day ###
vnstat -d 

### Show Statistics for a Month ###
vnstat -m

### Show Statistics for a Hour ###
vnstat -h

### Show Statistics for a Real Time ###
vnstat -l

### For more available options you can use the --help ###
vnstat --help

Step 4. Configure the vnStat PHP Web-Based Interface.

vnStat also provides a PHP-based web interface to show graphical statistics. In order to set up the vnStat web interface, it required install LAMP stack on CentOS 7.

Download vnStat PHP code using the below-given URL.

get http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz

Extract downloaded archive in the web-accessible directory, eg: /var/www/html/:

tar xzf vnstat_php_frontend-1.5.1.tar.gz
mv vnstat_php_frontend-1.5.1 /var/www/html/

Edit the config.php file and set the following parameters:

$language = 'en';
$iface_list = array('eth0', 'sixxs');
$iface_title['eth0'] = 'Public Interface';
$vnstat_bin = '/usr/bin/vnstat';

Accessing VnStat via a web browser, open your favorite browser and navigate to http://your-domain.com/ or http://your-server-ip.

Install VnStat Network Monitoring on CentOS 7

Congratulations! You have successfully installed VnStat. Thanks for using this tutorial for installing VnStat network monitoring on CentOS 7 systems. For additional help or useful information, we recommend you check the official VnStat website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!



r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button