nethogs is a very helpful tool to find out which PID is taking high bandwidth and the trouble with your network traffic as it groups bandwidth by process instead of breaking the traffic down per protocol or per subnet, like most tools, do. Monitor Bandwidth Usage per Process using Nethogs depends on ncurses for the text-based interface and libpcap for user-level packet capture.
If there’s suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this. This is very helpful for a system administrator to troubleshoot.
- Shows TCP download- and upload-speed per process
- Supports both Ethernet and PPP
- Supports both IPv4 and IPv6
Install Nethogs Tool on a RHEL or CentOS or Fedora Linux
First, update EPEL repo and type the following yum command to install nethogs package:
yum install epel-release -y
yum install nethogs -y
Loaded plugins: fastestmirror, remove-with-leaves apporbit-base | 2.9 kB 00:00:00 apporbit-c3 | 2.9 kB 00:00:00 base | 3.6 kB 00:00:00 epel/x86_64/metalink | 14 kB 00:00:00 epel | 4.7 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/3): apporbit-c3/primary_db | 112 kB 00:00:00 (2/3): epel/x86_64/updateinfo | 847 kB 00:00:00 (3/3): epel/x86_64/primary_db | 6.1 MB 00:00:00 Loading mirror speeds from cached hostfile * base: centos.aol.com * epel: mirror.solarvps.com * updates: ftp.osuosl.org Resolving Dependencies --> Running transaction check ---> Package nethogs.x86_64 0:0.8.5-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: nethogs x86_64 0.8.5-1.el7 epel 38 k Transaction Summary ======================================================================================================================================================================== Install 1 Package Total download size: 38 k Installed size: 71 k Is this ok [y/d/N]: y Downloading packages: nethogs-0.8.5-1.el7.x86_64.rpm | 38 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : nethogs-0.8.5-1.el7.x86_64 1/1 Verifying : nethogs-0.8.5-1.el7.x86_64 1/1 Installed: nethogs.x86_64 0:0.8.5-1.el7 Complete!
Install Nethogs Tool n a Debian or Ubuntu Linux
Type the following apt-get command/apt-get command
sudo apt-get install nethogs
Once you successfully installed, Run the following command to see the bandwidth results.
For more details.
[[email protected]]# nethogs -h
usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [device [device [device …]]]
-V : prints version.
-h : prints this help.
-b : bughunt mode – implies tracemode.
-d : delay for update refresh rate in seconds. default is 1.
-v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
-c : number of updates. default is 0 (unlimited).
-t : tracemode.
-p : sniff in promiscious mode (not recommended).
-s : sort output by sent column.
-a : monitor all devices, even loopback/stopped ones.
device : device(s) to monitor. default is all interfaces up and running excluding loopback
nethogs running, press:
s: sort by SENT traffic
r: sort by RECEIVE traffic
m: switch between total (KB, B, MB) and KB/s mode