Linux View network card traffic for a process or program (GO)

Source: Internet
Author: User

I. Introduction of Nethogs

Share a check on the bandwidth usage of the detection system process under Linux. Open source tools from GitHub.

It does not rely on modules in the kernel. When our server network is abnormal, you can run the Nethogs program to detect that the program is taking up a lot of bandwidth. Find time saved.

Second, installation method

1. You can install the Yum directly in the Epel source

Yum Install Libpcap nethogs-y

2. Source Mode installation

2.1 Installing the C + + environment

[email protected] ~]# Yum install gcc-c++ libpcap-devel.x86_64 libpcap.x86_64 ncurses*

2.2 Download the compiled binary file

[[email protected] ~]# git clone https://github.com/raboof/nethogsInitialized empty git repository in/root/nethogs/.git  /remote:counting objects:1193, done.remote:Total 1193 (Delta 0), reused 0 (Delta 0), pack-reused 1193Receiving objects: 100% (1193/1193), 1.22 MiB | KIB/S, done. Resolving deltas:100% (789/789), done.

2.3 Compiling and installing

[[Email protected] ~]# CD Nethogs/[[email protected] nethogs]# Make[[email protected] nethogs]# make install

Complete the above steps even if the installation is complete. If the compilation fails, most of them are missing the compilation environment.

3. How to use

3.1 Run Nethogs directly to see the current bandwidth-consuming process

3.2 We're going to test the program to find the bandwidth-intensive eth0.

Nethogs Network card Device

We test eth0, run the command.

[Email protected] ~]# nethogs eth0

The first line in the graph is the traffic record in the test, which indicates that the client 192.168.40.250 to access the bandwidth occupied by my 80 port.

In the PID column, you can use the Lsof-p PID to view the process test.

Or use the Lsof-i: port number to see which processes are in use. See 80-Port Lsof-i: 80

Linux View network card traffic for a process or program (GO)

Related Article

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.