How to Monitor Cloud Server Network Bandwidth Usage with the iftop Tool?

21-02-2024 02:54:09

iftop is a real-time network troubleshooting and traffic monitoring tool. This article focuses on the installation and basic usage of iftop on CentOS cloud servers, though the instructions are applicable to other Linux distributions as well.

The CentOS official software repository does not include iftop; it requires the installation of the epel third-party software repository before installing the iftop tool. The installation command is as follows.

sudo yum install epel-release
sudo yum update
sudo yum install iftop

Once installed, running iftop requires just a single command.

sudo iftop

By default, without any parameters, iftop monitors the inbound and outbound traffic of the default network interface eth0. To monitor a different network interface, the -i option is needed. For example, to monitor the traffic on the eth1 interface, use the following command.

sudo iftop -i eth1

iftop displays all current network connections, with arrows indicating the direction of traffic flow. The last three columns show the average traffic over the last 2 seconds, 10 seconds, and 40 seconds, respectively. The bottom of the interface displays total outgoing (TX), incoming (RX), and overall traffic, presented in three different metrics: cumulative (cumm), peak, and rates.

The iftop interface is customizable, with a series of shortcut keys to adjust the display of data.

  • h: Toggle display of help information.
  • j: Move down.
  • k: Move up.
  • n: Toggle display of hostnames.
  • N: Toggle display of port numbers and service names.
  • s: Toggle display of the local host.
  • S: Toggle display of the local host's port numbers.
  • d: Toggle display of the destination host.
  • D: Toggle display of the destination host's port numbers.
  • p: Toggle display of port numbers.
  • P: Pause or resume updating data.
  • t: Toggle display modes: two lines per host, one line per host, only incoming traffic, only outgoing traffic.
  • <: Sort by source host.
  • : Sort by destination host.
  • q: Quit the application.

For more detailed information about iftop, please refer to the official documentation.

http://www.ex-parrot.com/pdw/iftop/