Use Nethogs To Monitor Network Bandwidth Usage

Updated on January 23, 2016
Use Nethogs To Monitor Network Bandwidth Usage header image

In this tutorial, we will be covering the process of installing and using nethogs on CentOS 6x x64. nethogs is a network monitoring tool which allows Network and System Administrators to quickly identify the root cause of traffic-consuming processes that could be negatively affecting server’s performance.

Unlike similar tools, nethogs sorts bandwidth-consuming processes by process instead of protocol or subnet, thus allowing the Network and/or Systems Administrator to quickly identify the source of the traffic increase and isolate it if needed.

Prerequisites

  • A Vultr instance with CentOS 6.x x64.
  • A sudo user.

Installing Nethogs

The nethogs package is available under the EPEL Yum Repository:

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

Launching Nethogs

sudo nethogs

The above command will launch nethogs which will automatically begin monitoring bandwidth usage on the default Network Interface.

It is possible to specify the Network Interface which you want to monitor with nethogs. eg. eth1 or em0 etc…

sudo nethogs eth1

It is also possible to use nethogs to monitor multiple interfaces simultaneously:

sudo nethogs eth0 eth1

The Nethogs interface

The nethogs interface allows you to easily find the most consuming program on the specified device and its ID (PID or Process ID), user, and bandwidth usages.

On the Nethogs interface, press m to make the bandwidth usages toggle between total traffic and instant speed.

You can press q to quit the process.

Alternative ways to run nethogs

Set the refresh interval in seconds (the default value is 1 second):

sudo nethogs -d 3

Display the version number:

nethogs -V

Run Nethogs in tracemode:

sudo nethogs -t

In tracemode, the command outputs the connections one by one.

Run Nethogs in bughunt mode:

sudo nethogs -b

(Not recommended) Run Nethogs in promiscuous mode:

sudo nethogs -p

Show help for Nethogs:

nethogs -h