溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Linux如何查看網(wǎng)卡流量

發(fā)布時間:2021-10-26 11:54:06 來源:億速云 閱讀:328 作者:小新 欄目:建站服務器

這篇文章將為大家詳細講解有關(guān)Linux如何查看網(wǎng)卡流量,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

一.iptraf

安裝方法:

# yum install iptraf -y

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

epel/metalink                                                                                                               | 7.8 kB     00:00     

 * base: mirrors.163.com

 * epel: mirrors.yun-idc.com

 * extras: mirrors.aliyun.com

 * updates: centos.ustc.edu.cn

base                                                                                                                        | 3.7 kB     00:00     

epel                                                                                                                        | 4.7 kB     00:00     

epel/primary_db                                                                                                             | 6.0 MB     00:00     

extras                                                                                                                      | 3.4 kB     00:00     

updates                                                                                                                     | 3.4 kB     00:00     

Resolving Dependencies

--> Running transaction check

---> Package iptraf.x86_64 0:3.0.1-14.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================

 Package                           Arch                              Version                                 Repository                       Size

===================================================================================================================================================

Installing:

 iptraf                            x86_64                            3.0.1-14.el6                            base                            316 k

Transaction Summary

===================================================================================================================================================

Install       1 Package(s)

Total download size: 316 k

Installed size: 681 k

Downloading Packages:

iptraf-3.0.1-14.el6.x86_64.rpm                                                                                              | 316 kB     00:00     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : iptraf-3.0.1-14.el6.x86_64                                                                                                      1/1 

  Verifying  : iptraf-3.0.1-14.el6.x86_64                                                                                                      1/1 

Installed:

  iptraf.x86_64 0:3.0.1-14.el6                                                                                                                     

Complete!

用法:

# iptraf

Linux如何查看網(wǎng)卡流量

隨便按一個鍵繼續(xù),進入下圖內(nèi)容:

Linux如何查看網(wǎng)卡流量

參數(shù)解釋:

Ip 流量監(jiān)控

簡單的接口統(tǒng)計信息,根據(jù)連接查看網(wǎng)絡流量

詳細的接口統(tǒng)計信息,查看每個網(wǎng)卡上的流量,包括內(nèi)網(wǎng)和外網(wǎng)

統(tǒng)計分析

Lan統(tǒng)計,根據(jù)mac地址統(tǒng)計

具體用法可以參考:

https://www.landui.com/help/show-5067.html

二.nload

安裝方法:

# yum install -y nload

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

 * base: mirrors.163.com

 * epel: mirror01.idc.hinet.net

 * extras: mirrors.aliyun.com

 * updates: centos.ustc.edu.cn

Resolving Dependencies

--> Running transaction check

---> Package nload.x86_64 0:0.7.4-1.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================

 Package                          Arch                              Version                                  Repository                       Size

===================================================================================================================================================

Installing:

 nload                            x86_64                            0.7.4-1.el6                              epel                             63 k

Transaction Summary

===================================================================================================================================================

Install       1 Package(s)

Total download size: 63 k

Installed size: 155 k

Downloading Packages:

nload-0.7.4-1.el6.x86_64.rpm                                                                                                |  63 kB     00:00     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : nload-0.7.4-1.el6.x86_64                                                                                                        1/1 

  Verifying  : nload-0.7.4-1.el6.x86_64                                                                                                        1/1 

Installed:

  nload.x86_64 0:0.7.4-1.el6                                                                                                                       

Complete!

# nload

Linux如何查看網(wǎng)卡流量

三:iftop

安裝方法:

# yum install gcc flex byacc libpcap libpcap-devel ncurses ncurses-devel -y

#  wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz

# tar zxvf iftop-0.17.tar.gz

#cd iftop-0.17

#./configure && make && make install

# iftop

Linux如何查看網(wǎng)卡流量

相關(guān)參數(shù)及說明

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

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

TX:發(fā)送流量

RX:接收流量

TOTAL:總流量

Cumm:運行iftop到目前時間的總流量

peak:流量峰值

rates:分別表示過去 2s 10s 40s 的平均流量

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

  常用的參數(shù)

-i設(shè)定監(jiān)測的網(wǎng)卡,如:# iftop -i eth2

-B 以bytes為單位顯示流量(默認是bits),如:# iftop -B

-n使host信息默認直接都顯示IP,如:# iftop -n

-N使端口信息默認直接都顯示端口號,如: # iftop -N

-F顯示特定網(wǎng)段的進出流量,如# iftop -F 10.10.1.0/24或# iftop -F 10.10.1.0/255.255.255.0

-h(display this message),幫助,顯示參數(shù)信息

-p使用這個參數(shù)后,中間的列表顯示的本地主機信息,出現(xiàn)了本機以外的IP信息;

-b使流量圖形條默認就顯示;

-f這個暫時還不太會用,過濾計算包用的;

-P使host信息及端口信息默認就都顯示;

-m設(shè)置界面最上邊的刻度的最大值,刻度分五個大段顯示,例:# iftop -m 100M

  進入iftop畫面后的一些操作命令(注意大小寫)

按h切換是否顯示幫助;

按n切換顯示本機的IP或主機名;

按s切換是否顯示本機的host信息;

按d切換是否顯示遠端目標主機的host信息;

按t切換顯示格式為2行/1行/只顯示發(fā)送流量/只顯示接收流量;

按N切換顯示端口號或端口服務名稱;

按S切換是否顯示本機的端口信息;

按D切換是否顯示遠端目標主機的端口信息;

按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ù)左邊的本機名或IP排序;

按>根據(jù)遠端目標主機的主機名或IP排序;

按o切換是否固定只顯示當前的連接;

按f可以編輯過濾代碼

按!可以使用Shell命令

按q退出監(jiān)控。

四.sar命令

# sar -n DEV 1 4

Linux 2.6.32-696.el6.x86_64 (test2)     05/14/2019      _x86_64_        (4 CPU)

03:30:35 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

03:30:36 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:30:36 PM      eth2     32.00      2.00      1.44      0.30      0.00      0.00      0.00

03:30:36 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

03:30:37 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:30:37 PM      eth2     15.15      3.03      0.69      0.56      0.00      0.00      0.00

03:30:37 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

03:30:38 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:30:38 PM      eth2     30.69      1.98      1.38      0.50      0.00      0.00      0.00

03:30:38 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

03:30:39 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:30:39 PM      eth2     28.00      2.00      1.26      0.50      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:         eth2     26.50      2.25      1.19      0.47      0.00      0.00      0.00

備注:命令后面1 4的意思是每一秒鐘取1次值,共取4次。

參數(shù)解釋:

IFACE:LAN接口

rxpck/s:每秒鐘接收的數(shù)據(jù)包

txpck/s:每秒鐘發(fā)送的數(shù)據(jù)包

rxkB/s:每秒鐘接收的kB數(shù)

txkB/s:每秒鐘發(fā)送的kB數(shù)

rxcmp/s:每秒鐘接收的壓縮數(shù)據(jù)包

txcmp/s:每秒鐘發(fā)送的壓縮數(shù)據(jù)包

rxmcst/s:每秒鐘接收的多播數(shù)據(jù)包

關(guān)于“Linux如何查看網(wǎng)卡流量”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI