首页 > 代码库 > linux的网络监测工具
linux的网络监测工具
linux的性能网络监测工具(iostat/sar/mpstat)需要安装sysstat这个包。
工具一、iftop(查看网络带宽情,(必须从epel源安装)
1) iftop需要的依赖包如下:
flex byacc libpcap ncurses ncurses-devel libpcap-devel
2) 下面是维基百科上的描述:
iftop monitors to network traffic(网络流量) and displays a table of current bandwidth usage(实时带宽使用). An interface may be specified or, if not, it will listen on the first interface it finds which looks like an external interface (with libpcap and libncurses). iftop must be run with sufficient permissions to monitor all network traffic; on most systems this means that it must be run as a root user, see sudo.
By default, iftop will look up hostnames associated with addresses and counts all IP packets that pass through the filter. Hostname look-up can add substantial traffic, in and of itself(主机名查询能够添加大量的流量), and may result in an inaccurate display of network traffic(或许会导致网络流量显示不准确). You may wish to suppress display of DNS traffic by using filter code such as "not port domain"(你或许希望通过像not port domain这样的过滤代码抑制DNS流量显示), or switch it off entirely, by using the -n option or by pressing ‘n‘ when the program is running(或者通过-n选项整个关闭掉). Using the -F option makes it possible to show packets entering and leaving a given network(-F选项可以显示进入和离开给定网络的包).
3) 选项:
iftop -h | [-nNpblBP] [-i interface] [-f filter code] [-F net/mask] [-G net6/mask6]
-h
Print a summary of usage.帮助信息
-n
Don‘t do hostname lookups.不使用主机查询功能
-N
Do not resolve port number to service names不解析服务名的端口号
-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 address category.
-b
Don‘t display bar graphs of traffic.
-B
Display bandwidth rates in bytes/sec rather than bits/sec.
-i interface
Listen to packets on interface.
-f filter code 过滤器代码
Use 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/mask
Specifies an IPv4 network for traffic analysis. If specified, iftop will only include packets flowing in to or out of the 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 set in the netmask, such as /24.
-G net6/mask6
Specifies an IPv6 network for traffic analysis. The value of mask6 can be given as a prefix length or as a numerical address string for more compound bitmasking.
-c config file
Specifies an alternate config file. If not specified, iftop will use ~/.iftoprc if it exists. See below for a description of config files
By pressing s(小写) or d while iftop is running, all traffic for each source or destination will be aggregated together.(通过按s或者d,我们可以汇集每一个源或者目的的流量) This is most useful when iftop is run in promiscuous mode(混合模式), or is run on a gateway machine.
S(大写) or D toggle the display of source and destination ports respectively. p will toggle port display on/off.
显示类型:
t 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.
显示顺序:
By default, the display is ordered according to the 10s average (2nd column). By pressing 1, 2 or 3 it is possible to sort by the 1st, 2nd or 3rd column. By pressing < or > the display will be sorted by source or destination hostname respectively.
暂停显示或者冻结命令
P(大写) 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 the time will not be shown at all, although it will be included in the totals at the bottom of the screen.
滚动显示
j and k will scroll the display of hosts. This feature is most useful when the display order is frozen (see above).
4) 关于iftop的配置文件:
interface: if
Sets 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: bpf
Sets 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: bw
Fixes the maximum for the bar graph scale to bw, e.g. "10M". Note that the value has to always be in bits, regardless if the option to display in bytes has been chosen.
net-filter: net/mask
Defines an IP network boundary for determining packet direction.
net-filter6: net6/mask6
Defines an IPv6 network boundary for determining packet direction.
screen-filter: regexp
Sets a regular expression to filter screen output.
5) 说明:
显示的时间间隔是: 2, 10 and 40 second intervals
6) 安装iftop:
官网:http://www.ex-parrot.com/~pdw/iftop/
make、gcc、autoconf
flex
byacc
libpcap libpcap-devel
ncurses ncurses-devel
本文出自 “Victor的奋斗历程” 博客,请务必保留此出处http://victor2016.blog.51cto.com/6768693/1878622
linux的网络监测工具