Monitoring Network Usage in Linux


Linux monitoring refers to the process of tracking and analyzing various aspects of a Linux system's performance, such as CPU usage, memory usage, disk usage, network traffic, and system uptime. The goal of Linux monitoring is to detect and diagnose any issues that may be impacting the performance or stability of the system, and to identify and correct problems before they become critical.

Network Monitoring Tools

Some common network monitoring tools for Linux include −

  • nload − is a command-line tool for monitoring network traffic on a Linux system.

  • Speedometer − is a simple tool but with a different approach of showing the network usage.

  • iftop − a command-line tool that displays a real-time list of network connections, sorted by bandwidth usage.

  • netstat − a command-line tool that displays various network-related statistics, including information about network connections and routing tables.

  • nethogs − a command-line tool that displays the network usage of individual processes, rather than system-wide usage.

These are some of the common network monitoring tools that can be used on Linux. Some tools might require additional software or configurations to be used and some can be used in combination to gain more insight and troubleshoot specific issues.

Let’s see nload, Speedometer, and nethogs tools in detail.

nload

nload is a command-line tool for monitoring network traffic on a Linux system. It displays real-time statistics about the incoming and outgoing network traffic on a selected network interface. The statistics include the current network usage in terms of the inbound and outbound transfer rate (in bytes per second), as well as the total amount of data transferred.

Basic Usage

The basic usage of nload is very simple. To start monitoring network traffic on a specific interface, you can use the command nload interface_name, where "interface_name" is the name of the network interface you want to monitor. For example, to monitor the traffic on the "eth0" interface, you can use the command nload eth0.

You can switch between the different network interfaces by pressing the up or down arrow key. Pressing 'q' key will exit the program.

You can also add some options for more information or format the display, for example,

-t − Displays the usage as text

-u -k -m − Changes the units of the usage from bytes to kibibytes or megabytes

-i interval − Changes the interval of the refresh rate

An example command would be −

nload -u k -t eth0

This command shows the usage on the eth0 interface, updating the usage every second (default) and showing the usage in kibibytes on a text format.

Changing the Refresh Interval

You can change the refresh interval of nload using the -i option followed by the desired interval in seconds. For example, to update the statistics every 5 seconds, you can use the command nload -i 5 eth0.

The default refresh interval is 1 second, but you can change it to any value you like. For example, if you want to update the statistics every 10 seconds, you can use the command nload -i 10 eth0.

You can also use a decimal number to specify the interval in seconds with a high precision.

You can test different intervals to find the best balance between detail and system load that fits your needs.

Setting the Unit

You can change the unit of measurement used by nload to display network usage. By default, the unit is bytes, but you can change it to kibibytes or megabytes using the -u option.

To set the unit to kibibytes, you can use the command nload -u k eth0. To set the unit to megabytes, you can use the command nload -u m eth0.

You also can use the shortcut options -k instead of -u k and -m instead of -u m to change the unit of measurement.

For example, the following command

nload -k eth0

will show the usage in kibibytes on the eth0 interface.

Displaying All Devices

By default, nload monitors the network traffic on a specific interface, specified as the command argument. However, you can also use nload to monitor the traffic on all available network interfaces on a Linux system by using the -a option or the --all option.

For example, to monitor the traffic on all network interfaces, you can use the command nload -a or nload --all . When you run this command, nload will display a live graph of the network traffic on all available interfaces, along with a summary of the current usage in a text-based format. You can use the up and down arrow keys to switch between interfaces, and press the 'q' key to quit the program.

Speedometer

speedometer is a command-line tool for monitoring the network traffic on a Linux system. It is similar to nload, it also allows you to monitor the real-time transfer rate of a specific network interface, or all interfaces combined.

Basic Usage

The basic usage of speedometer is similar to nload, it monitors the network traffic on a specific interface, specified as the command argument. To start monitoring network traffic on a specific interface, you can use the command speedometer -i interface_name, where "interface_name" is the name of the network interface you want to monitor. For example, to monitor the traffic on the "eth0" interface, you can use the command speedometer -i eth0.

You can switch between the different network interfaces by pressing the up or down arrow key. Pressing 'q' key will exit the program.

An example command would be −

speedometer -i eth0 -u m -r 2 -l

This command shows the usage on the eth0 interface, updating the usage every 2 seconds, showing the usage in megabytes and on a bar format.

nethogs

nethogs is a command-line tool for monitoring network usage on a Linux system, it is different from other tools like nload and speedometer, as it displays the network usage of individual processes, rather than system-wide usage.

Basic Usage

The basic usage of nethogs is simple, to start monitoring network usage on a specific interface, you can use the command nethogs interface_name, where "interface_name" is the name of the network interface you want to monitor. For example, to monitor the traffic on the "eth0" interface, you can use the command nethogs eth0.

For example, to monitor the traffic on the "eth0" and "wlan0" interfaces you can use the command

nethogs eth0 &  nethogs wlan0

This command runs nethogs on eth0 and wlan0 interfaces in the background and shows the usage on two different terminal windows.

You can press 'q' key to quit the program on the terminal you are using nethogs.

Summary

Network monitoring tools are software applications that allow you to track and analyze various aspects of a network's performance and usage. Some of the common network monitoring tools for Linux include iftop, netstat, ip, nethogs, vnstat, bmon, ifstat, tcpdump, wireshark, nagios, zabbix, snmp, and prometheus.

nload is a command-line tool that displays real-time statistics about the incoming and outgoing network traffic on a selected network interface.

speedometer is a command-line tool that allows you to monitor the real-time transfer rate of a specific network interface, or all interfaces combined.

nethogs is a command-line tool that displays the network usage of individual processes, rather than system-wide usage.

Updated on: 24-Jan-2023

13K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements