参考 http://os.51cto.com/art/201404/435279.htmhtml
网卡流量监控工具能够监控经过网络接口传输的数据,并测量目前哪些数据所传输的速度。入站流量和出站流量分开来显示。一些命令能够显示单个进程所使用的带宽。这样一来,用户很容易发现过分使用网络带宽的某个进程。这些工具使用不一样的机制来制做流量报告。nload等一些工具能够读取"proc/net/dev"文件,以得到流量统计信息;而一些工具使用pcap库来捕获全部数据包,而后计算总数据量,从而估计流量负载。python
按功能划分的命令名称。linux
ntop和darkstat是面向Linux系统的其中两个基本的基于Web的网络监控工具。除此以外还有企业级监控工具,好比nagios,它们提供了一批功能特性,不只仅能够监控服务器,还能监控整个基础设施。ios
nload是一个命令行工具,让用户能够分开来监控入站流量和出站流量。它还能够绘制图表以显示入站流量和出站流量,视图比例能够调整。用起来很简单,不支持许多选项。redis
适用:只须要快速查看总带宽使用状况,无需每一个进程的详细状况。express
nload version 0.7.4 Copyright (C) 2001 - 2012 by Roland Riegel <feedback@roland-riegel.de> nload comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. For more details see the GNU General Public License Version 2 (http://www.gnu.org/copyleft/gpl.html). Command line syntax: nload [options] [devices] nload --help|-h Options: -a period Sets the length in seconds of the time window for average calculation. Default is 300. -i max_scaling Specifies the 100% mark in kBit/s of the graph indicating the incoming bandwidth usage. Ignored if max_scaling is 0 or the switch -m is given. Default is 10240. -m Show multiple devices at a time; no traffic graphs. -o max_scaling Same as -i but for the graph indicating the outgoing bandwidth usage. Default is 10240. -t interval Determines the refresh interval of the display in milliseconds. Default is 500. -u h|b|k|m|g Sets the type of unit used for the display of traffic numbers. H|B|K|M|G h: auto, b: Bit/s, k: kBit/s, m: MBit/s etc. H: auto, B: Byte/s, K: kByte/s, M: MByte/s etc. Default is h. -U h|b|k|m|g Same as -u, but for a total amount of data (without "/s"). H|B|K|M|G Default is H. devices Network devices to use. Default is to use all auto-detected devices. --help -h Print this help. example: nload -t 200 -i 1024 -o 128 -U M The options above can also be changed at run time by pressing the 'F2' key.
iftop可测量经过每个套接字链接传输的数据;它采用的工做方式有别于nload。iftop使用pcap库来捕获进出网络适配器的数据包,而后汇总数据包大小和数量,搞清楚总的带宽使用状况。服务器
虽然iftop报告每一个链接所使用的带宽,但它没法报告参与某个套按字链接的进程名称/编号(ID)。不过因为基于pcap库,iftop可以过滤流量,并报告由过滤器指定的所选定主机链接的带宽使用状况。网络
iftop: display bandwidth usage on an interface by host Synopsis: iftop -h | [-npbBP] [-i interface] [-f filter code] [-N net/mask] -h display this message -n don't do hostname lookups -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 -i interface listen on named interface -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 -P show ports as well as hosts -m limit sets the upper limit for the bandwidth scale -c config file specifies an alternative configuration file iftop, version 0.17 copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors
iptraf是一款交互式、色彩鲜艳的IP局域网监控工具。它能够显示每一个链接以及主机之间传输的数据量。 iptraf的安装须要预先安装linux内核开发包,iptraf须要引用其中的net下的头文件dom
nethogs是一款小巧的"net top"工具,能够显示每一个进程所使用的带宽,并对列表排序,将耗用带宽最多的进程排在最上面。万一出现带宽使用忽然激增的状况,用户迅速打开nethogs,就能够找到致使带宽使用激增的进程。nethogs能够报告程序的进程编号(PID)、用户和路径。socket
[root@s3 nethogs]# nethogs -h
usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [device [device [device ...]]]
-V : prints version.
-d : delay for update refresh rate in seconds. default is 1.
-t : tracemode.
-b : bughunt mode - implies tracemode.
-p : sniff in promiscious mode (not recommended).
device : device(s) to monitor. default is eth0
When nethogs is running, press:
q: quit
m: switch between total and kb/s mode
bmon(带宽监控器)是一款相似nload的工具,它能够显示系统上全部网络接口的流量负载。输出结果还含有图表和剖面,附有数据包层面的详细信息。bmon支持许多选项,可以制做HTML格式的报告。欲知更多信息
详见:http://lintut.com/bmon-real-time-bandwidth-monitoring-tool-for-linux/
slurm是另外一款网络负载监控器,能够显示设备的统计信息,还能显示ASCII图形。它支持三种不一样类型的图形,使用c键、s键和l键便可激活每种图形。slurm功能简单,没法显示关于网络负载的任何更进一步的详细信息。
tcptrack相似iftop,使用pcap库来捕获数据包,并计算各类统计信息,好比每一个链接所使用的带宽。它还支持标准的pcap过滤器,这些过滤器可用来监控特定的链接。
vnstat更像是一款制做历史报告的工具,显示天天或过去一个月使用了多少带宽。它并非严格意义上的实时监控网络的工具。vnstat与另外大多数工具备点不同。它实际上运行后台服务/守护进程,始终不停地记录所传输数据的大小。以外,它能够用来制做显示网络使用历史状况的报告。
运行没有任何选项的vnstat,只会显示自守护进程运行以来所传输的数据总量。
想实时监控带宽使用状况,请使用"-l"选项(实时模式)。而后,它会显示入站数据和出站数据所使用的总带宽量,但很是精确地显示,没有关于主机链接或进程的任何内部详细信息。
bwm-ng(下一代带宽监控器)是另外一款很是简单的实时网络负载监控工具,能够报告摘要信息,显示进出系统上全部可用网络接口的不一样数据的传输速度。若是控制台足够大,bwm-ng还能使用curses2输出模式,为流量绘制条形图。
这是另外一款小巧而简单的工具,仅仅绘制外观漂亮的图形,显示经过某个接口传输的入站流量和出站流量。
pktstat能够实时显示全部活动链接,并显示哪些数据经过这些活动链接传输的速度。它还能够显示链接类型,好比TCP链接或UDP链接;若是涉及HTTP链接,还会显示关于HTTP请求的详细信息。
netwatch是netdiag工具库的一部分,它也能够显示本地主机与其余远程主机之间的链接,并显示哪些数据在每一个链接上所传输的速度。
与netwatch和pktstat同样,trafshow也能够报告当前活动链接、它们使用的协议以及每条链接上的数据传输速度。它能使用pcap类型过滤器,对链接进行过滤。
netload命令只显示关于当前流量负载的一份简短报告,并显示自程序启动以来所传输的总字节量。没有更多的功能特性。它是netdiag的一部分。
ifstat可以以批处理式模式显示网络带宽。输出采用的一种格式便于用户使用其余程序或实用工具来记入日志和分析。
[root@s3 bmon-3.9]# ifstat -h
Usage: ifstat [OPTION] [ PATTERN [ PATTERN ] ]
-h, --help this message
-a, --ignore ignore history
-d, --scan=SECS sample every statistics every SECS
-e, --errors show errors
-n, --nooutput do history only
-r, --reset reset history
-s, --noupdate don;t update history
-t, --interval=SECS report average over the last SECS
-V, --version output version information
-z, --zeros show entries with zero activity
dstat是一款用途普遍的工具(用python语言编写),它能够监控系统的不一样统计信息,并使用批处理模式来报告,或者将相关数据记入到CSV或相似的文件。这个例子显示了如何使用dstat来报告网络带宽。
[root@s3 bmon-3.9]# dstat -h
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics
Dstat options:
-c, --cpu enable cpu stats
-C 0,3,total include cpu0, cpu3 and total
-d, --disk enable disk stats
-D total,hda include hda and total
-g, --page enable page stats
-i, --int enable interrupt stats
-I 5,eth2 include int5 and interrupt used by eth2
-l, --load enable load stats
-m, --mem enable memory stats
-n, --net enable network stats
-N eth1,total include eth1 and total
-p, --proc enable process stats
-r, --io enable io stats (I/O requests completed)
-s, --swap enable swap stats
-S swap1,total include swap1 and total
-t, --time enable time/date output
-T, --epoch enable time counter (seconds since epoch)
-y, --sys enable system stats
--aio enable aio stats
--fs, --filesystem enable fs stats
--ipc enable ipc stats
--lock enable lock stats
--raw enable raw stats
--socket enable socket stats
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
--vm enable vm stats
--plugin-name enable plugins by plugin name (see manual)
--list list all available plugins
-a, --all equals -cdngy (default)
-f, --full automatically expand -C, -D, -I, -N and -S lists
-v, --vmstat equals -pmgdsc -D total
--bits force bits for values expressed in bytes
--float force float values on screen
--integer force integer values on screen
--bw, --blackonwhite change colors for white background terminal
--nocolor disable colors (implies --noupdate)
--noheaders disable repetitive headers
--noupdate disable intermediate updates
--output file write CSV output to file
--profile show profiling statistics when exiting dstat
delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)
collectl
collectl以一种相似dstat的格式报告系统的统计信息;与dstat同样,它也收集关于系统不一样资源(如处理器、内存和网络等)的统计信息。这里给出的一个简单例子显示了如何使用collectl来报告网络使用/带宽。