Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at: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

    By 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.

    Advertisement

    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

    Related Posts

    How to Install Nagios Client (NRPE) on Ubuntu 20.04

    Installing Nagios on Ubuntu

    How to Install Nagios Server on Ubuntu 20.04

    How to Install Netdata Monitoring Tool on Ubuntu 20.04

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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