Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况。它支持 IPv4 和 IPv6 协议、支持本地网卡及 PPP 链接。
可以查看进程占用的 cpu、内存等信息,可以随时监测占用最大 cpu 和内存的进程是哪个。
Nethogs 可以说是网络带宽 top,他可以查看进程占用的带宽信息,和 top 一样,随时刷新。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
[root@zabbix-server ~]
# tar -zxvf nethogs-0.8.0.tar.gz
[root@zabbix-server ~]
# ls
anaconda-ks.cfg Documents Downloads
install
.log.syslog nethogs Pictures Templates
Desktop download
install
.log Music nethogs-0.8.0.
tar
.gz Public Videos
[root@zabbix-server ~]
# cd nethogs
[root@zabbix-server nethogs]
# ls
Changelog conninode.cpp cui.h decpcap_test devices.cpp inode2prog.h nethogs.8 packet.cpp process.h refresh.cpp
connection.cpp conninode.h decpcap.c decpcap_test.cpp devices.h INSTALL nethogs.cpp packet.h README refresh.h
connection.h cui.cpp decpcap.h DESIGN inode2prog.cpp Makefile nethogs.h process.cpp README.decpcap.txt
[root@zabbix-server nethogs]
# yum -y install libpcap-devel
[root@zabbix-server nethogs]
# make
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 target
type
/usr/include/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.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 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 -lm
[root@zabbix-server nethogs]
# echo $?
0
[root@zabbix-server nethogs]
# make install
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/
[root@zabbix-server nethogs]
# nethogs -h
usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [device [device [device ...]]]
-V : prints version.
-d : delay
for
update refresh rate
in
seconds. default is 1.
-t : tracemode.
-b : bughunt mode - implies tracemode.
-p : sniff
in
promiscious mode (not recommended).
device : device(s) to monitor. default is eth0
When nethogs is running, press:
q: quit
m: switch between total and kb
/s
mode
|
监控界面:
本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1712740,如需转载请自行联系原作者