Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Monitoring Tools»How to Setup vnStat (Network Traffic Monitor) on Ubuntu / Debian / LinuxMint

    How to Setup vnStat (Network Traffic Monitor) on Ubuntu / Debian / LinuxMint

    RahulBy RahulDecember 1, 20153 Mins Read

    vnStat is a console-based utility which monitor network traffic ( transmit and received ) on selected network interface and stored it. This article will help you to install and setup vnStat on your server and setup web-based graph using vnstat-php application.

    1. Install vnStat

    vnstat packages are available under default repositories. Use the following command to install it.

    [email protected]:~$ sudo apt-get update 
    [email protected]:~$ sudo apt-get install vnstat 
    
    Fetched 85.3 kB in 1s (50.2 kB/s)
    Selecting previously unselected package vnstat.
    (Reading database ... 448551 files and directories currently installed.)
    Preparing to unpack .../vnstat_1.11-2_amd64.deb ...
    Unpacking vnstat (1.11-2) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    Setting up vnstat (1.11-2) ...
     * Starting vnStat daemon vnstatd Zero database found, adding available interfaces...
    "eth0" added, 100 Mbit bandwidth limit.
    "eth1" added, 100 Mbit bandwidth limit.
    -> 2 interfaces added. Limits can be modified using the configuration file.
                                                                             [ OK ]
    Processing triggers for ureadahead (0.100.0-16) ...
    

    2. Setup vnStat

    After successful installation edit vnstat configuration file ( /etc/vnstat.conf ) and update Interface option as per network interface you want to monitor by vnstat. In my case I am monitoring eth1 interface.

    Interface "eth1"
    

    3. View Statistics with Command

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

    • Show Statistics for a Day
      [email protected]:~# vnstat -d 
      
      eth1  /  daily
      
           day         rx      |     tx      |    total    |   avg. rate
       ------------------------+-------------+-------------+---------------
        12/01/15    197.64 MiB |    7.84 MiB |  205.48 MiB |   43.94 kbit/s
       ------------------------+-------------+-------------+---------------
       estimated       444 MiB |      15 MiB |     459 MiB |
      
    • Show Statistics for a Month
      [email protected]:~$ vnstat -m 
      
    • Show Statistics for a Hour
      [email protected]:~$ vnstat -h 
      
    • Show Statistics in Real Time
      [email protected]:~$ vnstat -l 
      

    4. Setup vnStat Web Interface.

    vnStat also provides php based web interface to show graphical statistics. In order to set up vnStat web interface, it required to have Apache, php and php-gd packages on your system.

    $ sudo apt-get install apache2 php5 php5-gd
    

    4.1. Download vnStat Source Archive

    Now download vnStat php source code from its official web-page or use following command.

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

    Now extract downloaded archive in web accessible directory, eg: /var/www/html/vnstat

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

    4.2. Edit Configuration File

    Now edit vnstat-php configuration file config.php file and set the following parameters as per your requirements.

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

    4.3. Access vnStat in Web browser

    Now access vnStat in web browser using server FQDN or IP address. eg:

      http://svr1.tecadmin.net/vnstat/
    

    Setup vnstat 1

    Setup vnstat 2

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Force Overwrite Local Files on Git Pull
    Next Article How to Mount Remote Windows Share on Linux

    Related Posts

    How to Install Nagios Client (NRPE) on Ubuntu 20.04

    3 Mins Read

    How to Install Nagios Server on Ubuntu 20.04

    Updated:June 3, 20213 Mins Read

    How to Install Netdata Monitoring Tool on Ubuntu 20.04

    2 Mins Read

    How to Install and Configure Sysstat on Ubuntu 20.04

    Updated:July 28, 20204 Mins Read

    How To Install Zabbix Server 5.0 on Ubuntu 20.04

    Updated:August 11, 20205 Mins Read

    How To Install Zabbix Agent on Ubuntu 20.04

    Updated:July 12, 20202 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to run “npm start” through docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.