佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > linux中查看網(wǎng)卡流量六種方法

linux中查看網(wǎng)卡流量六種方法

熱門標(biāo)簽:硅谷的囚徒呼叫中心 解決方案 電話機(jī)器人搭建 服務(wù)器配置 美團(tuán) 外呼系統(tǒng) 家政服務(wù)網(wǎng)絡(luò) 百度競價點(diǎn)擊價格的計算公式

方法一、nload工具

源碼包路徑:

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

查看參數(shù)幫助命令:
nload –help

-a:這個好像是全部數(shù)據(jù)的刷新時間周期,單位是秒,默認(rèn)是300.
-i:進(jìn)入網(wǎng)卡的流量圖的顯示比例最大值設(shè)置,默認(rèn)10240 kBit/s.
-m:不顯示流量圖,只顯示統(tǒng)計數(shù)據(jù)。
-o:出去網(wǎng)卡的流量圖的顯示比例最大值設(shè)置,默認(rèn)10240 kBit/s.
-t:顯示數(shù)據(jù)的刷新時間間隔,單位是毫秒,默認(rèn)500。
-u:設(shè)置右邊Curr、Avg、Min、Max的數(shù)據(jù)單位,默認(rèn)是自動變的.注意大小寫單位不同!
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:設(shè)置右邊Ttl的數(shù)據(jù)單位,默認(rèn)是自動變的.注意大小寫單位不同(與-u相同)!
Devices:自定義監(jiān)控的網(wǎng)卡,默認(rèn)是全部監(jiān)控的,使用左右鍵切換。

如只監(jiān)控eth0命令: nload eth0

方法二、iftop工具

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

1、iftop界面相關(guān)說明

界面上面顯示的是類似刻度尺的刻度范圍,為顯示流量圖形的長條作標(biāo)尺用的。
中間的= =>這兩個左右箭頭,表示的是流量的方向。

TX:發(fā)送流量
RX:接收流量
TOTAL:總流量
Cumm:運(yùn)行iftop到目前時間的總流量
peak:流量峰值
rates:分別表示過去 2s 10s 40s 的平均流量

2、iftop相關(guān)參數(shù)

常用的參數(shù)

-i設(shè)定監(jiān)測的網(wǎng)卡,如:# iftop -i eth1
-B 以bytes為單位顯示流量(默認(rèn)是bits),如:# iftop -B
-n使host信息默認(rèn)直接都顯示IP,如:# iftop -n
-N使端口信息默認(rèn)直接都顯示端口號,如: # iftop -N
-F顯示特定網(wǎng)段的進(jìn)出流量,如# iftop -F 10.10.1.0/24或# iftop -F 10.10.1.0/255.255.255.0
-h(display this message),幫助,顯示參數(shù)信息
-p使用這個參數(shù)后,中間的列表顯示的本地主機(jī)信息,出現(xiàn)了本機(jī)以外的IP信息;
-b使流量圖形條默認(rèn)就顯示;
-f這個暫時還不太會用,過濾計算包用的;
-P使host信息及端口信息默認(rèn)就都顯示;
-m設(shè)置界面最上邊的刻度的最大值,刻度分五個大段顯示,例:# iftop -m 100M
進(jìn)入iftop畫面后的一些操作命令(注意大小寫)
按h切換是否顯示幫助;
按n切換顯示本機(jī)的IP或主機(jī)名;
按s切換是否顯示本機(jī)的host信息;
按d切換是否顯示遠(yuǎn)端目標(biāo)主機(jī)的host信息;
按t切換顯示格式為2行/1行/只顯示發(fā)送流量/只顯示接收流量;
按N切換顯示端口號或端口服務(wù)名稱;
按S切換是否顯示本機(jī)的端口信息;
按D切換是否顯示遠(yuǎn)端目標(biāo)主機(jī)的端口信息;
按p切換是否顯示端口信息;
按P切換暫停/繼續(xù)顯示;
按b切換是否顯示平均流量圖形條;
按B切換計算2秒或10秒或40秒內(nèi)的平均流量;
按T切換是否顯示每個連接的總流量;
按l打開屏幕過濾功能,輸入要過濾的字符,比如ip,按回車后,屏幕就只顯示這個IP相關(guān)的流量信息;
按L切換顯示畫面上邊的刻度;刻度不同,流量圖形條會有變化;
按j或按k可以向上或向下滾動屏幕顯示的連接記錄;
按1或2或3可以根據(jù)右側(cè)顯示的三列流量數(shù)據(jù)進(jìn)行排序;
按根據(jù)左邊的本機(jī)名或IP排序;
按>根據(jù)遠(yuǎn)端目標(biāo)主機(jī)的主機(jī)名或IP排序;
按o切換是否固定只顯示當(dāng)前的連接;
按f可以編輯過濾代碼,這是翻譯過來的說法,我還沒用過這個!
按!可以使用Shell命令,這個沒用過!沒搞明白啥命令在這好用呢!
按q退出監(jiān)控。

方法三、 ifstat

源碼包路徑:
http://gael.roualland.free.fr/ifstat/ifstat-1.1.tar.gz
參數(shù):

-a 監(jiān)測能檢測到的所有網(wǎng)絡(luò)接口的狀態(tài)信息
-z 隱藏流量是無的接口,例如那些接口雖然啟動了但是未用的
-i 指定要監(jiān)測的接口,后面跟網(wǎng)絡(luò)接口名
時間:
-T 報告所有監(jiān)測接口的全部帶寬
-w 用指定的列寬,而不是為了適應(yīng)接口名稱的長度而去自動放大列寬
-W 如果內(nèi)容比終端窗口的寬度還要寬就自動換行
-b 用kbits/s顯示帶寬而不是kbytes/s

方法四、

iptraf

安裝方式:
yum -y install iptraf

iptraf是一個基于ncurses開發(fā)的IP局域網(wǎng)監(jiān)控工具,它可以實(shí)時地監(jiān)視網(wǎng)卡流量,可以生成各種網(wǎng)絡(luò)統(tǒng)計數(shù)據(jù),包括TCP信息、UDP統(tǒng)計、ICMP和OSPF信息、以太網(wǎng)負(fù)載信息、節(jié)點(diǎn)統(tǒng)計、IP校驗(yàn)和錯誤和其它一些信息。

iptraf的參數(shù)列表

iptraf后面加上不同的參數(shù),可以起到不同的作用,下面是iptraf的參數(shù)命令列表:

參數(shù)命令 作用
-i iface 網(wǎng)絡(luò)接口:立即在指定網(wǎng)絡(luò)接口上開啟IP流量監(jiān)視,iface為all指監(jiān)視所有的網(wǎng)絡(luò)接口,iface指相應(yīng)的interface
-g 立即開始生成網(wǎng)絡(luò)接口的概要狀態(tài)信息
-d iface 網(wǎng)絡(luò)接口:在指定網(wǎng)絡(luò)接口上立即開始監(jiān)視明細(xì)的網(wǎng)絡(luò)流量信息,iface指相應(yīng)的interface
-s iface 網(wǎng)絡(luò)接口:在指定網(wǎng)絡(luò)接口上立即開始監(jiān)視TCP和UDP網(wǎng)絡(luò)流量信息,iface指相應(yīng)的interface
-z iface 網(wǎng)絡(luò)接口:在指定網(wǎng)絡(luò)接口上顯示包計數(shù),iface指相應(yīng)的interface
-l iface 網(wǎng)絡(luò)接口:在指定網(wǎng)絡(luò)接口上立即開始監(jiān)視局域網(wǎng)工作站信息,iface指相應(yīng)的interface
-t timeout 時間:指定iptraf指令監(jiān)視的時間,timeout指監(jiān)視時間的minute數(shù)
-B 將標(biāo)注輸出重新定向到“/dev/null”,關(guān)閉標(biāo)注輸入,將程序作為后臺進(jìn)程運(yùn)行
-L logfile 指定一個文件用于記錄所有命令行的log,默認(rèn)文件是地址:/var/log/iptraf
-I interval 指定記錄log的時間間隔(單位是minute),不包括IP traffic monitor
-u 允許使用不支持的接口作為以太網(wǎng)設(shè)備
-f 清空所有計數(shù)器
-h 顯示幫助信息

方法五、watch ifconfig

watch命令可以反復(fù)的執(zhí)行一個命令,默認(rèn)時間間隔為2秒鐘。
watch ifconfig 可以每隔兩秒監(jiān)視網(wǎng)絡(luò)狀態(tài)、
watch -d ifconfig 可以每隔兩秒監(jiān)視網(wǎng)絡(luò)狀態(tài), 并標(biāo)記發(fā)生變化的部分
watch -d ifconfig eth0 可以每隔兩秒只監(jiān)視 網(wǎng)卡eth0, 并標(biāo)記發(fā)生變化的部分
watch -d 'ifconfig eth0 | grep bytes' 可以每隔一秒只監(jiān)視網(wǎng)卡eth0,只顯示流量部分,并標(biāo)記發(fā)生變化的部分

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

標(biāo)簽:韶關(guān) 烏蘭察布 臨沂 南昌 防城港 北海 邢臺 撫州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《linux中查看網(wǎng)卡流量六種方法》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    丹凤县| 沈阳市| 绍兴县| 中卫市| 黑龙江省| 久治县| 肥乡县| 阿拉善右旗| 财经| 武安市| 休宁县| 多伦县| 定州市| 英德市| 广德县| 凤翔县| 沈阳市| 封丘县| 昆山市| 洛川县| 黄浦区| 庄浪县| 铜鼓县| 兴国县| 宝清县| 满洲里市| 宁南县| 遂宁市| 汉阴县| 江陵县| 仙桃市| 方城县| 丹棱县| 湘乡市| 桓台县| 合川市| 乳源| 广昌县| 澄迈县| 高青县| 湛江市|