Fedora Linux install vnstat network traffic monitor

ADVERTISEMENTS



1. Find information about vnstat

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.

Run the following dnf command:

dnf update

dnf info vnstat



2. Fedora Linux install vnstat app

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

sudo dnf install vnstat



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



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



Daily bandwidth usage stats

vnstat -d



Weekly bandwidth usage stats

vnstat -w



Monthly network usage stats

vnstat -m



Get top 10 bandwidth usage days

vnstat -t



Monitor network transfer rate in real time

vnstat -l



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.

