MONITOR BANDWIDTH USAGE PER PROCESS WITH NETHOGS TOOL
GIT â I have Red Hat EnterpriseÂ LinuxÂ 6.x server. How do I find out and groups network bandwidth usage by process underÂ LinuxÂ operating systems? How do I find out what programs are using network bandwidth underÂ LinuxÂ operating systems?
Website :Â http://nethogs.sourceforge.net/
You need to use nethogsÂ command. It is a small ânet topâ tool. From the nethogs project home page:
Instead of breaking the traffic down per protocol or per subnet, like most such tools do, it groups bandwidth by process and does not rely on a specialÂ kernelÂ module to be loaded. So if thereâs suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this, and if itâs some kind of spinning process, kill it.
Please note that this toolÂ only works under LinuxÂ operating systems.
Type the followingÂ apt-get command to install nethogsÂ package:
$ sudo apt-get install nethogs
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libavutil-extra-51 libggiwmh0-target-x libggi2 libgii1 libvo-aacenc0 libgii1-target-x mplayer-skin-blue libggiwmh0 libggi-target-x libvo-amrwbenc0 Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: nethogs 0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded. Need to get 0 B/28.2 kB of archives. After this operation, 115 kB of additional disk space will be used. Selecting previously deselected package nethogs. (Reading database ... 331881 files and directories currently installed.) Unpacking nethogs (from .../nethogs_0.7.0-3_amd64.deb) ... Processing triggers for man-db ... Setting up nethogs (0.7.0-3) ...
Install nethogs under RHEL orÂ CentOSÂ or Fedora Linux
First turn onÂ EPEL repoÂ and type the followingÂ yumÂ command to install nethogs package:
# yum install nethogs
Loaded plugins: product-id, rhnplugin, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. This system is receiving updates from RHN Classic or RHN Satellite. rhel-x86_64-server-6 | 1.5 kB 00:00 rhel-x86_64-server-6/primary | 13 MB 00:01 rhel-x86_64-server-6 10127/10127 rhel-x86_64-server-6-debuginfo | 1.3 kB 00:00 rhel-x86_64-server-6-debuginfo/primary | 776 kB 00:00 rhel-x86_64-server-6-debuginfo 4240/4240 rhel-x86_64-server-optional-6 | 1.5 kB 00:00 rhel-x86_64-server-optional-6-debuginfo | 1.3 kB 00:00 rhel-x86_64-server-supplementary-6 | 1.5 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package nethogs.x86_64 0:0.8.0-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================== Package Arch Version Repository Size ===================================================================== Installing: nethogs x86_64 0.8.0-1.el6 epel 28 k Transaction Summary ===================================================================== Install 1 Package(s) Total download size: 28 k Installed size: 53 k Is this ok [y/N]: y Downloading Packages: nethogs-0.8.0-1.el6.x86_64.rpm | 28 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : nethogs-0.8.0-1.el6.x86_64 1/1 Verifying : nethogs-0.8.0-1.el6.x86_64 1/1 Installed: nethogs.x86_64 0:0.8.0-1.el6 Complete!
How do I use nethogs?
The syntax is:
Â nethogs nethogs eth1 nethogs [option] eth0 eth1 nethogs [option] eth0 eth1 ppp0 sudo /usr/sbin/nethogs eth0
Fig.01: nethogs in action
Another output from one of my personal RHEL server:
Use the following interactive controls:
- mÂ : Cycle between display modes (kb/s, kb, b, mb)
- rÂ : Sort by received.
- sÂ : Sort by sent.
- qÂ : Quit and return to the shell prompt.
-d delay for refresh rate. -h display available commands usage. -p sniff in promiscious mode (not recommended). -t tracemode. -V prints Version info.