京东6.18大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

linux中检察网卡流量六种方法

2024-11-2 22:27| 发布者: 44f6fa4f5| 查看: 33| 评论: 0

摘要: 方法一、nload工具 源码包路径: http://heanet.dl.sourceforge.net/project/nload/nload/0.7.2/nload-0.7.2.tar.gz 检察参数资助命令: nload –help -a:这个好像是全部数据的刷新时间周期,单位是秒,默

方法一、nload工具

源码包路径:

http://heanet.dl.sourceforge.net/project/nload/nload/0.7.2/nload-0.7.2.tar.gz

检察参数资助命令:
nload –help

-a:这个好像是全部数据的刷新时间周期,单位是秒,默认是300.
-i:进入网卡的流量图的体现比例最大值设置,默认10240 kBit/s.
-m:不体现流量图,只体现统计数据。
-o:出去网卡的流量图的体现比例最大值设置,默认10240 kBit/s.
-t:体现数据的刷新时间间隔,单位是毫秒,默认500。
-u:设置右边Curr、Avg、Min、Max的数据单位,默认是自动变的.注意巨细写单位差异!
h|b|k|m|g h: auto, b: Bit/s, k: kBit/s, m: MBit/s etc.
H|B|K|M|G H: auto, B: Byte/s, K: kByte/s, M: MByte/s etc.
-U:设置右边Ttl的数据单位,默认是自动变的.注意巨细写单位差异(与-u雷同)!
Devices:自定义监控的网卡,默认是全部监控的,使用左右键切换。

如只监控eth0命令: nload eth0

方法二、iftop工具

源码包路径:
http://www.ex-parrot.com/%7Epdw/iftop/download/iftop-0.17.tar.gz

1、iftop界面干系分析

界面上面体现的是雷同刻度尺的刻度范围,为体现流量图形的长条作标尺用的。
中间的<= =>这两个左右箭头,体现的是流量的方向。

TX:发送流量
RX:接收流量
TOTAL:总流量
Cumm:运行iftop到目前时间的总流量
peak:流量峰值
rates:分别体现过去 2s 10s 40s 的平均流量

2、iftop干系参数

常用的参数

-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使流量图形条默认就体现;
-f这个暂时还不太会用,过滤计算包用的;
-P使host信息及端口信息默认就都体现;
-m设置界面最上边的刻度的最大值,刻度分五个大段体现,例:# iftop -m 100M
进入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

源码包路径:
http://gael.roualland.free.fr/ifstat/ifstat-1.1.tar.gz
参数:

-a 监测能检测到的所有网络接口的状态信息
-z 隐蔽流量是无的接口,比方那些接口固然启动了但是未用的
-i 指定要监测的接口,背面跟网络接口名
时间:
-T 报告所有监测接口的全部带宽
-w 用指定的列宽,而不是为了顺应接口名称的长度而去自动放大列宽
-W 如果内容比终端窗口的宽度还要宽就自动换行
-b 用kbits/s体现带宽而不是kbytes/s

方法四、

iptraf

安装方式:
yum -y install iptraf

iptraf是一个基于ncurses开发的IP局域网监控工具,它可以及时地监督网卡流量,可以天生各种网络统计数据,包括TCP信息、UDP统计、ICMP和OSPF信息、以太网负载信息、节点统计、IP校验和错误和其它一些信息。

iptraf的参数列表

iptraf背面加上差异的参数,可以起到差异的作用,下面是iptraf的参数命令列表:

参数命令 作用
-i iface 网络接口:立刻在指定网络接口上开启IP流量监督,iface为all指监督所有的网络接口,iface指相应的interface
-g 立刻开始天生网络接口的概要状态信息
-d iface 网络接口:在指定网络接口上立刻开始监督明细的网络流量信息,iface指相应的interface
-s iface 网络接口:在指定网络接口上立刻开始监督TCP和UDP网络流量信息,iface指相应的interface
-z iface 网络接口:在指定网络接口上体现包计数,iface指相应的interface
-l iface 网络接口:在指定网络接口上立刻开始监督局域网工作站信息,iface指相应的interface
-t timeout 时间:指定iptraf指令监督的时间,timeout指监督时间的minute数
-B 将标注输出重新定向到“/dev/null”,关闭标注输入,将程序作为背景进程运行
-L logfile 指定一个文件用于记载所有命令行的log,默认文件是地址:/var/log/iptraf
-I interval 指定记载log的时间间隔(单位是minute),不包括IP traffic monitor
-u 答应使用不支持的接口作为以太网装备
-f 清空所有计数器
-h 体现资助信息

方法五、watch ifconfig

watch命令可以反复的实行一个命令,默认时间间隔为2秒钟。
watch ifconfig 可以每隔两秒监督网络状态、
watch -d ifconfig 可以每隔两秒监督网络状态, 并标志发生厘革的部分
watch -d ifconfig eth0 可以每隔两秒只监督 网卡eth0, 并标志发生厘革的部分
watch -d 'ifconfig eth0 | grep bytes' 可以每隔一秒只监督网卡eth0,只体现流量部分,并标志发生厘革的部分

watch也可以用来检察文件厘革的环境,比方:
比方 watch ls -la file,这条命令的意思是没两秒察看 file1的文件巨细厘革环境。

退出: ctrl+c

watch命令详解

NAME
watch - execute a program periodically, showing output fullscreen
SYNOPSIS
watch [-dhvt] [-n <seconds>] [--differences[=cumulative]] [--help] [--interval=<seconds>] [--no-title] [--version] <command>
DESCRIPTION
watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or --interval to specify a different interval.
The -d or --differences flag will highlight the differences between successive updates. The --cumulative option makes highlighting "sticky", presenting a running display of all positions that have ever changed. The -t or --no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line. watch will run until interrupted.
NOTE
Note that command is given to "sh -c" which means that you may need to use extra quoting to get the desired effect.
Note that POSIX option processing is used (i.e., option processing stops at the first non-option argument). This means that flags after command don't get interpreted by watch itself.
EXAMPLES
To watch for mail, you might do: watch -n 60 from
To watch the contents of a directory change, you could use: watch -d ls -l
If youre only interested in files owned by user joe, you might use: watch -d 'ls -l &#124; fgrep joe'
You can watch for your administrator to install the latest kernel with: watch uname -r (Just kidding.)呵呵
BUGS
Upon terminal resize, the screen will not be correctly repainted until the next scheduled update. All --differences highlighting is lost on that update as well.
Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them.

方法六、

watch cat /proc/net/dev


来源:https://www.jb51.net/LINUXjishu/593625.html
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )|网站地图

GMT+8, 2025-7-2 08:17 , Processed in 0.032429 second(s), 19 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.

返回顶部