NetHogs – Monitor Per Process Network Bandwidth Usage in Real Time

Linux operating systems have tons of open source network monitoring tools on the web. Say, you can use iftop command to check bandwidth usage, netstat command to see reports on interface statistics or top command to watch running process on your system. But if you are really looking for something that can give you a real time statistics of your network bandwidth of per process usage, then NetHogs is the only utility you should look for.

Linux Network Bandwidth Monitoring

NetHogs – Network Bandwidth Monitoring

What is NetHogs?

NetHogs is an open source command line program (similar to Linux top command) that is used for monitor real time network traffic bandwidth used by each process or application.

From NetHogs Project Page

NetHogs is a small ‘net top’ tool. Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process. NetHogs does not rely on a special kernel module to be loaded. If there’s suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this. This makes it easy to identify programs that have gone wild and are suddenly taking up your bandwidth.

This article explains you on how to install and find out real time per process network bandwidth usage with nethogs utility under Unix/Linux operating systems.

Install NetHogs in RHEL, CentOS and Fedora

To install nethogs, you must turn on EPEL repository under your Linux systems and then run the following yum command to download and install nethogs package.

# yum install nethogs
Sample Output
[[email protected] ~]# yum -y install nethogs

Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * base: mirrors.hns.net.in
 * epel: mirror.nus.edu.sg
 * extras: mirrors.hns.net.in
 * rpmfusion-free-updates: mirrors.ustc.edu.cn
 * rpmfusion-nonfree-updates: mirror.de.leaseweb.net
 * updates: mirrors.hns.net.in
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nethogs.i686 0:0.8.0-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package				Arch				Version					Repository					Size
===========================================================================================================
Installing:
 nethogs				i686				0.8.0-1.el6				epel						28 k

Transaction Summary
===========================================================================================================
Install       1 Package(s)

Total download size: 28 k
Installed size: 50 k
Downloading Packages:
nethogs-0.8.0-1.el6.i686.rpm														|  28 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : nethogs-0.8.0-1.el6.i686                                                          1/1
  Verifying  : nethogs-0.8.0-1.el6.i686                                                          1/1

Installed:
  nethogs.i686 0:0.8.0-1.el6

Complete!

Install NetHogs in Ubuntu, Linux Mint and Debian

To install nethogs, type the following apt-get command to install nethogs package.

$ sudo apt-get install nethogs
Sample Output
[email protected]:~$ sudo apt-get install nethogs

[sudo] password for tecmint: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nethogs
0 upgraded, 1 newly installed, 0 to remove and 318 not upgraded.
Need to get 27.1 kB of archives.
After this operation, 100 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu/ quantal/universe nethogs i386 0.8.0-1 [27.1 kB]
Fetched 27.1 kB in 1s (19.8 kB/s)  
Selecting previously unselected package nethogs.
(Reading database ... 216058 files and directories currently installed.)
Unpacking nethogs (from .../nethogs_0.8.0-1_i386.deb) ...
Processing triggers for man-db ...
Setting up nethogs (0.8.0-1) ...

Using NetHogs Utility

To run the nethogs utility, type the following command under red-hat based systems.

# nethogs

To execute it, you will must have root permissions, so run with sudo command as shown.

$ sudo nethogs
Sample Previews:
Install Nethogs in Linux

NetHogs Preview on CentOS 6.3

Install nethogs in Ubuntu

NetHogs Preview on Ubuntu 12.10

As you see above the send and received lines show the amount of traffic being used by per process. The total sent and received usage of bandwidth calculated at the bottom. You can sort and change the order by using the interactive controls discussed below.

NetHogs Command Line Options

Following are the nethogs command line options. Using ‘-d‘ to add a refresh rate and ‘device name‘ to monitor specific given device or devices bandwidth (default is eth0). For example, to set 5 seconds as your refresh rate, then type the command as.

# nethogs -d 5
$ sudo nethogs -d 5

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

# nethogs eth0
$ sudo nethogs eth0

To monitor network bandwidth of both eth0 and eth1 interfaces, type the following command.

# nethogs eth0 eth1
$ sudo nethogs eth0 eth1
Other Options and Usage
-d : delay for refresh rate.
-h : display available commands usage.
-p : sniff in promiscious mode (not recommended).
-t : tracemode.
-V : prints Version info.

NetHogs Interactive Controls

Following are some useful interactive controls (Keyboard Shortcuts) of nethogs program.

-m : Change the units displayed for the bandwidth in units like KB/sec -> KB -> B-> MB.
-r : Sort by magnitude of respectively traffic.
-s : Sort by magnitude of sent traffic.
-q : Hit quit to the shell prompt.

For a full list of nethogs utility command line options, please check out the nethogs man pages by using command as ‘man nethogs‘ or ‘sudo man nethogs‘ from the terminal. For more information visit the Nethogs project home page.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

9 Responses

  1. Vab says:

    Hi I have a problem here: http://unix.stackexchange.com/questions/290147/unknown-network-connections-in-nethogs-is-it-safe
    what are those IP addresses? can you help me there?
    thank you

  2. Shantanu says:

    Getting error as:

    yum install nethogs
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.net.in
    * extras: centos.mirror.net.in
    * updates: centos.mirror.net.in
    Setting up Install Process
    No package nethogs available.
    Error: Nothing to do

    • Ravi Saive says:

      @Shantanu,

      May I know on which Linux distribution you’re trying to install? also have you installed and enabled EPEL repository on the system? if not, follow these commands.

      # yum install epel-release
      # yum install nethogs
      
  3. sudhir says:

    Hi,
    How can I filter the monitoring for a specific process with its name, could you you tell me an example command for that?

  4. researchiteng says:

    It seems nethogs is not recompiled by epel for RH/Centos 7.
    Any ideas how to do it?

    • Ravi Saive says:

      What do you mean by recompiled? the nethogs packages comes with epel repository all you have to do is:

      # yum install nethogs
      
  5. niraj vara says:

    HI

    I have installed the same and working fine and its a good tools but problem is PROGRAM column it showing only the destination details only its not showing the source address you can see the same issue in above screen when you run the

    sudo nethogs

Leave a Reply to Ravi Saive Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.