Nethogs – Monitor Linux network traffic usage per process

s2 0

There are tons of open source network monitoring tools for the Linux operating systems on the web. For example, suppose you can use the iftop command to monitor bandwidth usage, the netstat command or ss command to view reports on interface statistics, or the top command to monitor the running process on your system.

But if you’re really looking for something that gives you real-time statistics of your network bandwidth per process usage, then this is it NetHogs is the only utility you should be looking for.

Nethogs – bandwidth usage per process on Linux

What is NetHogs?

NetHogs is an open source command line utility (similar to the Linux top command) used to monitor the real-time network traffic bandwidth being used by any process or application in Linux.

From the NetHogs project page

NetHogs is a small ‘nettop’ tool. Instead of breaking down traffic by protocol or subnet, as most tools do, it groups bandwidth by process. NetHogs does not need to load a special kernel module. If there is suddenly a lot of network traffic, you can start NetHogs and immediately see which PID is causing this. This makes it easy to identify programs that have gone wild and are suddenly consuming your bandwidth.

In this article you will learn how to install and determine the network bandwidth usage per process in real time nethogs Utility under Unix / Linux Operating systems.

How to install NetHogs on Linux systems

this NetHogs Bandwidth monitoring solution is available for numerous Linux operating systems. Based on the Linux distribution you are running, you can install nethogs from one of the following ways:

Install NetHogs in RHEL, CentOS, Rocky Linux and AlmaLinux

To install nethogs, you need to enable the EPEL repository on RedHat based Linux distributions and then run the following yum command to download and install the nethogs package as shown.

# yum install epel-release
# yum install nethogs

on Fedora Linux, use the dnf command as shown.

# dnf install nethogs

Install NetHogs in Ubuntu, Linux Mint, and Debian

To install nethogs, issue the following apt command to install the nethogs package.

$ sudo apt install nethogs

How to use NetHogs to monitor bandwidth by process

To run the nethogs utility, enter the following command on Red Hat Based Systems.

# nethogs

On Debian-based Linux, you must have root privileges, so run with the sudo Command as shown.

$ sudo nethogs
NetHogs sample previews:
Install Nethogs on Linux
NetHogs preview of CentOS 6.3
Install Nethogs in Ubuntu
NetHogs preview of Ubuntu 12.10

As you can see above send and receive Lines indicate the amount of traffic used per process. The sum sent and receive The bandwidth usage is calculated below. You can sort and change the order using the interactive controls described below.

NetHogs command line options

The following are the nethogs Command line options. Using ‘-d‘to add an update rate and’Device name‘to monitor the bandwidth of a specific device or devices (default is eth0).

For example, to hire 5 seconds as your refresh rate, and then enter the command as.

# nethogs -d 5
$ sudo nethogs -d 5

To monitor a specific device (eth0) network bandwidth only, use the command as.

# nethogs eth0
$ sudo nethogs eth0

To monitor the network bandwidth of both eth0 and eth1 Interfaces enter the following command.

# nethogs eth0 eth1
$ sudo nethogs eth0 eth1

NetHogs Options and Usage

  • -d – Delay for the update rate.
  • -h – List of available commands.
  • -p – Sniffing in promiscuous mode (not recommended).
  • -t – Trace mode.
  • -V – Show version info.

Interactive controls from NetHogs

Below are some useful interactive controls (Keyboard shortcuts) of the nethogs program.

  • -m – Change the displayed units for the bandwidth in units such as KB / sec -> KB -> B -> MB.
  • -r – Sort by the size of each traffic.
  • -s – Sort by the size of the traffic sent.
  • -q – Press Exit at the shell prompt.

For a full list of nethogs Command line options of the utility please check the nethogs man pages with the command ‘Man nethogs‘ or ‘sudo man nethogs’“From the terminal.

For more information visit the Nethogs project Home page.