CentOS6.5 using Nethogs to monitor the network usage of the process

Source: Internet
Author: User
Tags net bug uppercase letter

The nethogs is a network traffic monitoring tool under the terminal, which is unique in that it can show the bandwidth consumption of each process, which makes it more intuitive to obtain network usage. It supports IPV4 and IPV6 protocols, supports local network cards, and PPP links.

Download:

Download nethogs-0.8.0.tar.gz from SourceForge

Download using wget:

wget http://sourceforge.net/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download

Installation:

you need to  yum install ncurses*

before installing

[[email protected] desktop]# yum install ncurses*loaded plugins:fastestmirror, Refresh-packagekit, Securityloading mirror speeds from cached Hostfile * base:mirrors.skyshe.cn * extras:mirrors.skyshe.cn * updates:mirror S.skyshe.cnsetting up Install processpackage ncurses-5.7-3.20090208.el6.x86_64 already installed and latest Versionpackage ncurses-libs-5.7-3.20090208.el6.x86_64 already installed and latest Versionpackage Ncurses-base-5.7-3.20090208.el6.x86_64 already installed and latest versionresolving dependencies--> Running Transaction Check---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 'll be a installed---> package Ncurses-static.x86_64 0:5.7-3.20090208.el6 'll be installed---> Package ncurses-term.x86_64 0:5.7-3.20090208.el6 'll be installed--> finished Dependency resolutiondependencies resolved========================================= =============================================================================================================== ================ Package Arch Version Repository size================================================================ ========================================================================================================installing                                : Ncurses-devel x86_64 5.7-3.20090208.el6                             Base 642 K ncurses-static x86_64                               5.7-3.20090208.el6 Base 546 K ncurses-term                             x86_64 5.7-3.20090208.EL6 Base 547 ktransaction summary======================================================================================== ================================================================================install 3 Package (s) total download size:1.7 minstalled size:6.8 MIs                                                                                               This OK [y/n]: ydownloading Packages: (1/3): ncurses-devel-5.7-3.20090208.el6.x86_64.rpm |                                                                                              642 KB 00:01 (2/3): ncurses-static-5.7-3.20090208.el6.x86_64.rpm |                                                                                                546 KB 00:00 (3/3): ncurses-term-5.7-3.20090208.el6.x86_64.rpm | 547 KB 00:02----------------------------------------------------------------------------------------------------                                                                                                                                   --------------------------------------------------------------------Total 284 kb/s |     1.7 MB 00:06Running rpm_check_debugrunning Transaction testtransaction Test succeededrunning Transaction Installing:                                                                                                              Ncurses-devel-5.7-3.20090208.el6.x86_64                                                                                                             1/3 installing:ncurses-static-5.7-3.20090208.el6.x86_64 2/3 Installing:ncurses-term-5.7-3.20090208.el    6.x86_64 3/3                                                                                                               Verifying:ncurses-term-5.7-3.20090208.el6.x86_64                                                                                                             1/3 verifying:ncurses-static-5.7-3.20090208.el6.x86_64 2/3 verifying:ncurses-devel-              5.7-3.20090208.el6.x86_64                                                                                                3/3 Installed:ncurses-de vel.x86_64 0:5.7-3.20090208.el6 ncurses-static.x86_64 0:5.7-3.20090208.el6 ncurses-term.x86_64 0 : 5.7-3.20090208.el6 complete!
Unzip the file:

TAR-ZXVF nethogs-0.8.0.tar.gz

To switch directories:

CD Nethogs

Compile and install:

Make && make install

Make made an error:

[[email protected] nethogs]# make && make Installcc-g-wall-wextra-c decpcap.cdecpcap.c:7:18:error:pcap. H:no such file or Directoryin file included from decpcap.c:8:decpcap.h:34:error:expected specifier-qualifier-list befor  E ' pcap_t ' decpcap.c:14:error:expected ') ' before ' * ' tokendecpcap.c:in function ' Dp_open_offline ':d ecpcap.c:48:error: ' pcap_t ' undeclared (first use with this function) Decpcap.c:48:error: (each undeclared identifier was reported only Oncedec Pcap.c:48:error:for each function it appears in.)  Decpcap.c:48:error: ' Temp ' undeclared (first use with 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 ':d ecpcap.c:60:error: ' pcap_t ' undeclared (first use of this function) Decpcap.c:60:error: ' Temp ' undeclared (fi RST use on this function) Decpcap.c:60:warning:implicit declaration of function ' pcap_open_live ' Decpcap.c:in function ' DP_ADDCB ':d ecpcap.c:74:error: ' struct dp_handle ' has no member named ' Callback ' Decpcap.c:in functio N ' dp_parse_tcp ':d ecpcap.c:84:error: ' struct dp_handle ' has no member named ' Callback ' Decpcap.c:86:error: ' struct Dp_han Dle ' has no member named ' Callback ' Decpcap.c:87:error: ' struct dp_handle ' have no member named ' UserData ' decpcap.c:in fun Ction ' dp_parse_ip ':d ecpcap.c:99:error:dereferencing pointer to incomplete typedecpcap.c:103:error: ' struct DP_ Handle ' have 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 ':d ecpcap.c:126:error: ' str UCT Dp_handle ' have no member named ' Callback ' Decpcap.c:128:error: ' struct dp_handle ' has no member named ' Callback ' DECPCA P.c:129:error: ' struct dp_handle ' has no member named ' UserData ' decpcap.c:in function ' dp_parse_ethernet ':d ecpcap.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: ' str UCT Dp_handle ' has no member named ' UserData ' decpcap.c:in function ' dp_parse_ppp ':d ecpcap.c:196:error: ' struct dp_handle ' Have no member named ' Callback ' Decpcap.c:198:error: ' struct dp_handle ' has no member named ' Callback ' Decpcap.c:199:erro R: ' struct Dp_handle ' has no member named ' UserData ' decpcap.c:in function ' dp_parse_linux_cooked ':d ecpcap.c:238:error: ' struct Dp_handle ' have no member named ' Callback ' Decpcap.c:240:error: ' struct dp_handle ' has no member named ' Callback ' Dec Pcap.c:241:error: ' struct dp_handle ' has no member named ' UserData ' decpcap.c:in function ' dp_pcap_callback ':d ecpcap.c:2 70:error: ' struct dp_handle ' has no member named ' Userdata_size ' decpcap.c:271:error: ' struct dp_handle ' have no member NA Med ' 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 with this function) Decpcap.c:277:error: ' DLT_PPP ' un Declared (first use of this function) Decpcap.c:280:error: ' Dlt_linux_sll ' undeclared (first use of this function) Decpcap. C:283:error: ' Dlt_raw ' undeclared (first use with this function) Decpcap.c:284:error: ' Dlt_null ' undeclared (first use in t His function) Decpcap.c:289:error: ' struct dp_handle ' have no member named ' Linktype ' decpcap.c:in function ' Dp_dispatch ':d Ecpcap.c:296:error: ' struct dp_handle ' has no member named ' UserData ' decpcap.c:297:error: ' struct dp_handle ' have no memb Er 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 ':d ecpcap.c:302:warning:implic It declaration of function ' Pcap_setnonblock ' decpcap.c:302:error: ' struct dp_handle ' has no member named ' Pcap_handle ' Dec pcap.c:in function ' Dp_geteRR ':d ecpcap.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
Or a lack of dependencies, execute the following command to install:

Yum Install Libpcap-dev Libncurses5-dev

[[email protected] nethogs]# yum install Libpcap-dev libncurses5-devloaded plugins:fastestmirror, Refresh-packagekit, securityloading mirror speeds from cached Hostfile * base:mirrors.skyshe.cn * extras:mirrors.skyshe. CN * Updates:mirrors.skyshe.cnSetting up Install Processno package Libpcap-dev available. No Package Libncurses5-dev available. Error:nothing to do[[email protected] nethogs]# yum-y install libpcap-devel ncurses-develloaded plugins:fastestm Irror, Refresh-packagekit, securityloading mirror speeds from cached Hostfile * base:mirrors.skyshe.cn * extras:mirrors. skyshe.cn * updates:mirrors.skyshe.cnSetting up Install processpackage ncurses-devel-5.7-3.20090208.el6.x86_64 Already installed and latest versionresolving dependencies--> Running transaction Check---> Package Libpcap-devel.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6 'll be installed--> finished Dependency Resolutiondependencies resolved======================================================================================================================================================================                                                          ========================= Package Arch Version Repository size============================= ===============================================================================================================                                ===================================================installing:libpcap-devel x86_64                                14:1.4.0-1.20130826GIT2DBCAA1.EL6 Base Ktransaction summary========================================================================================       =======================================================================================================install 1 package (s) total download size:114 kinstalled size:160Kdownloading packages:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64.rpm | KB 00:00 Running rpm_check_debugrunning Transaction testtransaction Test succeededrunning Transaction Install                                                                                                                      Ing:14:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64 1/1 verifying:14:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6                                                                                                                      . x86_64                                                                                                                       1/1 installed:libpcap-devel.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6 complete!
Re-execution:Make && make install
[[email protected] nethogs]# make && make installcc-g-wall-wextra-c decpcap.cdecpcap.c:in function ' dp_open_l Ive ':d ecpcap.c:60:warning:passing argument 5 of ' pcap_open_live ' discards qualifiers from pointer target Type/usr/includ e/pcap/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.cppg++-g-wall-wextra-c conninode.cppg + +-c-o devices.o devices.cppg++-g-wall-wextra nethogs.cpp packet.o connection.o process.o refresh.o decpcap.o Cui. o inode2prog.o conninode.o devices.o-o nethogs-lpcap-lm-lncurses-dversion=\ "0\"-dsubversion=\ "8\"-DMINORVERSION=\ " 0\ "g++-g-wall-wextra decpcap_test.cpp decpcap.o-o decpcap_test-lpcap-lminstall-d-M 755/usr/local/sbininstall-m 7 Nethogs/usr/local/sbininstall-d-M 755/usr/local/share/man/man8/install-m 644 NETHOGS.8/USR/LOCAL/SHARE/MAN/MAN8 /
The installation is successful!

Execution: Nethogs

[Email protected] nethogs]# nethogswaiting for first packet to arrive (see SourceForge.net bug 1019381) nethogs version 0.                                                                                                                                     8.0 PID USER Program                                                                                                                            DEV SENT RECEIVED 3227 root sshd: [email PROTECTED]/2       Eth0     0.666 0.059 kb/sec?                                                                                                                                            Root Unknown TCP                                                                                                                                                               0.000 0.000 kb/sec Total 0.666 0.059 kb/ Sec

Shows the current network usage of each process:


Press "M" key to switch to the statistics view to show the total network usage of each process


Press "CTRL + C" or "Q" to exit the monitor

Use Help:

[Email protected] ~]# nethogs--helpnethogs:invalid Option--'-' usage:nethogs [-v] [-b] [-D seconds] [-t] [-p] [device [Device [device ...]] -V: Displays the version information, note the uppercase letter v.-d: The delay update refresh rate, in seconds. The default value is 1.-T: Trace mode.-b:bug Hunting mode-means tracking mode.-P: Mixed mode (not recommended). Device: The name of the device to monitor. Default is eth0 when Nethogs is running, press: Q: Exit M: Total and current usage mode toggle between

CentOS6.5 using Nethogs to monitor the network usage of the process

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.