iftop 流量监控

来源:互联网 发布:九天网络 编辑:程序博客网 时间:2024/05/21 04:00

微服务框架下,网络IO对于应用性能的影响十分明显,因此堆网络流量的监控很有意义。在linux环境下,可以通过iftop来监控网络流量使用情况。

安装

ubuntu & debian

本文在ubuntu server16.04环境下,使用国内163镜像源,可以通过apt install iftop安装iftop命令:

root@ubuntu:~# apt install iftopReading package lists... DoneBuilding dependency tree       Reading state information... DoneThe following NEW packages will be installed:  iftop0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.Need to get 35.2 kB of archives.After this operation, 91.1 kB of additional disk space will be used.Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial/universe amd64 iftop amd64 1.0~pre4-3 [35.2 kB]Fetched 35.2 kB in 0s (79.3 kB/s)Selecting previously unselected package iftop.(Reading database ... 210315 files and directories currently installed.)Preparing to unpack .../iftop_1.0~pre4-3_amd64.deb ...Unpacking iftop (1.0~pre4-3) ...Processing triggers for man-db (2.7.5-1) ...Setting up iftop (1.0~pre4-3) ...root@ubuntu:~# iftopinterface: enp0s3IP address is: 192.168.1.103MAC address is: 08:00:27:e4:ff:a4root@ubuntu:~# 

RedHat & CentOS

方法一:配置EPEL源,然后通过命令yum -y install iftop安装
方法二;源码安装

  1. 安装依赖包:yum install flex byacc libpcap ncurses ncurses-devel libpcap-devel
  2. 从iftop官网下载源码到本地并解压
  3. ./configure
  4. make && make install

使用

运行,直接执行iftop,效果如下
这里写图片描述
界面上面显示的是类似刻度尺的刻度范围,为显示流量图形的长条作标尺用的。

中间的<= =>这两个左右箭头,表示的是流量的方向。TX:发送流量RX:接收流量TOTAL:总流量Cumm:运行iftop到目前时间的总流量peak:流量峰值rates:分别表示过去 2s 10s 40s 的平均流量

常用参数

 -i设定监测的网卡,如:# iftop -i eth1 -B 以bytes为单位显示流量(默认是bits),如:# iftop -B -n使host信息默认直接都显示IP,如:# iftop -n -N使端口信息默认直接都显示端口号,如: # iftop -N -F显示特定网段的进出流量,如# iftop -F 10.10.1.0/24或#      iftop -F 10.10.1.0/255.255.255.0 -h(display this message),帮助,显示参数信息 -p使用这个参数后,中间的列表显示的本地主机信息,出现了本机以外的IP信息; -b使流量图形条默认就显示; -P使host信息及端口信息默认就都显示; -m设置界面最上边的刻度的最大值,刻度分五个大段显示,例:# iftop -m 100M
0 0