Some Linux command line tools that can be used to monitor network usage.
These tools monitor the traffic that flows through the network interfaces and measure the speed with which data is being transferred. Inbound and outbound traffic is shown separately.
Some of the commands show the bandwidth used by individual processes. This makes it easier to detect a process that is using the network bandwidth too much.
The tools have different mechanisms for generating the traffic report. Here is a list of the commands, classified by their resources.
Nload is a command line tool that allows users to monitor incoming and outgoing traffic separately.
It also draws a graph to indicate the same, whose scale can be adjusted. Easy and simple to use and does not support many options.
So, if you just need to take a quick look at the total bandwidth usage without details of individual processes, nload will be useful.
Installation example on a Linux distro:
Example of use:
Iftop measures the data that flows through individual socket connections and works differently than Nload.
Iftop uses the pcap library to capture the incoming and outgoing packets from the network adapter and then adds the size and count to find the total bandwidth in use.
Although iftop reports the bandwidth used by individual connections, it cannot report the name/id of the process involved in the specific socket connection.
But, being based on the pcap library, iftop is able to filter traffic and report bandwidth usage on selected host connections, as specified by the filter.
Installation example on a Linux distro:
Example of use:
Iptraf is an interactive and colorful IP Lan monitor. It shows the individual connections and the amount of data flowing between the hosts.
Installation example on a Linux distro:
Example of use:
Nethogs is a small ‘net top’ tool that shows the bandwidth used by individual processes and ranks the list by placing the most intense processes at the top.
In the event of a sudden increase in bandwidth, quickly open the nethogs and find out who is responsible for the process. Nethogs informs the PID, the user and the program path.
Installation example on a Linux distro:
Example of use:
Bmon (Bandwidth Monitor) is a tool similar to nload that shows the traffic load on all network interfaces in the system. The output also consists of a graph and a section with details at the package level.
Installation example on a Linux distro:
Example of use:
Slurm is “more” another network load monitor that shows device statistics along with an ASCII graph. It supports 3 different styles of graphs, each of which can be activated using the keys c, s and l. Simple in resources, slurm no longer displays details about the network load.
Installation example on a Linux distro:
Example of use:
Tcptrack is similar to iftop and uses the pcap library to capture packets and calculate various statistics, such as the bandwidth used for each connection.
It also supports standard pcap filters that can be used to monitor specific connections.
Installation example on a Linux distro:
Example of use:
Vnstat is slightly different from most other tools. In fact, it runs a service/daemon in the background and keeps recording the size of the data transfer all the time.
It can then be used to generate a network usage history report.
Installation example on a Linux distro:
Running vnstat without any options would simply show the total amount of data transfer that has occurred since the date the daemon is running.
To monitor bandwidth usage in real time, use the ‘-l’ option (live mode). It would then show the total bandwidth used by the input and output data, but in a very precise way, without any internal details about host connections or processes.
Example of use:
Bwm-ng (Bandwidth Monitor Next Generation) is another very simple real-time network load monitor that reports a summary of the speed at which data is being transferred into and out of all available network interfaces in the system.
Installation example on a Linux distro:
If the size of the console is large enough, bwm-ng can also draw bar charts for traffic using the curses2 output mode.
Example of use:
A small, simple bandwidth monitor that displays the volume of traffic through network interfaces. There are no more options, only traffic statistics are displayed and updated in real time.
Installation example on a Linux distro:
Example of use:
Another small and simple tool that only draws beautiful graphics of incoming and outgoing traffic through a given interface.
Installation example on a Linux distro:
Example of use:
Pktstat displays all active connections in real time and the speed with which data is being transferred through them.
It also displays the connection type, that is, tcp or udp and also details about HTTP requests, if involved.
Installation example on a Linux distro:
Example of use:
Netwatch is part of the netdiag tool collection and also displays the connections between the local host and other remote hosts and the speed with which data is transferred over each connection.
Installation example on a Linux distro:
Example of use:
Like netwatch and pktstat, trafshow reports the current active connections, their protocol and the data transfer speed for each connection. It can filter connections using pcap filters. Monitor only tcp connections.
Installation example on a Linux distro:
Example of use:
netload is a very simple network traffic viewer for the terminal. It shows a moving bar graph representing incoming network traffic and a small box with RX and TX traffic in kilobytes.
Installation example on a Linux distro:
Example of use:
Ifstat reports the network bandwidth in a batch style mode. The output is in an easy format to record and analyze using other programs or utilities.
Installation example on a Linux distro:
Example of use:
Dstat is a versatile tool (written in python) that can monitor different system statistics and report them in a batch mode or record the data in a csv or similar file. This example shows how to use dstat to report network bandwidth.
Installation example on a Linux distro:
Example of use:
Collectl reports system statistics in a style similar to dstat and, like dstat, gathers statistics about several different system resources, such as CPU, memory, network, etc.
Here is a simple example of how to use it to report network usage/bandwidth.
Installation example on a Linux distro:
Example of use:
These were some useful commands to quickly check the network bandwidth on your Linux server. However, they do require the user to log in to the remote server using ssh.
Alternatively, web-based monitoring tools can also be used for the same task.
In addition, there are enterprise-grade monitoring tools, such as Nagios, that provide a number of features to monitor not just one server, but the entire infrastructure.
If you want to create your own solution it is very simple, for more details watch this video(Portuguese Brazilian)