vnStat is a network traffic monitoring tool for Linux systems. It is used to track the network traffic data and display it in a convenient graphical interface. vnStat can be used to track bandwidth usage on a per-interface basis, which makes it an ideal tool for monitoring network traffic on servers, routers, and other network devices. This article provides a comprehensive guide on how to set up vnStat on CentOS and Fedora systems.

Advertisement

Prerequisites

Before installing vnStat, make sure that your system meets the following requirements:

  • A running CentOS or Fedora system
  • A user with administrative or root privileges

Step 1: Installing vnStat

  1. Update the system’s package index by running the following command:
    sudo yum update 
    
  2. Install the vnStat package by running the following command:
    sudo yum install vnstat 
    
  3. Once the installation is complete, start the vnStat service by running the following command:
    sudo systemctl start vnstat 
    
  4. Enable the vnStat service to start automatically at boot time by running the following command:
    sudo systemctl enable vnstat 
    

Step 2: Configuring vnStat

  1. To configure vnStat, open the configuration file using your favorite text editor, for example:
    sudo nano /etc/vnstat.conf 
    
  2. In the configuration file, set the desired options, such as the location of the database file, the polling interval, and the interface to be monitored. For example, to monitor the “eth0” interface set the following option:

  3. Save the changes and close the file.

Step 3: View Network Traffic Statistics

You should wait for some time to let the vnStat collect data for the defined interface. After that, you can view the statics on the command line interface.

  • To check the network traffic data, run the following command:
    vnstat 
    
    Output
    Database updated: 2023-02-07 18:30:00 eth0 since 2023-02-07 rx: 686.41 KiB tx: 5.20 MiB total: 5.87 MiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- 2023-02 686.41 KiB | 5.20 MiB | 5.87 MiB | 84 bit/s ------------------------+-------------+-------------+--------------- estimated 2.31 MiB | 20.76 MiB | 23.07 MiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- today 686.41 KiB | 5.20 MiB | 5.87 MiB | 739 bit/s ------------------------+-------------+-------------+--------------- estimated 890 KiB | 6.74 MiB | 7.61 MiB |

    The vnStat output will display the network traffic data for the specified interface in a graphical format, including the total amount of data received and transmitted, the total number of packets received and transmitted, and the average transfer rate.

  • You can also view the statistics for a specific time period, such as daily, weekly, monthly, and yearly, by running the following command:
    vnstat -d 
    vnstat -w 
    vnstat -m 
    vnstat -y 
    
  • You can also view the network statics in real-time with the following command.
    vnstat -l 
    

Conclusions

vnStat is a simple and lightweight tool for monitoring network traffic on Linux systems. With the help of this article, you should now be able to install and configure vnStat on CentOS and Fedora systems. The tool is highly customizable and provides a graphical representation of network traffic data, making it easy to understand and analyze network usage patterns. With vnStat, you can monitor network traffic on servers, routers, and other network devices, and ensure that your network is running smoothly.

Share.

8 Comments

  1. Hi Folks ,
    Thank you for amazing pretty tool article.
    i have a question.
    i installed my centos 6 x64 cPanel WHM server but . Getting Internal Server Error
    But everythings looks normal.
    What can i do ?
    Thanks in advance.
    Regards.
    Berk

Exit mobile version