Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make real-time statistics of network bandwidth utilization according to process under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to count network bandwidth utilization by process in real time under Linux". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to count network bandwidth utilization by process in real time under Linux".

NetHogs-Network bandwidth Monitoring

What is NetHogs?

NetHogs is an open source command line tool (similar to Linux's top command) that is 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 that groups bandwidth by process instead of slowing down each protocol or subnet as most tools do. NetHogs NetHogs does not rely on loading a particular kernel module. If there is a network congestion, you can start NetHogs and immediately see which PID caused the situation. This makes it easy to find out which program runs away and suddenly takes up your bandwidth.

This article shows you how to install and use NetHogs under the Unix/Linux operating system to monitor network bandwidth usage by process.

Install NetHogs under RHEL,CentOS and Fedora:

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

# yum install nethogs

Sample output:

[root@tecmint~] # yum-y install nethogs Loaded plugins:fastest mirror 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.i6860: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 28k Transaction Summary = Install 1 Package (s) Total download size:28k Installed size:50k Downloading Packages: nethogs-0.8.0-1.el6 .i686.rpm | 28kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing: nethogs-0.8.0-1.el6.i686 1 Verifying: nethogs-0.8.0-1.el6.i686 1 Installed: nethogs.i6860:0.8.0-1.el6 Complete!

Install NetHogs under Ubuntu, Linux mint, and Debian:

Type the apt-get command to install the NetHogs package:

$sudo apt-get install nethogs

Sample output

Tecmint@tecmint:~$ sudo apt-get install nethogs [sudo] password fortecmint: 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.1kB of archives. After this operation,100kB of additional disk space will be used. Get: 1 http://in.archive.ubuntu.com/ubuntu/ quantal/universe nethogs i386 0.8.0-1 [27.1kB] Fetched 27.1kB in 1s (19.8kB/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 forman-db... Setting up nethogs (0.8.0-1).

NetHogs usage

Type the following command to start the NetHogs tool on a RedHat-based system.

# nethogs

To execute NetHogs, you must have root permission, that is, use the sudo command as shown in the figure:

$sudo nethogs

Sample preview:

NetHogs Preview under CentOS 6.3

NetHogs Preview under Ubuntu 12.10

As shown in the figure above, the end and received columns show statistics based on the traffic of each process. The total bandwidth of sending and receiving data is at the bottom, and sorting can be controlled with interactive commands, which are discussed below.

NetHogs command line arguments

The following are the parameters of the NetHogs command line. Use'- d' to add the refresh frequency parameter, and `refresh name` is used to detect the bandwidth of a given device or devices (default is eth0). For example, to set the refresh rate of 5 seconds, type the following command:

# nethogs-d 5

Or

$sudo nethogs-d 5

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

# nethogs eth0 or

$sudo nethogs eth0

If you want to monitor both eth0 and eth2 interfaces, use the following command:

# nethogs eth0 eth2

Or

$sudo nethogs eth0 eth2

Other parameters and usage:

-d: delay for refresh rate. -h: display available commands usage. -p: sniff in promiscious mode (not recommended). -t: trace mode. -V: prints Version info.

NetHogs interactive control

Here are some useful interaction controls for NetHogs (keyboard shortcuts:

-m: Change the units displayed forthe bandwidth inunits like KB/sec- > KB- > B-> MB. -r: Sort by magnitude of respectively traffic. -s: Sort by magnitude of sent traffic. -Q: Hit quit tothe shell prompt. The above is all the contents of the article "how to count network bandwidth utilization by process in real time under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report