Get the App
SLTechnology News&Howtos  ›  Network Security  › 

NetHogs real-time monitoring process / program network usage

Shulou Source: shulou.com Published: 2022-06-01 04:02:12 10月06日 Update

NetHogs is a small open source traffic monitoring tool. Speaking of traffic monitoring tools, there are actually a lot of tools, such as: iftop, vnstat, these are statistics and monitoring of network card traffic. The characteristic of NetHogs is that it can monitor the bandwidth usage of each process in real time. When our server takes up a lot of bandwidth or some other network anomalies, we can use NetHogs to see which process or program exception causes the bandwidth to be occupied, so as to solve the bandwidth problem.

1. NetHogs installation:

1. It is recommended to use installation method:

Install under Ubuntu/Debian:

# apt-get install nethogs

Install under ReadHat/CentOS:

# yum install nethogs

Take centos as an example:

two。 Download the relevant package to compile and install:

Yum-y install gcc-g++ libpcap libpcap-devel

Wget http://jaist.dl.sourceforge.net/project/nethogs/nethogs/0.8/nethogs-0.8.0.tar.gz-p / usr/local/src

Cd / usr/local/src

Tar-xvf nethogs-0.80.tar.gz

Cd nethogs

Make & & make install

2. Use:

Nethogs [- h] [- V] [- d] [- v] [- t] [- c] [- p] [- s] [device (s)]

Examples of specific use:

Use NetHogs directly (the default is to detect the bandwidth of the device eth0, and the default is to refresh every second)

# nethogs

Refresh every 5 seconds using the-d parameter

# nethogs-d 5

Specify the bandwidth of the monitored network card device

# nethogs eth2

# nethogs eth0 eth2

3. Description of specific parameters:

(1) parameters and usage:

-h: displays the usage of available commands

-V: print version information

-d: delayed refresh rate (delayed refresh time), in seconds. Default is one refresh per second.

-v: select view mode

-p: sniffing in mixed mode (not recommended)

-t: tracking mode

-c: limit the number of refreshes (seems to be available only in version 0.8.1-SNAPSHOT and later versions)

-s: sort by the traffic sent (seems to be available only in version 0.8.1-SNAPSHOT and later versions)

Device (s): listening device. Default is eth0 (network card device name).

(2) NetHogs interactive control: (use keystroke operation)

M: press m key to switch units or display occupancy speed; the switching order is (KB/sec,KB,B,MB)

R: press r key to sort by received traffic

S: press the s key to sort by send traffic

Q: press Q key to exit

IV. Extended use of NetHogs

1. Redirect the information output of the nethogs monitoring process to a log file

# nethogs-c 1-t > test.log (does not seem to be supported in version 0.8.0)

Note: if you do not add the-t parameter, the content redirected to the file may be garbled.

Tags: Monitoring bandwidth traffic parameters version devices processes modes network cards sorting information units only tools files examples switching delays recommendations real-time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS Microsoft OPPO Reno MariaDB