View server NIC traffic through Nethogs

Source: Internet
Author: User


In daily operations, you will encounter a spike in server bandwidth causing site anomalies. As operations personnel, we need to be able to understand the server network card traffic situation, the network card traffic is observed by which programs are occupied.

Today, we introduce a tool for viewing server NIC traffic usage under Linux: Nethogs, an open source tool 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.


Nethogs Installation:

Method One: The Epel source can be installed directly in Yum
[email protected] src]# Yum install-y libpcap nethogs-y

Method Two: Source code installation
#安装c + + Environment
[email protected] src]# Yum install-y gcc-c++ libpcap-devel.x86_64 libpcap.x86_64 ncurses*
[[email protected] src]# git clone https://github.com/raboof/nethogs
[Email protected] src]# CD nethogs/
[[email protected] src]# make
[[email protected] src]# make install

#完成上面步骤就算安装完成了. If the compilation fails, most of them are missing the compilation environment.


The next step is to test:

Command: "Nethogs NIC Device"
Detect EM1 Network card traffic usage (), run the command

[Email protected] src]# nethogs em1

The first line in the figure is the traffic record of the EM1 network card, indicating that the bandwidth of Em1 NIC is occupied by MySQL program.
In the PID column, you can use the Lsof-p PID to view the process.
or use "Lsof-i: Port number" To see which processes are in use.
such as view MySQL port lsof-i:3306

View server NIC traffic through Nethogs

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.