文章目录

  • ifstat
  • iftop

ifstat

Ifstat is a little tool to report interface activity,
just like iostat/vmstat do for other system statistics.
  • ifstat 工具是个网络接口监测工具,比较简单看网络流量
    默认的使用方式:ifstat
andrew@andrew-Thurley:~$ ifstatenp4s0             wlp3s0b1     KB/s in  KB/s out   KB/s in  KB/s out0.00      0.00      2.29     28.130.00      0.00      0.64      0.000.00      0.00      0.77      0.000.00      0.00      0.64      0.09
ifstat 默认不监测环回接口的数据,监测所有网络接口的时候使用:ifstat -a

andrew@andrew-Thurley:~$ ifstat -alo                enp4s0             wlp3s0b1     KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out0.00      0.00      0.00      0.00      0.56      1.310.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.00      0.00      0.00      0.00

ifstat -l监听含有环回地址的网卡活跃流量

andrew@andrew-Thurley:~$ ifstat -llo                enp4s0             wlp3s0b1     KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out0.00      0.00      0.00      0.00      0.29      0.450.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.00      0.00      0.00      0.090.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.00      0.00      0.00      0.09

ifstat -z 忽略网卡up但是没有流量的网卡

andrew@andrew-Thurley:~$ ifstat -zwlp3s0b1     KB/s in  KB/s out0.00      0.000.00      0.000.00      0.00

ifstat -i指定监听的网卡
Specifies the list of interfaces to monitor, separated by commas (if an interface name has a comma, it can be escaped with '\'). Multiple instances of the options are added together.

andrew@andrew-Thurley:~$ ifstat -i lolo        KB/s in  KB/s out0.00      0.000.00      0.000.00      0.00

ifstat -s/d
Specifies a driver to use to gather stats and an eventual option for this driver separated of the driver name by a colon.


andrew@andrew-Thurley:~$ sudo ifstat -d procenp4s0             wlp3s0b1     KB/s in  KB/s out   KB/s in  KB/s out0.00      0.00      0.04      0.090.00      0.00      0.06      0.080.00      0.00      0.15      0.000.00      0.00      0.00      0.000.00      0.00      0.00      0.000.00      0.00      0.00      0.000.00      0.00      0.00      0.000.00      0.00      0.00      0.00

ifstat -t `增加时间戳

andrew@andrew-Thurley:~$ ifstat -tTime          enp4s0             wlp3s0b1
HH:MM:SS   KB/s in  KB/s out   KB/s in  KB/s out
21:54:23      0.00      0.00      0.00      0.00
21:54:24      0.00      0.00      0.15      0.00
21:54:25      0.00      0.00      0.00      0.28
21:54:26      0.00      0.00      0.00      0.10
21:54:27      0.00      0.00      0.12      0.09

ifstat -T 报告所有网卡的网络吞吐量的和

andrew@andrew-Thurley:~$ ifstat -Tenp4s0             wlp3s0b1             Total       KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out0.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.00      0.00      0.00      0.000.00      0.00      0.04      0.06      0.04      0.06
-h  Displays a short help message.
-n  Turns off displaying the header periodically.-A  Disables use of interface indexes: by default, when polling mechanism is index based (snmp, ifmib), ifstat remembersindexes of monitored interfaces to poll only them. However, if interfaces indexes change often (new interfaces added, etc),you might loose some stats, hence this flag. Note that if you ask ifstat to monitor a non existent interface, it will pollall interfaces until it finds the requested one (regardless of this flag) so you can poll for an interface that goes up anddown.-w  Uses fixed width columns, instead of enlarging them if needed for interfaces names to fit.-W  Wrap lines that are larger than the terminal width (implies -w). Wrapped lines are prefixed with a cycling letter to easereading.-S  Keep stats updated on the same line if possible (no scrolling nor wrapping).-b  Reports bandwith in kbits/sec instead of kbytes/sec.-q  Quiet mode, warnings are not printed.-v  Displays version and the compiled-in drivers.

iftop

`iftop`是一款实时流量监测工具,监测tcp/ip的连接
`iftop - display bandwidth usage on an interface by host`

参数

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

直接显示IP不进行DNS反解析

 sudo iftop -n -i wlp3s0b1

不对网络端口号进行解析

sudo iftop -N -i wlp3s0b1

监测指定网段

sudo iftop  -F 192.168.0.0/255.255.255.0  -i wlp3s0b1
       -p     Run in promiscuous mode, so that traffic which does not pass directly through the specified interface is also counted.-P     Turn on port display.-l     Display and count datagrams addressed to or from link-local IPv6 addresses.  The default is not to display that addresscategory.-b     Don't display bar graphs of traffic.-m limitSet the upper limit for the bandwidth scale.  Specified as a number with a 'K', 'M' or 'G' suffix.-B     Display bandwidth rates in bytes/sec rather than bits/sec.-i interfaceListen to packets on interface.-f filter codeUse filter code to select the packets to count. Only IP packets are ever counted, so the specified code is evaluated as(filter code) and ip.-F net/maskSpecifies  an IPv4 network for traffic analysis.  If specified, iftop will only include packets flowing in to or out ofthe given network, and packet direction is determined relative to the network boundary, rather than to  the  interface.You  may specify mask as a dotted quad, such as /255.255.255.0, or as a single number specifying the number of bits setin the netmask, such as /24.-G net6/mask6Specifies an IPv6 network for traffic analysis. The value of mask6 can be given as a prefix length or  as  a  numericaladdress string for more compound bitmasking.-c config fileSpecifies  an  alternate  config  file.   If  not  specified,  iftop will use ~/.iftoprc if it exists.  See below for adescription of config files-t text output modeUse text interface without ncurses and print the output to STDOUT.DISPLAYWhen running, iftop uses the whole screen to display network usage. At the top of the display is a logarithmic scale  for  thebar graph which gives a visual indication of traffic.The main part of the display lists, for each pair of hosts, the rate at which data has been sent and received over the preced‐ing 2, 10 and 40 second intervals. The direction of data flow is indicated by arrows, <= and =>. For instance,foo.example.com  =>  bar.example.com      1Kb  500b   100b<=                       2Mb    2Mb    2Mbshows, on the first line, traffic from foo.example.com to bar.example.com; in the preceding 2 seconds, this averaged  1Kbit/s,around  half  that  amount  over  the  preceding 10s, and a fifth of that over the whole of the last 40s. During each of thoseintervals, the data sent in the other direction was about 2Mbit/s. On the actual display, part of each  line  is  inverted  togive  a visual indication of the 10s average of traffic.  You might expect to see something like this where host foo is makingrepeated HTTP requests to bar, which is sending data back which saturates a 2Mbit/s link.By default, the pairs of hosts responsible for the most traffic (10 second average) are displayed at the top of the list.At the bottom of the display, various totals are shown, including peak traffic over the last 40s,  total  traffic  transferred(after filtering), and total transfer rates averaged over 2s, 10s and 40s.SOURCE / DEST AGGREGATIONBy  pressing  s  or d while iftop is running, all traffic for each source or destination will be aggregated together.  This ismost useful when iftop is run in promiscuous mode, or is run on a gateway machine.PORT DISPLAYS or D toggle the display of source and destination ports respectively. p will toggle port display on/off.DISPLAY TYPEt cycles through the four line display modes; the default 2-line display, with sent and received traffic  on  separate  lines,and 3 1-line displays, with sent, received, or total traffic shown.
DISPLAY ORDERBy default, the display is ordered according to the 10s average (2nd column).  By pressing 1, 2 or 3 it is possible to sort bythe 1st, 2nd or 3rd column.   By pressing < or > the display will be sorted by source or destination hostname respectively.DISPLAY FILTERINGl allows you to enter a POSIX extended regular expression that will be used to filter hostnames shown in the display.  This isa  good way to quickly limit what is shown on the display.  Note that this happens at a much later stage than filter code, anddoes not affect what is actually captured.  Display filters DO NOT affect the totals at the bottom of the screen.PAUSE DISPLAY / FREEZE ORDERP will pause the current display.o will freeze the current screen order.  This has the side effect that traffic between hosts not shown on the  screen  at  thetime will not be shown at all, although it will be included in the totals at the bottom of the screen.SCROLL DISPLAYj and k will scroll the display of hosts.  This feature is most useful when the display order is frozen (see above).FILTER CODEf allows you to edit the filter code whilst iftop running.  This can lead to some unexpected behaviour.CONFIG FILEiftop  can  read its configuration from a config file.  If the -c option is not specified, iftop will attempt to read its con‐figuration from ~/.iftoprc, if it exists.  Any command line options specified will override settings in the config file.The config file consists of one configuration directive per line.  Each directive is a name value pair, for example:interface: eth0sets the network interface.  The following config directives are supported:interface: ifSets the network interface to if.dns-resolution: (yes|no)Controls reverse lookup of IP addresses.port-resolution: (yes|no)Controls conversion of port numbers to service names.filter-code: bpfSets the filter code to bpf.show-bars: (yes|no)Controls display of bar graphs.promiscuous: (yes|no)Puts the interface into promiscuous mode.port-display: (off|source-only|destination-only|on)Controls display of port numbers.link-local: (yes|no)Determines displaying of link-local IPv6 addresses.hide-source: (yes|no)Hides source host names.hide-destination: (yes|no)Hides destination host names.use-bytes: (yes|no)Use bytes for bandwidth display, rather than bits.sort: (2s|10s|40s|source|destination)Sets which column is used to sort the display.line-display: (two-line|one-line-both|one-line-sent|one-line-received)Controls the appearance of each item in the display.show-totals: (yes|no)Shows cumulative total for each item.log-scale: (yes|no)Use a logarithmic scale for bar graphs.max-bandwidth: bwFixes the maximum for the bar graph scale to bw, e.g. "10M". Note that the value has to always be in  bits,  regardlessif the option to display in bytes has been chosen.net-filter: net/maskDefines an IP network boundary for determining packet direction.net-filter6: net6/mask6Defines an IPv6 network boundary for determining packet direction.screen-filter: regexpSets a regular expression to filter screen output.QUIRKS (aka they're features, not bugs)There  are  some  circumstances  in which iftop may not do what you expect.  In most cases what it is doing is logical, and webelieve it is correct behaviour, although I'm happy to hear reasoned arguments for alternative behaviour.Totals don't add upThere are several reasons why the totals may not appear to add up.  The most obvious is having a screen filter in  effect,  orscreen ordering frozen.  In this case some captured information is not being shown to you, but is included in the totals.A  more subtle explanation comes about when running in promiscuous mode without specifying a -F option.  In this case there isno easy way to assign the direction of traffic between two third parties.  For the purposes of the main display this  is  donein an arbitrary fashion (by ordering of IP addresses), but for the sake of totals all traffic between other hosts is accountedas incoming, because that's what it is from the point of view of your interface.  The -F option allows you to specify an arbi‐trary network boundary, and to show traffic flowing across it.Peak totals don't add upAgain,  this is a feature.  The peak sent and peak received didn't necessarily happen at the same time.  The peak total is themaximum of sent plus received in each captured time division.Changing the filter code doesn't seem to workGive it time.  Changing the filter code affects what is captured from the time that you entered it, but most of what is on thedisplay  is based on some fraction of the last 40s window of capturing.  After changing the filter there may be entries on thedisplay that are disallowed by the current filter for up to 40s.  DISPLAY FILTERING has immediate effect and does  not  affectwhat is captured.
FILES~/.iftoprcConfiguration file for 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退出监控。

ifstat,iftop相关推荐

  1. Linux网络流量实时监控ifstat iftop命令详解

    ifstat 介绍 ifstat工具是个网络接口监测工具,比较简单看网络流量 实例 默认使用 #ifstateth0 eth1 KB/s in KB/s out KB/s in KB/s out0.0 ...

  2. 【网络】流量监控 - iftop|ifstat|查看某个ip流量|tcpdump|iptraf|Linux

    目录 流量监控18个常用工具 tcpdump查看某个端口数据 ifstat iftop 四.运行iftop 五.相关参数及说明 1.iftop界面相关说明 2.iftop相关参数 常用的参数 按端口显 ...

  3. linux脚本实时监控,linux实时监控命令

    1.查看磁盘IO iostat -x 1 10  查看设备使用率(%util).响应时间(await) avg-cpu:  %user   %nice %system %iowait  %steal  ...

  4. Linux/Unix笔记本

    Linux介绍 Linux入门--个人感想 Google怎么用linux 初入Linux Windows XP硬盘安装Ubuntu 12.04双系统图文详解 实例讲解虚拟机3种网络模式(桥接.nat. ...

  5. 【转载】Linux/Unix笔记本

    http://www.cnblogs.com/ggjucheng/archive/2012/08/18/2645321.html Linux介绍 Linux入门--个人感想 Google怎么用linu ...

  6. 【Linux】之【网络】相关的命令及解析[ethtool、nload、nethogs、iftop、iptraf、ifstat]

    文章目录 一.网络带宽命令 1.ethtool – 查询与设置网卡参数 2.nload – 实时统计网卡带宽使用率工具 二.网络命令 1.nethogs – 实时统计网络带宽使用率工具 2.iftop ...

  7. Linux流量查看工具ifstat,nload,iftop(谁在偷偷使用流量)

    1.ifstat 是一个网络流量监测程序.能查看网卡的流出和流入的字节.是一个统计网络接口活动状态的工具. 安装方法:yum install -y ifstat 选项: -a 监测能检测到的所有网络接 ...

  8. 时时流量查看工具-ifsta,nload,iftop

    为什么80%的码农都做不了架构师?>>>    1.ifstat 是一个网络流量监测程序.能查看网卡的流出和流入的字节. 概要:ifstat就像iostat/vmstat描述其它的系 ...

  9. iftop监控网卡实时流量

    在Linux/Unix监控系统网卡的实时流量 iftop是个不错的选择她可以详细到来源和目标及端口 ifstat 报告接口状态,是一个网络流量监测程序.能查看网卡的流出和流入的字节. 参数: -l 监 ...

最新文章

  1. php中将数据加入到文件中
  2. golang goroutine的调度模型:MPG模式
  3. python 姓名用*替换_学会用python截取你的姓名
  4. Spring学习总结3——配置datasource三种方式
  5. 水彩手绘中华美食PNG素材,提高海报设计效率!
  6. java如何解析word大纲_Java POI 解析word文档
  7. 吴恩达《机器学习》课程总结(8)_神经网络参数的反向传播算法
  8. activemq 搭建2
  9. OpenGL库 资源下载
  10. NPDP产品经理认证:创新性解决问题方法(TRIZ)的工具与应用
  11. C语言中 1%3,算术什么意思啊 算数什么意思
  12. element ui 自定义icon图标
  13. 北京将超前布局6G未来网络!这场发布会,信息量很大
  14. JavavEE中网络编程Socket套接字Ⅱ(TCP)
  15. Word文档如何进行字数统计
  16. Windows关于文件句柄数的限制
  17. 动目标显示matlab仿真,动目标显示与脉冲多普勒雷达 (MATLAB程式设计)
  18. 团队-中国象棋游戏-设计文档
  19. 只能替换有源晶振 时钟发生器_有源晶振选型与替换原则
  20. 物体抓取位姿估計算法綜述_NO. 1 物体位姿估计 机器人抓取

热门文章

  1. 食品行业ERP选型 需把握关键的20%
  2. poj 1186 方程的解数(线性探测再哈希)
  3. jsp网上商城jsp课程设计
  4. 最大流ISAP算法模板
  5. [Xcode 实际操作]七、文件与数据-(3)创建文本文件、属性列表文件、图片文件
  6. 《明解C语言》pdf
  7. [转载] LinkedIn架构这十年
  8. 浅谈输入输出”重定向“——基于Linux系统
  9. 一个return引发的血案 - 自己动手实现allocator
  10. 面试金典--min栈的实现