iftop统计流量工具及安装过程_服务器

TX:发送流量
RX:接收流量
TOTAL:总流量
Cumm:运行iftop到目前时间的总流量
peak:流量峰值
rates:分别表示过去 2s 10s 40s 的平均流量


第一行:带宽显示

中间部分:外部连接列表,即记录了哪些ip正在和本机的网络连接

 中间部分右边:实时参数分别是该访问ip连接到本机2秒,10秒和40秒的平均流量

 =>代表发送数据,<= 代表接收数据

 底部三行:表示发送,接收和全部的流量

 底部三行第二列:为你运行iftop到目前流量

 底部三行第三列:为高峰值

 底部三行第四列:为平均值

操作

进入iftop画面后的一些操作命令(注意大小写)

 按h切换是否显示帮助;

 按n切换显示本机的IP或主机名;

 按s切换是否显示本机的host信息;

 按d切换是否显示远端目标主机的host信息;

 按t切换显示格式为2行/1行/只显示发送流量/只显示接收流量;

 按N切换显示端口号或端口服务名称;

 按S切换是否显示本机的端口信息;

 按D切换是否显示远端目标主机的端口信息;

 按p切换是否显示端口信息;

 按P切换暂停/继续显示;

 按b切换是否显示平均流量图形条;

 按B切换计算2秒或10秒或40秒内的平均流量;

 按T切换是否显示每个连接的总流量;

 按l打开屏幕过滤功能,输入要过滤的字符,比如ip,按回车后,屏幕就只显示这个IP相关的流量信息;

 按L切换显示画面上边的刻度;刻度不同,流量图形条会有变化;

 按j或按k可以向上或向下滚动屏幕显示的连接记录;

 按1或2或3可以根据右侧显示的三列流量数据进行排序;

 按<根据左边的本机名或IP排序;

 按>根据远端目标主机的主机名或IP排序;

 按o切换是否固定只显示当前的连接;

 按f可以编辑过滤代码,这是翻译过来的说法,我还没用过这个!

 按!可以使用shell命令,

 按q退出监控。


下载安装连接:​​​​http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz​

安装操作

安装依赖包:yum install flex byacc libpcap ncurses ncurses-devel libpcap-devel
tar zxvf iftop-0.17.tar.gz
cd iftop-0.17
./configure
make && make install

显示过程

[root@prod-nginx-a iftop-0.17]# ls
aclocal.m4 cfgfile.h dlcommon.h iftop.c Makefile.am ppp.h sll.h TODO
addr_hash.c ChangeLog edline.c iftop.cat Makefile.in README sorted_list.c token.h
addr_hash.h config ether.h iftop.h Makefile.OLD resolver.c sorted_list.h ui.c
addrs_dlpi.c config.h.in ethertype.h iftop.spec NEWS resolver.h stringmap.c ui.h
addrs_ioctl.c configure extract.h INSTALL ns_hash.c screenfilter.c stringmap.h util.c
AUTHORS configure.in hash.c integers.h ns_hash.h screenfilter.h tcp.h vector.c
bootstrap COPYING hash.h ip.h options.c serv_hash.c threadprof.c vector.h
cfgfile.c dlcommon.c iftop.8 llc.h options.h serv_hash.h threadprof.h
[root@prod-nginx-a iftop-0.17]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets ${MAKE}... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking sys/dlpi.h usability... no
checking sys/dlpi.h presence... no
checking for sys/dlpi.h... no
checking for regcomp... yes
checking for select... yes
checking for strdup... yes
checking for strerror... yes
checking for strspn... yes
checking for library containing socket... none required
checking for library containing log... -lm
checking for gethostbyname... yes
checking for library containing inet_aton... none required
checking for library containing inet_pton... none required
checking for inet_aton... yes
checking for inet_pton... yes
checking size of u_int8_t... 1
checking size of u_int16_t... 2
checking size of u_int32_t... 4
checking for library containing getnameinfo... none required
checking for library containing gethostbyaddr_r... none required
checking how to call gethostbyaddr_r... 8 args, int return
checking gethostbyaddr_r usability... yes
checking where to find pcap.h... /include
checking for pcap_open_live in -lpcap... yes
checking pcap.h usability... yes
checking pcap.h presence... yes
checking for pcap.h... yes
checking for a curses library containing mvchgat... -lcurses
checking POSIX threads compilation... CFLAGS= and LIBS=-lpthread
checking POSIX threads usability... yes
checking if we need to enable promiscuous mode by default... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@prod-nginx-a iftop-0.17]# make && make install
make all-recursive
make[1]: Entering directory `/root/iftop-0.17'
Making all in config
make[2]: Entering directory `/root/iftop-0.17/config'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/iftop-0.17/config'
make[2]: Entering directory `/root/iftop-0.17'
source='addr_hash.c' object='addr_hash.o' libtool=no \
depfile='.deps/addr_hash.Po' tmpdepfile='.deps/addr_hash.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'addr_hash.c' || echo './'`addr_hash.c
source='edline.c' object='edline.o' libtool=no \
depfile='.deps/edline.Po' tmpdepfile='.deps/edline.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'edline.c' || echo './'`edline.c
source='hash.c' object='hash.o' libtool=no \
depfile='.deps/hash.Po' tmpdepfile='.deps/hash.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'hash.c' || echo './'`hash.c
source='iftop.c' object='iftop.o' libtool=no \
depfile='.deps/iftop.Po' tmpdepfile='.deps/iftop.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'iftop.c' || echo './'`iftop.c
source='ns_hash.c' object='ns_hash.o' libtool=no \
depfile='.deps/ns_hash.Po' tmpdepfile='.deps/ns_hash.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'ns_hash.c' || echo './'`ns_hash.c
source='options.c' object='options.o' libtool=no \
depfile='.deps/options.Po' tmpdepfile='.deps/options.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'options.c' || echo './'`options.c
source='resolver.c' object='resolver.o' libtool=no \
depfile='.deps/resolver.Po' tmpdepfile='.deps/resolver.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'resolver.c' || echo './'`resolver.c
source='screenfilter.c' object='screenfilter.o' libtool=no \
depfile='.deps/screenfilter.Po' tmpdepfile='.deps/screenfilter.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'screenfilter.c' || echo './'`screenfilter.c
source='serv_hash.c' object='serv_hash.o' libtool=no \
depfile='.deps/serv_hash.Po' tmpdepfile='.deps/serv_hash.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'serv_hash.c' || echo './'`serv_hash.c
source='sorted_list.c' object='sorted_list.o' libtool=no \
depfile='.deps/sorted_list.Po' tmpdepfile='.deps/sorted_list.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'sorted_list.c' || echo './'`sorted_list.c
source='threadprof.c' object='threadprof.o' libtool=no \
depfile='.deps/threadprof.Po' tmpdepfile='.deps/threadprof.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'threadprof.c' || echo './'`threadprof.c
source='ui.c' object='ui.o' libtool=no \
depfile='.deps/ui.Po' tmpdepfile='.deps/ui.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'ui.c' || echo './'`ui.c
source='util.c' object='util.o' libtool=no \
depfile='.deps/util.Po' tmpdepfile='.deps/util.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'util.c' || echo './'`util.c
source='addrs_ioctl.c' object='addrs_ioctl.o' libtool=no \
depfile='.deps/addrs_ioctl.Po' tmpdepfile='.deps/addrs_ioctl.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'addrs_ioctl.c' || echo './'`addrs_ioctl.c
source='addrs_dlpi.c' object='addrs_dlpi.o' libtool=no \
depfile='.deps/addrs_dlpi.Po' tmpdepfile='.deps/addrs_dlpi.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'addrs_dlpi.c' || echo './'`addrs_dlpi.c
source='dlcommon.c' object='dlcommon.o' libtool=no \
depfile='.deps/dlcommon.Po' tmpdepfile='.deps/dlcommon.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'dlcommon.c' || echo './'`dlcommon.c
source='stringmap.c' object='stringmap.o' libtool=no \
depfile='.deps/stringmap.Po' tmpdepfile='.deps/stringmap.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'stringmap.c' || echo './'`stringmap.c
source='cfgfile.c' object='cfgfile.o' libtool=no \
depfile='.deps/cfgfile.Po' tmpdepfile='.deps/cfgfile.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'cfgfile.c' || echo './'`cfgfile.c
source='vector.c' object='vector.o' libtool=no \
depfile='.deps/vector.Po' tmpdepfile='.deps/vector.TPo' \
depmode=gcc3 /bin/sh ./config/depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f 'vector.c' || echo './'`vector.c
gcc -g -O2 -o iftop addr_hash.o edline.o hash.o iftop.o ns_hash.o options.o resolver.o screenfilter.o serv_hash.o sorted_list.o threadprof.o ui.o util.o addrs_ioctl.o addrs_dlpi.o dlcommon.o stringmap.o cfgfile.o vector.o -lpcap -lm -lcurses -lpthread
make[2]: Leaving directory `/root/iftop-0.17'
make[1]: Leaving directory `/root/iftop-0.17'
Making install in config
make[1]: Entering directory `/root/iftop-0.17/config'
make[2]: Entering directory `/root/iftop-0.17/config'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/iftop-0.17/config'
make[1]: Leaving directory `/root/iftop-0.17/config'
make[1]: Entering directory `/root/iftop-0.17'
make[2]: Entering directory `/root/iftop-0.17'
/bin/sh ./config/mkinstalldirs /usr/local/sbin
/bin/install -c iftop /usr/local/sbin/iftop
/bin/sh ./config/mkinstalldirs /usr/local/man/man8
mkdir -p -- /usr/local/man/man8
/bin/install -c -m 644 ./iftop.8 /usr/local/man/man8/iftop.8
make[2]: Leaving directory `/root/iftop-0.17'
make[1]: Leaving directory `/root/iftop-0.17'

安装完成后

iftop统计流量工具及安装过程_流量统计_02