Nethogs, the latest network monitoring tool in CentOS
Nethogs is a network traffic monitoring tool on a terminal. It displays the bandwidth usage of each process, so that the network usage can be obtained more intuitively. It supports IPv4 and IPv6 protocols, local NICs, and PPP connections.
In some cases, the server sends a large number of packets to the external network, occupying a large amount of bandwidth, resulting in the impact of other servers. In the case of abnormal traffic, how can I view the bandwidth used by each process? You can use the nethogs tool to view details.
Of course, there are some other broadband analysis tools. You can learn more about them. I have a post on http:// OS .51cto.com/art/201404/435279.htm. Analysis by application is still quite common, So I generally use nethogs. The following describes how to install nethogs:
1. Download
Address: http://sourceforge.net/projects/nethogs/files/nethogs/
Download installation package: nethogs-0.8.0.tar.gz (38.0 kB)
2. Installation
Yum install ncurses *
Tar-zxvf nethogs-0.8.0.tar.gz
Cd nethogs
Make & make install
If the following error is reported:
[Root @ localhost nethogs] # make & make install
G ++-g-Wall-Wextra-c packet. cpp
G ++-g-Wall-Wextra-c connection. cpp
G ++-g-Wall-Wextra-c process. cpp
G ++-g-Wall-Wextra-c refresh. cpp
Refresh. cpp: 9: warning: unused parameter 'I'
Cc-g-Wall-Wextra-c decpcap. c
Decpcap. c: 7: 18: error: pcap. h: No such file or directory
In file encoded ded from decpcap. c: 8:
Decpcap. h: 34: error: expected specifier-qualifier-list before 'pcap _ t'
Decpcap. c: 14: error: expected ') 'before' *' token
Decpcap. c: In function 'dp _ open_offline ':
Decpcap. c: 48: error: 'pcap _ t' undeclared (first use in this function)
Decpcap. c: 48: error: (Each undeclared identifier is reported only once
Decpcap. c: 48: error: for each function it appears in .)
Decpcap. c: 48: error: 'temp 'undeclared (first use in this function)
Decpcap. c: 48: warning: implicit declaration of function 'pcap _ open_offline'
Decpcap. c: 55: warning: implicit declaration of function 'dp _ fillhandle'
Decpcap. c: In function 'dp _ open_live ':
Decpcap. c: 60: error: 'pcap _ t' undeclared (first use in this function)
Decpcap. c: 60: error: 'temp 'undeclared (first use in this function)
Decpcap. c: 60: warning: implicit declaration of function 'pcap _ open_live'
Decpcap. c: In function 'dp _ addcb ':
Decpcap. c: 74: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: In function 'dp _ parse_tcp ':
Decpcap. c: 84: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 86: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 87: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ parse_ip ':
Decpcap. c: 99: error: dereferencing pointer to incomplete type
Decpcap. c: 103: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 105: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 106: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ parse_ip6 ':
Decpcap. c: 126: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 128: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 129: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ parse_ethernet ':
Decpcap. c: 150: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 152: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 153: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ parse_ppp ':
Decpcap. c: 196: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 198: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 199: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ parse_linux_cooked ':
Decpcap. c: 238: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 240: error: 'struct dp_handle' has no member named 'callback'
Decpcap. c: 241: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: In function 'dp _ pcap_callback ':
Decpcap. c: 270: error: 'struct dp_handle' has no member named 'userdata _ size'
Decpcap. c: 271: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: 271: error: 'struct dp_handle' has no member named 'userdata _ size'
Decpcap. c: 273: error: 'struct dp_handle' has no member named 'linktype'
Decpcap. c: 274: error: 'dlt _ EN10MB 'undeclared (first use in this function)
Decpcap. c: 277: error: 'dlt _ PPP 'undeclared (first use in this function)
Decpcap. c: 280: error: 'dlt _ LINUX_SLL 'undeclared (first use in this function)
Decpcap. c: 283: error: 'dlt _ RAW 'undeclared (first use in this function)
Decpcap. c: 284: error: 'dlt _ null' undeclared (first use in this function)
Decpcap. c: 289: error: 'struct dp_handle' has no member named 'linktype'
Decpcap. c: In function 'dp _ dispatch ':
Decpcap. c: 296: error: 'struct dp_handle' has no member named 'userdata'
Decpcap. c: 297: error: 'struct dp_handle' has no member named 'userdata _ size'
Decpcap. c: 298: warning: implicit declaration of function 'pcap _ dispatch'
Decpcap. c: 298: error: 'struct dp_handle' has no member named 'pcap _ handle'
Decpcap. c: In function 'dp _ setnonblock ':
Decpcap. c: 302: warning: implicit declaration of function 'pcap _ setnonblock'
Decpcap. c: 302: error: 'struct dp_handle' has no member named 'pcap _ handle'
Decpcap. c: In function 'dp _ geterr ':
Decpcap. c: 307: warning: implicit declaration of function 'pcap _ geterr'
Decpcap. c: 307: error: 'struct dp_handle' has no member named 'pcap _ handle'
Make:*[Decpcap. o] Error 1
Execute Command
Yum install libpcap-dev * libncurses5-dev *
Then re-compile and install, as shown below:
[Root @ localhost nethogs] # make & make install
Cc-g-Wall-Wextra-c decpcap. c
Decpcap. c: In function 'dp _ open_live ':
Decpcap. c: 60: warning: passing argument 5 of 'pcap _ open_live 'discards qualifiers from pointer
/Usr/include/pcap. h: 349: note: expected 'Char'But argument is of type' const char'
G ++-g-Wall-Wextra-c cui. cpp-DVERSION = \ "0 \"-DSUBVERSION = \ "8 \"-DMINORVERSION = \ "0 \"
G ++-g-Wall-Wextra-c inode2prog. cpp
G ++-g-Wall-Wextra-c conninode. cpp
G ++-c-o devices. o devices. cpp
G ++-g-Wall-Wextra nethogs. cpp packet. o connection. o process. o refresh. o decpcap. o cui. o inodee. o devices. o-o nethogs-lpcap-lm-lncurses-DVERSION = \ "0 \"-DSUBVERSION = \ "8 \"-DMINORVERSION =
G ++-g-Wall-Wextra decpcap_test.cpp decpcap. o-o decpcap_test-lpcap-lm
Install-d-m 755/usr/local/sbin
Install-m 755 nethogs/usr/local/sbin
Install-d-m 755/usr/local/share/man/man8/
Install-m 644 nethogs.8/usr/local/share/man/man8/
The installation is successful. Enter the nethogs command to view the bandwidth usage of the application.
I opened two command windows for testing: