NetHogs -- real-time network bandwidth usage statistics by process in Linux

Source: Internet
Author: User
Tags linux mint

There are many open-source network monitoring tools for Linux operating systems on the Internet. for example, you can use the iftop command to check the bandwidth usage. netstat is used to view the interface Statistics Report, as well as the current processes of the top monitoring system. however, if you want to find a tool that can calculate network bandwidth utilization by process in real time, NetHogs is the only tool you need.

NetHogs-network bandwidth monitoring

What is NetHogs?

NetHogs is an open-source command line tool (similar to the top command in Linux) used to count network bandwidth usage in real time by process or program.

From the NetHogs Project Website:

NetHogs is a small 'net top' tool. Unlike most tools, NetHogs slows down each protocol or the speed of each subnet, but groups bandwidth by process. netHogs does not need to load a special kernel module. if network congestion occurs, you can start NetHogs to immediately see which PID causes this situation. in this way, it is easy to find out which program runs and then suddenly occupies your bandwidth.

This article explains how to install and use NetHogs in Unix/Linux operating systems to monitor network bandwidth usage by process.

Install NetHogs in RHEL, CentOS, and Fedora:

To install NetHogs, you must enable the EPEL source in Linux and then run the following yum command to download and install the NetHogs package.

  1. # Yum install nethogs

Sample output

  1. [Root @ tecmint ~] # Yum-y install nethogs
  2. Loaded plugins: fastest mirror, refresh-packagekit
  3. Loading mirror speeds from cached hostfile
  4. * Base: mirrors.hns.net. in
  5. * Epel: pai.nus.edu. sg
  6. * Extras: mirrors.hns.net. in
  7. * Rpmfusion-free-updates: mirrors.ustc.edu.cn
  8. * Rpmfusion-nonfree-updates: pai.de.leaseweb.net
  9. * Updates: mirrors.hns.net. in
  10. Setting up InstallProcess
  11. ResolvingDependencies
  12. --> Running transaction check
  13. ---> Package nethogs. i6860: 0.8.0-1. el6 will be installed
  14. --> FinishedDependencyResolution
  15. DependenciesResolved
  16. ========================================================== ========================================================== ======================================
  17. PackageArchVersionRepositorySize
  18. ========================================================== ========================================================== ======================================
  19. Installing:
  20. Nethogs i686 0.8.0-1. el6 epel 28 k
  21. TransactionSummary
  22. ========================================================== ========================================================== ======================================
  23. Install1Package (s)
  24. Total download size: 28 k
  25. Installed size: 50 k
  26. DownloadingPackages:
  27. Nethogs-0.8.0-1.el6.i686.rpm | 28kB00: 00
  28. Running rpm_check_debug
  29. RunningTransactionTest
  30. TransactionTestSucceeded
  31. RunningTransaction
  32. Installing: nethogs-0.8.0-1.el6.i6861/1
  33. Verifying: A nethogs-0.8.0-1.el6.i6861/1
  34. Installed:
  35. Nethogs. i6860: 0.8.0-1. el6
  36. Complete!
Install NetHogs in Ubuntu, Linux mint, and Debian:

Run the apt-get command to install the NetHogs package.

  1. $ Sudo apt-get install nethogs
Sample output
  1. Tecmint @ tecmint :~ $ Sudo apt-get install nethogs
  2. [Sudo] password fortecmint:
  3. Readingpackage lists... Done
  4. Building dependency tree
  5. Reading state information... Done
  6. The following NEW packages will be installed:
  7. Nethogs
  8. 0 upgraded, 1 newly installed, 0 to remove and318not upgraded.
  9. Need to get27.1kB of archives.
  10. Afterthis operation, 100kB of additional disk space will be used.
  11. Get: 1 http://in.archive.ubuntu.com/ubuntu/ quantal/universe nethogs i386 0.8.0-1 [27.1 kB]
  12. Fetched27.1kBin1s (19.8kB/s)
  13. Selecting previusly unselected package nethogs.
  14. (Reading database... 216058 files and directories currently installed .)
  15. Unpacking nethogs (from.../nethogs_0.8.0-1_i386.deb )...
  16. Processing triggers forman-db...
  17. Setting up nethogs (0.8.0-1 )...
NetHogs usage

In the RedHat-based system, enter the following command to start the NetHogs tool.

  1. # Nethogs

To execute NetHogs, you must have the root permission, that is, use the sudo command.

  1. $ Sudo nethogs

Sample preview:

NetHogs preview in CentOS 6.3

NetHogs preview in Ubuntu 12.10

As shown in, the send column and the received column show statistics based on the traffic of each process. the total bandwidth for sending and receiving data is at the bottom, and you can use interactive commands to control sorting. These interactive commands will be discussed below:

NetHogs command line parameters

The following are the parameters of the NetHogs command line. You can use '-d' to add the refresh frequency parameter. The 'device name' is used to detect the bandwidth of a given or certain devices (eth0 by default ). for example, set the refresh frequency for 5 seconds and enter the following command:

  1. # Nethogs-d 5

Or

  1. $ Sudo nethogs-d 5

If you only want to monitor the network bandwidth of the device (eth0), run the following command:

  1. # Nethogs eth0

Or

  1. $ Sudo nethogs eth0

To monitor the eth0 and eth1 interfaces at the same time, run the following command:

  1. # Nethogs eth0 eth1

Or

  1. $ Sudo nethogs eth0 eth1

Other parameters and usage

  1. -D: delay for refresh rate.
  2. -H: display available commands usage.
  3. -P: sniff in promiscious mode (not recommended ).
  4. -T: trace mode.
  5. -V: prints Version info.
NetHogs interaction control

Below are some useful interactive controls for NetHogs (Keyboard Shortcuts)

  1. -M: Change the units displayed forthe bandwidth inunits like KB/sec-> KB-> B-> MB.
  2. -R: Sortby magncategory of respectively traffic.
  3. -S: Sortby magn0000of sent traffic.
  4. -Q: Hit quit tothe shell prompt.

For the complete parameter list of the NetHogs command line tool, see the NetHogs manual. You can enter 'man nethogs 'or 'sudo man nethogs' in the terminal ', for more information, see the NetHogs project homepage.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.