Fedora Linux install vnstat network traffic monitor

last updated in Categories , ,

How do I install vnstat network traffic monitor on Fedora Linux system to monitor my hourly, daily, weekly, and monthly bandwidth usage?

vnstat is free and open-source software. It is a console-based network traffic monitor that keeps a log of daily network traffic for the selected network interface. It is not a packet sniffer. The traffic information gathered from the /proc file-system so that application can use without root user-level access. This page shows how to install vnstat on Fedora Linux desktop or server.

1. Find information about vnstat

Run the following dnf command:
dnf update
dnf info vnstat

vnstat console-based network traffic monitor for Fedora Linux

2. Fedora Linux install vnstat app

Simply run the following command to install vnstat on Fedora Linux:
sudo dnf install vnstat

Fedora Linux install vnstat using dnf
How to install vnstat on Fedora Linux

3. Configure the vnstat

You need to edit the file named /etc/vnstat.conf using a text editor such as vim/nano:
sudo vi /etc/vnstat.conf
Set default interface name (use the ip command to obtain interface name):
Interface "wlp1s0"
Save and close the file in vim/vi.

Enable the service

Type the following systemctl command:
sudo systemctl enable vnstat.service
Sample outputs:

Created symlink /etc/systemd/system/vnstatd.service ? /usr/lib/systemd/system/vnstat.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vnstat.service ? /usr/lib/systemd/system/vnstat.service.

Start the service

sudo systemctl start vnstat.service

Stop the service

sudo systemctl stop vnstat.service

Restart the service

sudo systemctl restart vnstat.service

Find status of the vnstat service

sudo systemctl status vnstat.service
See vnstat service status on Fedora Linux

4. Learn how to use vnstat

The syntax is as follows:
vnstat
vnstat -i NIC_NAME
vnstat [options] -i NIC_NAME

Let us see some examples by typing the following command:
vnstat
vnstat -i eth0

Sample outputs:

Database updated: Thu Jul 11 17:00:51 2019
 
   eth0 since 06/11/17
 
          rx:  796.74 TiB      tx:  86.08 TiB      total:  882.81 TiB
 
   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Jun '19     29.50 GiB |    2.84 GiB |   32.33 GiB |  104.64 kbit/s
       Jul '19     11.95 GiB |    1.05 GiB |   13.00 GiB |  117.89 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated     34.59 GiB |    3.04 GiB |   37.63 GiB |
 
   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     yesterday      1.82 GiB |  172.14 MiB |    1.99 GiB |  193.09 kbit/s
         today    901.73 MiB |   92.55 MiB |  994.28 MiB |  132.98 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      1.24 GiB |     129 MiB |    1.37 GiB |

One can display traffic summary for a merge of interfaces eth0, eth3 and eth7:
vnstat -i eth0+eth3+eth7
Want to see information about interface eth9 in xml format? Try:
vnstat -i eth0 --xml
How about see all information of all monitored interfaces in json format? Try:
vnstat --json
vnstat --json -i eth0

Display hours stats

vnstat -h

Show traffic statistics on a hourly basis for the last 24 hours
Show traffic statistics on a hourly basis for the last 24 hours

Daily bandwidth usage stats

vnstat -d

See traffic statistics on a daily basis for the last 30 days
See traffic statistics on a daily basis for the last 30 days

Weekly bandwidth usage stats

vnstat -w

Get network traffic for 7 days, current and previous week
Get network traffic for 7 days, current and previous week

Monthly network usage stats

vnstat -m

My traffic statistics on a monthly basis for the last 12 months
My traffic statistics on a monthly basis for the last 12 months

Get top 10 bandwidth usage days

vnstat -t

Find all time top 10 traffic days
Find all time top 10 traffic days

Monitor network transfer rate in real time

vnstat -l

vnstat live in action
Gif 01: vnstat live in action

Force a database update for interface eth0

vnstat -u -i eth0

Delete database of interface eth1 and stop monitoring it

vnstat -i eth1 --delete

Conclusion

This page showed you how to install and use vnStat which a console-based network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s). For more info, see project home page here.

This entry is 4 of 4 in the vnStat Monitor and Log Network Traffic Tutorial series. Keep reading the rest of the series:
  1. How to install vnstat on a CentOS/RHEL/Fedora Linux
  2. View Vnstat Graphs Using PHP Web Interface Frontend
  3. How to install vnstat on FreeBSD Unix server
  4. Fedora Linux install vnstat network traffic monitor

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive