Linux 網(wǎng)絡(luò)狀態(tài)監(jiān)控、網(wǎng)絡(luò)性能測試

網(wǎng)絡(luò)狀態(tài)監(jiān)控、及性能測試

在進(jìn)行生產(chǎn)環(huán)境網(wǎng)絡(luò)狀態(tài)檢測、測試網(wǎng)絡(luò)質(zhì)量、網(wǎng)絡(luò)傳輸能力極限的時候就經(jīng)常會用到下面的 Linux 工具,每一種工具都有其側(cè)重點,我們可以根據(jù)具體的關(guān)注點來有選擇性的使用這些工具。

一、nethogs(進(jìn)程級別)

image.png
image.png

NetHogs is a simple open-source utility that runs in the terminal. Instead of breaking the traffic down per protocol or per subnet, it groups bandwith by process. It is very helpful for finding the PID of a hanging program or just for seeing what is eating your bandwidth. It relies mostly on /proc, so most features are Linux-only.
NetHogs 是一個在終端中運行的簡單開源實用程序。它不是按協(xié)議或每個子網(wǎng)分解流量,而是按進(jìn)程對 bandwith 進(jìn)行分組。這對于查找掛起程序的 PID 或僅查看正在消耗帶寬的內(nèi)容非常有幫助。它主要依賴于/proc,因此大多數(shù)功能僅適用于Linux。

To run it, simply use:
要運行它,只需使用:

sudo nethogs

Conveniently, you can specify devices after the command (such as sudo nethogs eth0). You also have additional parameters, such as choosing a delay for the refresh rate (-d), version info (-V), tracemode (-t) and a few others which you can check out in the man pages (man nethogs).
您可以方便地在命令指定設(shè)備 (例如: sudo nethogs eth0)。您還有其他參數(shù),例如為刷新率 (-d) 、版本信息 (-V) 、tracemode (-t) 選擇延遲還有一些您可以在手冊頁 (man nethogs) 中查看的其他內(nèi)容。

二、nload(網(wǎng)卡級別)

image.png
image.png

nload is an open-source console application that allows you to monitor network traffic and bandwidth usage in real time. It visualizes incoming and outgoing traffic using graphs, while also providing additional information (total amount of transferred data, min/max network usage etc.). It’s a simple to use tool that can be really helpful at times.
nload 是一個開源控制臺應(yīng)用程序,可讓您實時監(jiān)控網(wǎng)絡(luò)流量和帶寬使用情況。它使用圖表可視化傳入和傳出流量,同時還提供附加信息 (傳輸數(shù)據(jù)總量、最小/最大網(wǎng)絡(luò)使用量等)。這是一個簡單易用的工具,有時會非常有用。

三、cmb(網(wǎng)卡級別)

image.png
image.png

CBM(Color Bandwidth Meter is a very simple tool that displays (in color) network traffic on all connected devices, in a very stripped-down manner.
CBM是一個非常簡單的工具,以非常精簡的方式在所有連接的設(shè)備上顯示 (彩色) 網(wǎng)絡(luò)流量。

Using CBM is just as easy as installing it. You run:
使用 CBM 和安裝 CBM 一樣簡單。你運行:

cbm

The commands are displayed in the bottom of your terminal so that you can control them easily.
這些命令顯示在終端的底部,以便您可以輕松控制它們。

四、iftop(主機(jī)級別)

image.png
image.png

iftop is a free open-source software command-line system monitor tool that produces a frequently updated list of network connections between pairs of hosts. The connections can be ordered by different parameters, but they ordered by default by bandwidth usage, with only the “top” bandwidth consumers shown.
iftop 是一個免費的開源軟件命令行系統(tǒng)監(jiān)控工具,可生成主機(jī)對之間網(wǎng)絡(luò)連接的頻繁更新列表。連接可以按不同的參數(shù)排序,但默認(rèn)情況下,它們按帶寬使用量排序,僅顯示 “top” 帶寬消費者。

五、iPerf(性能測試)

image.png
image.png

iPerf is tool used for network performance measurement and tuning and can produce standardized performance measurements for any network. It has client and server functionality, and can create data streams to measure bandwidth, loss and other parameters between the two ends in one or both directions. There are two implementations: the original iPerf (iPerf2) and a non-backwards compatible implementation iPerf3.
iPerf 是用于網(wǎng)絡(luò)性能測量和調(diào)整的工具,可以為任何網(wǎng)絡(luò)產(chǎn)生標(biāo)準(zhǔn)化的性能測量。它具有客戶端和服務(wù)器功能,并且可以創(chuàng)建數(shù)據(jù)流來測量兩端在一個方向或兩個方向上的帶寬、損耗和其他參數(shù)。有兩種實現(xiàn)方式: 原始 iPerf (iPerf2) 和非向后兼容實現(xiàn) iperf3。

Note: For all further examples, if you are using iPerf3 simply replace all instances of iperf with iperf3.
注意: 對于所有其他示例,如果您使用的是 iPerf3,只需將 iperf 的所有實例替換為iPerf3。

_
However, doing so will only display your options. To run iPerf, you need a minimum of 2 machines: one to act as a client and one to act as a server. For the server, you’ll use:
但是,這樣做只會顯示您的選項。要運行 iPerf,您至少需要兩臺機(jī)器: 一臺充當(dāng)客戶端,一臺充當(dāng)服務(wù)器。對于服務(wù)器,您將使用:

iperf -s

This will open the machine for listening on port 5001. To connect to another machine and run a test, you’ll use:
這將打開監(jiān)聽端口 5001 的機(jī)器。要連接到另一臺計算機(jī)并運行測試,您將使用:

iperf -c server_address

Where server_address is, of course, the address of the server you are trying to connect to. This can be either an IP address, or something like ping.online.net. The iPerf3 team has a list of servers to use for testing purposes.
其中 server_address 當(dāng)然是您嘗試連接的服務(wù)器的地址。這可以是一個 ip 地址,也可以是 ping.online.net 之類的地址。IPerf3 團(tuán)隊有一個用于測試目的的 服務(wù)器列表。

iPerf is a widely used tool that has a lot of specific uses and many options. I won’t go into those, since it is beyond the scope of this article. However, you can check out the manpage (man iperf / man iperf3) or the documentation.
IPerf 是一種廣泛使用的工具,具有許多特定用途和許多選項。我不再贅述,因為這超出了本文的范圍。但是,您可以查看手冊頁 (man iperf / man iperf3) 或文檔。

參考

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容