Use NetHogs in CentOS6.5 to monitor network usage of processes

Source: Internet
Author: User
Tags net bug

Use NetHogs in CentOS6.5 to monitor network usage of processes

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.

Download:

Download nethogs-0.8.0.tar.gz from sourceforge.

Download with wget:

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

Installation:

Before installation, yum install ncurses *

[root@localhost Desktop]# yum install ncurses*Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.skyshe.cn * extras: mirrors.skyshe.cn * updates: mirrors.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 will be installed---> Package ncurses-static.x86_64 0:5.7-3.20090208.el6 will be installed---> Package ncurses-term.x86_64 0:5.7-3.20090208.el6 will 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:06     Running 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.el6.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-devel.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!
Decompress the file:

Tar-zxvf nethogs-0.8.0.tar.gz

Switch directory:

Cd nethogs

Compile and install:

Make & make install

Make error:

[root@localhost 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 before ‘pcap_t’decpcap.c:14: error: expected ‘)’ before ‘*’ tokendecpcap.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 oncedecpcap.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 typedecpcap.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
If the dependency is still missing, run the following command to install it:

Yum install libpcap-dev libncurses5-dev

[root@localhost 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[root@localhost nethogs]# yum  -y install libpcap-devel  ncurses-develLoaded plugins: fastestmirror, 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 will be installed--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================================================================================================== Package                                      Arch                                  Version                                                          Repository                           Size===============================================================================================================================================================================================Installing: libpcap-devel                                x86_64                                14:1.4.0-1.20130826git2dbcaa1.el6                                base                                114 kTransaction Summary===============================================================================================================================================================================================Install       1 Package(s)Total download size: 114 kInstalled size: 160 kDownloading Packages:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64.rpm                                                                                                                 | 114 kB     00:00     Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction  Installing : 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!
Run make & make install again.
[Root @ localhost nethogs] # make & make installcc-g-Wall-Wextra-c decpcap. cdecpcap. c: In function 'dp _ open_live ': decpcap. c: 60: warning: passing argument 5 of 'pcap _ open_live 'discards qualifiers from pointer target type/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. 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 755 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!

Run: nethogs

[root@localhost 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: root@pts/2                                                                                                                            eth0       0.666  0.059 KB/sec?     root     unknown TCP                                                                                                                                            0.000  0.000 KB/sec  TOTAL                                                                                                                                                               0.666       0.059 KB/sec 

Displays the current network usage of each process:

Help:

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD48cHJlIGNsYXNzPQ = "brush: java;"> [root @ localhost ~] # Nethogs -- helpnethogs: invalid option -- '-' usage: nethogs [-V] [-B] [-d seconds] [-t] [-p] [device [device [device...] -V: The version information is displayed. Note that the uppercase letter is V. -d: The refresh rate of delayed updates, in seconds. The default value is 1. -t: tracking mode. -B: bug hunting mode--Indicates tracking mode. -p: Mixed Mode (not recommended ). device: the name of the device to be monitored. the default value is eth0. When nethogs is running, switch between: q: Exit m: Total and current usage mode

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.