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

21-02-2024 03:01:45

This guide is based on a CentOS cloud server and introduces the installation and usage of Nethogs, a network monitoring tool. System administrators can use Nethogs to quickly identify processes causing performance degradation on the server. Unlike other similar tools, Nethogs sorts the bandwidth consumption by each process, rather than by protocol or subnet, enabling network administrators to swiftly pinpoint the causes of sudden bandwidth spikes on the server.

The Nethogs package is available through the EPEL third-party software repository, thus requiring the installation of EPEL prior to installing Nethogs.

sudo yum -y install epel-release
sudo yum -y update
sudo yum -y install nethogs

Launching Nethogs requires just a single command line, which automatically starts monitoring the default network interface's traffic.

sudo nethogs

Nethogs can also monitor multiple network interfaces simultaneously, such as eth0 and eth1.

sudo nethogs eth0 eth1

On the Nethogs display screen, press the 'm' key to toggle between total traffic and real-time bandwidth display. Press the 'q' key to exit the display.

Set the refresh interval to 3 seconds, with the default being 1 second.

sudo nethogs -d 3

Display the version number of Nethogs.

nethogs -V

Display the help information for Nethogs.

nethogs -h