Http://www.vpser.net/manage/nethogs.html from. Last modified slightly
Before the VPS detective once introduced traffic bandwidth related tools such as: Iftop, Vnstat, these are statistics and monitoring network card traffic. But when the bandwidth of our servers or VPS is heavily occupied or full, there is no satisfactory tool or program to see how much bandwidth the program or process is occupying. Although there is a lot of software on Windows to see the bandwidth of the process, like a 3**, a Q home computer steward, IP radar and so on. But this kind of software is very rare under Linux, today we are looking at a Linux view process bandwidth network consumption of software: Nethogs.
Installation
Debian/ubuntu installation is simple, execute:apt-get install nethogs can be installed.
Centos/rhel is recommended to install the Epel first, then perform:yum install Libpcap nethogs .
Specific Use parameter description:
[Email protected] ~]# nethogs-h
Usage:nethogs [-v] [-b] [-D seconds] [-t] [-p] [device [device [device]]] Nethogs parameters that can be used
-v:prints version.//Print version information
-d:delay for update, refresh rate in seconds. Default is 1. Delay refresh time, unit seconds, default 1 seconds
-t:tracemode. Tracking mode
-b:bughunt mode-implies TraceMode. Bughunt mode
-p:sniff in promiscious mode (not recommended). Sniffing in mixed mode, not recommended
Device:device (s) to monitor. The default is eth0//listening device, which is eth0, that is, the network card device name, if OpenVZ VPS is generally venet0, specifically can be ifconfig to view, Lo for the local loopback, not used. Multiple network cards can be written on a piece, separated by spaces.
When Nethogs is running, press://nethogs operation is possible with the following keys
Q:quit//Run, press the Q key to exit
M:switch between Total and kb/s mode//press M to toggle units or show process usage or traffic that has been counted. The switching order is KB/SEC->KB->B->MB
R:sort by received. Sort by received
S:sort by sent. Sort by send
Use example:nethogs venet0
For example, the PID column is the process of Pid,program is to show the process or the port number of the connection, the front red box is the server's IP: port, the red box is the client's IP: port, according to the port can be judged, there are currently 7700 ports, If you do not know which process the port corresponds to, you can view it through lsof. Lsof-i: The occupied port number such as: lsof-i:80
The Dev column displays the device name, send is the traffic sent by the server, and the traffic received by the received server. //press M to toggle statistics: Traffic speed kb/sec or total {kb/b/m}
Linux process/Program network bandwidth Usage view Tool--nethogs