linux iftop命令的用法,使用iftop命令查看实时网络流量 、监控tcp与ip连接,iftop命令的安装过程、参数说明与应用实例。
在linux系统中可以使用top查看系统资源、进程、内存占用等信息。 若要查看实时的网络流量,监控TCP/IP连接等,则可以使用iftop或nethogs等~。
iftop命令工具的安装过程:
##下载##
[root@ipython ~]# wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-1.0pre4.tar.gz ##依赖安装## [root@ipython iftop-0.17]# yum install libpcap-devel ncurses-devel ##build iftop## [root@ipython ~]# tar zxf iftop-1.0pre4.tar.gz [root@ipython ~]# cd iftop-1.0pre4 [root@ipython iftop-1.0pre4]# ./configure && make && make install
直接运行:
[root@ipython iftop-0.17]# iftop
interface: eth0 IP address is: 107.170.243.66 MAC address is: 04:01:1d:04:bd:01 12.5Kb 25.0Kb 37.5Kb 50.0Kb 62.5Kb ^@qqqqqqqqqqqqqqqqq^@qqqqqqqqqqqqqqqqq^@qqqqqqqqqqqqqqqqq^@qqqqqqqqqqqqqqqqq^@qqqqqqqqqqqqqqqqqq 107.170.243.66 => 114.94.114.79 1.36Kb 1.58Kb 2.70Kb <= 160b 193b 252b 107.170.243.66 => 114.243.56.61 0b 0b 8.30Kb <= 0b 0b 282b 107.170.243.66 => 42.156.136.101 0b 0b 3.97Kb <= 0b 0b 247b 107.170.243.66 => google-public-dns-b.google.com 0b 0b 123b <= 0b 0b 212b 107.170.243.66 => resolver1.level3.net 0b 0b 18b <= 0b 0b 32b 107.170.243.66 => google-public-dns-a.google.com 0b 0b 18b <= 0b 0b 18b
TX:发送流量 RX:接收流量 | TOTAL:总流量
[root@ipython ~]# iftop --help
iftop: unknown option -- 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 帮助信息 -n 不解析主机名,直接显示IP -N 不给端口友好名字,直接显示端口号 -p 混杂模式 -b 流量单位 b -B 流量单位 B -i interface 指定网络接口 -f filter code 过滤数据包 -F net/mask show traffic flows in/out of IPv4 network -G net6/mask6 show traffic flows in/out of IPv6 network -l 查看ipv6流量 -P 显示端口信息 -m limit 设置界面最上边的刻度的最大值 -c config file 指定配置文件 -t 使用文本界面(比较有用的一个option) Sorting orders: -o 2s 按2s平均流量列排序 -o 10s 按10s平均流量列排序 -o 40s 按50s平均流量列排序 -o source 按源IP列排序 -o destination 按目的IP列排序 The following options are only available in combination with -t -s num 指定刷新几次 -L num 显示多少行数据。当程序多流量大时,则要显示行数多些才行 iftop, version 1.0pre4 copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors
[root@ipython ~]# iftop -Pp -Nn -t -L 100 -s 10 > awk_iftop.txt
interface: eth0 IP address is: 107.170.243.66 MAC address is: 04:01:1d:04:ffffffbd:01
awk处理iftop输出日志:
[root@ipython ~]# awk '/=[^=>]/{split($1,array,":");{print array[1],$4,$5}}' awk_iftop.txt|column -t
114.94.114.79 2.54Kb 2.54Kb 114.94.114.79 80b 80b (责任编辑:IT) |