A tool for viewing process network traffic under linux-NetHogs

NetHogs is an open source command line tool (similar to Linux's top command), 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, which does not slow down the speed of each protocol or each subnet like most tools, but groups the bandwidth according to the process. NetHogs does not need to rely on loading a special kernel module. If network congestion occurs, you can start NetHogs to immediately see which PID caused the situation. This makes it easy to find out which program ran away and then suddenly took up your bandwidth.

NetHogs usage

$ sudo nethogs 

 

As shown in the figure above, the send column and received column show the traffic statistics of each process. The total bandwidth for sending and receiving data is at the bottom, and the ordering can be controlled by interactive commands. These interactive commands will be discussed below.

NetHogs command line parameters

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

# nethogs -d 5
$ sudo nethogs -d 5

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

# nethogs eth0
$ sudo nethogs eth0

If you want to monitor the eth0 and eth1 interfaces at the same time, use the following command:

# nethogs eth0 eth1
$ sudo nethogs eth0 eth1

Other parameters and usage

-d: refresh interval 
-h: help 
-p: promiscious mode 
-t: trace mode 
-V: version

Interactive command

The following are some interactive commands (keyboard shortcuts) of NetHogs

  • m: modify unit
  • r: sort by traffic
  • s: sort by sending traffic
  • q: Exit the command prompt

For more information, please refer to the NetHogs project homepage

Guess you like

Origin blog.csdn.net/lianshaohua/article/details/109239417