网络实时流量监测工具iftop

来源:互联网 发布:python 字符串split 编辑:程序博客网 时间:2024/05/18 00:36

iftop是一个免费的网卡实时流量监控工具,类似于linux下的top命令。iftop可以做哪些事情呢

1.监控指定网卡的实时流量,端口连接信息,反向解析ip等

2.精确显示本机网络流量情况及网络内各主机与本机相互通信的流量集合,适合于监控代理服务器或路由器的网络情况

3.对监测流量异常的主机非常有效

iftop的安装非常简单,其官方网站为http://www.ex-parrot.com/pwd/iftop/ ,下面以cent os为例

yum install libpcap libpcap-devel ncurses ncurses-devel -yyum install flex byacc wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpmyum install -y iftop

使用介绍

执行"  iftop -P -i ens33  " 命令,得到如下图一个经典输出界面



iftop的输出大致可以为三大部分,

第一部分是最上面一行,此行信息是流量刻度,用于显示网卡带宽流量

第二部分是输出在中间部分,其中=>代表发送数据 <=代表接收数据

第三部分最下面,其中TX代表发送数据 RX代表接收数据,TOTAL代表发送和接收的全部流量,CUM 代表命令开始时到现在的总流量,peak代表各项流量峰值,rates代表2s,10s,40s内平均流量值


iftop常用参数

[root@www ~]# iftop -h
iftop: display bandwidth usage on an interface by host


Synopsis: iftop -h | [-npblNBP] [-i interface] [-f filter code]
                               [-F net/mask] [-G net6/mask6]


   -h                  display this message
   -n                  don't do hostname lookups
   -N                  don't convert port numbers to services
   -p                  run in promiscuous mode (show traffic between other
                       hosts on the same network segment)
   -b                  don't display a bar graph of traffic
   -B                  Display bandwidth in bytes
   -i interface        listen on named interface
   -f filter code      use filter code to select packets to count
                       (default: none, but only IP packets are counted)
   -F net/mask         show traffic flows in/out of IPv4 network
   -G net6/mask6       show traffic flows in/out of IPv6 network
   -l                  display and count link-local IPv6 traffic (default: off)
   -P                  show ports as well as hosts
   -m limit            sets the upper limit for the bandwidth scale
   -c config file      specifies an alternative configuration file
   -t                  use text interface without ncurses


   Sorting orders:
   -o 2s                Sort by first column (2s traffic average)
   -o 10s               Sort by second column (10s traffic average) [default]
   -o 40s               Sort by third column (40s traffic average)
   -o source            Sort by source address
   -o destination       Sort by destination address


   The following options are only available in combination with -t
   -s num              print one single text output afer num seconds, then quit
   -L num              number of lines to print


iftop, version 1.0pre4
copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors

常用的交互参数及含义

参数 含义 
 P 通过此键可切换暂停/继续显示 
 h 通过此键可在交互参数界面/状态输出界面之间来回切换
 b 通过此键可切换是否显示平均流量图形条
 B 通过此键可切换显示2秒、10秒、40秒内的平均流量
 T 通过此键可切换是否显示每个连接的总流量
 j/k 按j键或k键可以向上或向下滚动屏幕显示当前的连接信息
 l 通过此键可打开iftop输出过滤功能,比如输入要显示的IP,按回车后,屏幕就只显示与这个IP 相关的流量信息
 L 通过此键可切换显示流量刻度范围,刻度不同,流量图形条会跟着变化
 q 通过此键可退出iftop流量监控界面
 n 通过此键可使iftop输出结果以IP或主机名的方式显示
 s 通过此键可切换是否显示源主机信息
 d 通过此键可切换是否显示远端目标主机信息
 t 通过此键可切换iftop显示格式,连续按此键可依次显示:以两行方式显示发送接收流量、以一行方式显示发送接收流量、只显示发送流量/只显示接收流量
 N 通过此键可切换显示端口号/端口号对应服务名称
 S 通过此键可切换是否显示本地源主机的端口信息
 D 通过此键可切换是否显示远端目标主机的端口信息
 p 通过此键可切换是否显示端口信息 < 通过此键可根据左边的本地主机名或IP地址进行排序 > 通过此键可根据远端目标主机的主机名或IP地址进行排序
 o 通过此键可切换是否固定显示当前的连接








原创粉丝点击