Advance

Tutorial Install vnStat on Ubuntu 20.04

Tutorial Install vnStat on Ubuntu 20.04
1
(1)

view network Statistics is a command-line tool for network traffic monitoring. It also and uses sames control keys and helps you to log and view network statistics over various time periods. This network utility is for the Linux Operating system and a console-based network traffic monitor. Since the traffic information is analyzed from the proc filesystem, vnStat can be used without root permissions. Using vnStat allows you to view hourly, daily, monthly statistics in the form of a detailed table or a command-line statistical view. Join us with this guide to review Tutorial Install vnStat on Ubuntu 20.04. To purchase a fully managed but cheap, Ubuntu VPS, choose a package or contact us on Eldernode.

How to Install vnStat On Ubuntu 20.04 step by step

As a developer or sysadmin, you need to Monitoring Network Traffic or Bandwidth Usage to monitor traffic on various systems which share the internet bandwidth. In this way, vnStat helps you monitor various network parameters like bandwidth consumption and the traffic flowing in/out. In this article, you will learn more about vnStat that is one of the tools which can do this and in the following, the process of installation vnStat on Ubuntu 20.04 will be taught.

Recommended Article: How to Install and run dropbox on Linux ubuntu 20.10

vnStat Features

Here are the most important benefits of using vnStat:

– Monitoring multiple interfaces at the same time

– Quick and simple to install and get running

– Gathered statistics persists through system reboots

– Several output options

– Data retention duration is fully user-configurable on the fly

– Months can be configured to follow the billing period

– Light, minimal resource usage

– Same low CPU usage regardless of traffic

– Can be used without root permissions

– The online color configuration editor

Install and Configure vnStat On Ubuntu 20.04 | Ubuntu 18.04

vnStat is available in the Ubuntu default repository. So, use the following command to install it.

sudo apt update
sudo apt install vnstat

Now, vnStat is installed and ready to start. To test if it is installed or not, you can type ”vnstat” in the terminal. So, you would not see any error like ”vnstat not found”. Also, you can use the command below to get the basic stats of all network interfaces.

vnstat

How to Setup and Run vnStat on Ubuntu 20.04

To make sure vnStat is running, use the command below:

sudo systemctl status vnstat

After ensuring that the vnStst is installed and running correctly, you need to find and set the network interface which you wish to monitor. So, to view a list of network interface available on your system and their names, run:

ifconfig

Now, to tell vnStat the network interfaces to monitor, let’s look at a wired interface for instance ”ens33” and a wireless interface ”wlan0”.  Type the following commands in the terminal.

vnstat -u -i ens33

You have activated monitoring that interface by running the above command. If this is the first time you run it, you will face the error: ‘Unable to read database “/var/lib/vnstat/ens33” ‘. The only reaction you must do is to ignore this.

If you have a WLAN, use the following command to set the wireless network interface.

vnstat -u -i wlan0

Run the command below to see all the network interfaces available in your system.

vnstat --iflist

Till here, you know all the interfaces that you want to be monitored. So, if you use the above command with that interface name, you can monitor the traffic. Then, use the following command to start the vnStat daemon.

sudo service vnstat start

You can check the status of the daemon process. to receive a month-wise summary of total network traffic from all registered interfaces run the following command.

ps -f | grep vnst

Using the “-i” option allows you to monitor specific network interfaces for specific but basic usage. So, the command for ens33 will be like:

vnstat -i ens33

Note: Replacing the “ens33” from the above command with any other interface like “eth0” or “wlan0” will give the statistics for that interface. At the end of each table, vnStat provides an estimated network usage for the month. To control the bandwidth usage, you can use this as one of the many useful features of vnStat.

How to use vnStat On Ubuntu Linux

You can use vnStat to monitor traffic at specific time periods and for one particular interface. Here we still continue with the ens33 example.

Hourly statistics view

To view hourly statistics in the form of a console-based graph followed by a table representing the usage for the last 24 hours, run:

vnstat -h -i ens33

To get the result, replace the “wlan0” with say “eth0”.

Monthly statistics view

Also, you can view the monthly statistics using the “-m” option:

vnstat -m -i ens33

Weekly statistics view

Use the “-w” option to view the weekly statistics for an interface:

vnstat -w -i ens33
Recommended Article: How to Repair Databases in MySQL

How to produce graphical images using vnStat

Using vnStat also allows you to produce graphical images representing the network traffic as graphs. To create graphs from vnStat and stores them in the specified location, it takes the required information.

The output of summary for an interface

Use the “-s” option of vnStati to take the output of a particular interface. So, to get the output and store it as an image called “summary.png” in the home folder, type:

vnstati -s -i ens33 -o ~/summary.png

Hourly display of stats

To get the output for hourly display use the “-h” option. To do this run the following command.

Note: The display is always for the last 24 hours.

vnstati -h -i ens33 -o ~/summary2.png

Cumulative output

Also, if you combine the traffic analysis of multiple interfaces, you will get the total output.

Look at the below example and then check the command.

“eth0+eth1” gives the output for the traffic by summing up the stats from eth0 and eth1. Similarly we can add up any number of interfaces like “eth0+eth1+eth2” or “eth0+wlan0”, etc.

vnstati -s -i wlan0+eth0 -o ~/summary3.png

Conclusion

In this article, you learned How To Install vnStat on Ubuntu 20.04. vnStat gives you a variety of information and you can log and analyze and produce by monitoring network traffic and prepare accurate results. If you are interested in learning more, find our article on Linux Server Monitoring Commands.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day