首页 » Linux » CentOS » Linux实时流量监控工具iftop

Linux实时流量监控工具iftop

 

iftop用来监控流量的工具,可以用来监控网卡的实时流量,指定网段、反解IP、显示端口信息等。

官网:http://www.ex-parrot.com/~pdw/iftop/

iftop的安装

这里只介绍rpm包的方式,方便快捷,下面是两个iftop包,直接wget后,执行yum安装即可(两个包32和64,根据需求下载)。

wget http://blog.whsir.com/uploads/iftop-0.16-0.i386.rpm

wget http://blog.whsir.com/uploads/iftop-0.17-1.el6.rf.x86_64.rpm

iftop

TX,发送流量;

RX,接收流量;

TOTAL,总流量;

Cumm,运行iftop期间流量;

peak,流量峰值;

rates,分别代表2秒、10秒、40秒的平均流量

iftop的选项:

常用选项-n -i -m

-h display this message 帮助

-n don't do hostname lookups 不做主机名查找(直接显示IP)

-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 以bytes 为单位显示流量(默认是bits)

-i interface listen on named interface 指定监听的网卡。例:iftop -i eth1

-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 network 显示特定网段的进出流量 如# iftop -F 192.168.1.5/24或# iftop -F 192.168.1.5/255.255.255.0

-P show ports as well as hosts 显示端口及主机

-m limit sets the upper limit for the bandwidth scale 设置iftop界面最上面的刻度最大值,刻度分五个大段显示,例:# iftop -m 10M

-c config file specifies an alternative configuration file 指定配置文件(不清楚怎么用)

进入iftop后的一些操作命令

常用命令nsdtpPN

n - toggle DNS host resolution 和-n一样作用

s - toggle show source host 切换显示源主机,是否显示自己主机的IP

d - toggle show destination host 切换显示目标主机,就是右边的IP屏蔽掉

t - cycle line display mode 切换显示格式多一行/只显示发送流量/只显示接收流量

 

N - toggle service resolution 切换显示端口号或端口名称

S - toggle show source port 切换显示本机端口信息

D - toggle show destination port 切换显示目标端口信息

p - toggle port display 切换显示所有端口信息(相当于S和D的合并)

 

P - pause display 切换暂停/继续显示

h - toggle this help display 显示帮助

b - toggle bar graph display 切换显示上面刻度

B - cycle bar graph average 切换计算2秒或10秒或40秒内的平均流量

T - toggle cummulative line totals 切换显示每个连接总流量

j/k - scroll display 上下滚动

f - edit filter code 过滤,不知道怎么用

l - set screen filter 过滤,不知道怎么用

L - lin/log scales 切换显示最上面那个刻度

! - shell command 可以使用shell命令,感觉没啥用

q - quit 退出

 

< - sort by source name 排序

> - sort by dest name 排序

o - freeze current order 固定只显示当前连接

1/2/3 - sort by 1st/2nd/3rd column 不知道干啥的

总结:用不上的命令很多,记住常用的几个就可以了。

原文链接:Linux实时流量监控工具iftop,转载请注明来源!

5