linux nload_Linux nload命令

linux nload

nload is a Linux command-line tool used to monitor network traffic and bandwidth usage in real time, using insightful graphs and traffic statistics.

nload是一个Linux命令行工具,用于使用有洞察力的图表和流量统计信息实时监视网络流量和带宽使用情况。

In this article, we shall take a quick look at what the nload command can do for us.

在本文中,我们将快速了解nload命令可以为我们做什么。



安装nload命令 (Installing nload Command)

If nload is not installed on your system, try typing the below command and examine the output.

如果您的系统上未安装nload ,请尝试键入以下命令并检查输出。


nload --help

Based on the ouput, we can check if we have nload installed.

根据输出,我们可以检查是否已安装nload

Linux Nload Command Not Found
Linux Nload Command Not Found
找不到Linux Nload命令

In my case (Ubuntu), I do not have it installed yet. So install it using your package manager (apt in my case).

就我而言(Ubuntu),我尚未安装。 因此,请使用您的软件包管理器进行安装(在我的情况下为apt )。

Now, on typing nload --help, a suitable help prompt will appear, indicating that it is now installed on your system.

现在,在键入nload --help ,将出现一个合适的帮助提示,表明它已安装在您的系统上。



使用nload命令 (Using nload Command)

There are different ways of invoking nload command to perform and show the required statistics as per the option given. Let us understand that one by one.

根据给定的选项,有多种调用nload命令的方式来执行和显示所需的统计信息。 让我们一一理解。



默认配置:无选项 (Default config: No options)

We can directly call nload command using default settings by simply typing:

我们只需输入以下内容即可使用默认设置直接调用nload命令:


nload

This will now take you to another screen, which will show you the network visualizations in real-time, coming from various devices.

现在,您将转到另一个屏幕,该屏幕将实时显示来自各种设备的网络可视化。

Nload Command Default
Nload Command Default 1
Nload命令默认值1

Here, as you can see, there are 3 pages available; One for each device. A device is anything which sends and/or receives internet packets on the same network, but usually, it represents a network interface device. It does not necessarily need to be a separate physical device, but can even be on the same machine!

如您所见,这里共有3页; 每个设备一个设备是在同一网络上发送和/或接收Internet数据包的任何设备 ,但通常代表网络接口设备 。 它不一定需要是单独的物理设备,甚至可以在同一台机器上!

In my case, my first device is Docker, which is not a physical device, but rather just a service which sends packets through the network. Since it is present locally, it is also listed as a device on nload command.

就我而言,我的第一个设备是Docker,它不是物理设备,而只是通过网络发送数据包的服务。 由于它在本地存在,因此它也被列为nload命令上的设备。

The statistics for this device show that currently, Docker is not sending or receiving any types of packets across a network connection, which is to be expected, as we are not running any Docker Container,

该设备的统计信息表明,由于我们未运行任何Docker容器,目前,Docker尚未通过网络连接发送或接收任何类型的数据包,这是可以预期的。

导航的快捷键 (Key Shortcuts for navigation)

When the statistics window is open, the following key bindings serve as navigation within the window.

打开统计信息窗口后,以下按键绑定将在窗口中用作导航。

KeybindingFunction
Left and Right arrow keysSwitch the display to the next network device/page
Enter / TabSwitch the display to the next network device/page
F2Display the options window
F5Save current settings to the user config file
F6Reload settings from the configuration file
q / Ctrl + CQuit nload command
键绑定 功能
左右箭头键 将显示切换到下一个网络设备/页面
输入/制表符 将显示切换到下一个网络设备/页面
F2 显示选项窗口
F5 将当前设置保存到用户配置文件
F6 从配置文件重新加载设置
q / Ctrl + C 退出nload命令


Now that we know how we can navigate the screen in nload, let us move to our next device, which we can examine by pressing the right arrow key.

现在,我们知道了如何在nload导航屏幕,让我们移至下一个设备,可以通过按右箭头键进行检查。

Nload Command Page Two
Nload Command Page Two
Nload命令第二页

This shows that the second device is ens3, which is a network interface. This is the primary means through which my system is communicating with the internet, and therefore, this roughly shows the bandwidth of my network via the ens3 interface. Since there are no packets actively being transferred via this interface, there is no traffic graph.

这表明第二个设备是ens3 ,这是一个网络接口。 这是我的系统与Internet通信的主要方式,因此,这可以通过ens3接口大致显示我的网络带宽。 由于没有通过此接口主动传输的数据包,因此没有流量图。

Now that we understand the basics of using nload, let us understand some more options for this command.

现在,我们了解了使用nload的基础知识,让我们了解此命令的更多选项。



显示多个设备 (Display multiple devices)

To display multiple network interfaces at the same time without the graphs, use the -m option. This offers a view of all the interfaces in one screen.

要在没有图形的情况下同时显示多个网络接口,请使用-m选项。 这样就可以在一个屏幕中查看所有接口。


nload -m
Nload Multiple Network Interfaces
Nload Multiple Network Interfaces
Nload多个网络接口

This makes it easier to monitor the whole network more easily, using a minimal display screen without traffic graphs.

这使得使用最少的无流量图的显示屏,可以更轻松地监控整个网络。



设定时间窗 (Set a time window)

We can use the -a option to set the length in seconds of the time window for average calculation. By default, nload sets this to be 300 seconds.

我们可以使用-a选项设置时间窗口的长度,以秒为单位进行平均计算。 默认情况下, nload将其设置为300秒。

Syntax:

句法:


nload -a DURATION

Where DURATION is the number of seconds used for calculation.

其中DURATION是用于计算的秒数。

An example invocation can be:

示例调用可以是:


nload -a 100

设置刷新率 (Set the refresh rate)

The -t interval flag sets the refresh interval of the display in milliseconds. By default, nload sets this to be 500 seconds.

-t interval标志设置显示的刷新间隔(以毫秒为单位)。 默认情况下, nload将其设置为500秒。


nload -t 600

使用特定的网络设备 (Use a specific network device)

We can specify network devices to use with the devices flag. The default option is set to “all”, so to change this, we need to explicitly specify the network device to the devices flag.

我们可以使用devices标志指定要使用的网络设备。 默认选项设置为“ all ”,因此要更改此设置,我们需要将网络设备显式指定给devices标志。


nload devices ens3

The above command analyses network packet statistics in the ens3 interface.

上面的命令在ens3接口中分析网络数据包统计信息。



放在一起–使用多个选项 (Putting them together – Using multiple options)

As for other commands, we can invoke nload using multiple options to analyze the network traffic according to our needs.

至于其他命令,我们可以使用多个选项来调用nload来根据需要分析网络流量。

For, example, the below command will display multiple devices across all available interfaces with a time window of 400 seconds and a refresh rate of 600 milliseconds.

例如,以下命令将在所有可用接口上显示多个设备,时间窗口为400秒,刷新率为600毫秒。


nload -m -a 400 -t 600

Output

输出量

Linux Nload Multiple Options
Linux Nload Multiple Options
Linux Nload多个选项


nload命令的配置文件 (Configuration files for nload command)

The nload command can take advantage of some special configuration files to specify the command invocation, instead of using the command options all the time.

nload命令可以利用一些特殊的配置文件来指定命令调用,而不是一直使用命令选项。

Such configuration files can specify the options with which nload starts up by default. There are 2 configuration files, one for the current user, and a global system-wide configuration.

此类配置文件可以指定默认情况下nload启动nload的选项。 有2个配置文件,一个用于当前用户,一个全局系统范围的配置。

The system configuration for nload is located at /etc/nload.conf. It is generally advised to not tamper with this file, as we have a separate user config file for user specific settings.

nload的系统配置位于/etc/nload.conf。 通常建议不要篡改此文件,因为我们为用户特定设置提供了单独的用户配置文件。

The user configuration file is located at $HOME/.nload, where $HOME is the Home Environment Variable, that mentions your home directory. This file may not exist by default, but nload creates this automatically for us when we save the settings using F5. These settings will then be used by default if we type nload, since a configuration file exists!

用户配置文件位于$ HOME / .nload ,其中$ HOME是主目录环境变量 ,其中提到您的主目录。 默认情况下该文件可能不存在,但是当我们使用F5保存设置时, nload将自动为我们创建该文件。 如果我们键入nload ,那么默认情况下将使用这些设置,因为存在配置文件!

We can first check if the user config file exists, using this script:

我们可以使用以下脚本首先检查用户配置文件是否存在:


#!/bin/sh

if test -f $HOME/.nload; then
    echo "Found"
else
    echo "Not Found"
fi
Nload Check Cofig File 1
Nload Check Cofig File 1
Nload检查Cofig文件1

There is no such file in my system, so let’s create it using nload with the previous set of options and saving it by F5.

我的系统中没有这样的文件,所以让我们使用带有前一组选项的nload来创建它,并通过F5保存它。


nload -m -a 400 -t 600

After saving it, and exiting the window, run the script again. nload must have automatically created a config file and saved settings related to our options.

保存它并退出窗口后,再次运行脚本。 nload必须已经自动创建了一个配置文件并保存了与我们的选项有关的设置。

Let’s examine it using any text editor.

让我们使用任何文本编辑器对其进行检查。


vi $HOME/.nload

Indeed, an existing file opens for us.

实际上,现有文件已为我们打开。

Nload Config Options
Nload Config Options
Nload配置选项

This is more or less some of the options which we specified, so this indeed works.

这或多或少是我们指定的一些选项,因此这确实有效。

Now, if you want to invoke nload with the same options, you can simply type nload, and the options will be automatically specified in the configuration file!

现在,如果要使用相同的选项调用nload ,只需键入nload ,这些选项将在配置文件中自动指定!



结论 (Conclusion)

In this tutorial, we learned about how we can use the nload command to monitor network traffic. We also learned various options which can be used to set custom monitoring options and analyze our network bandwidth and traffic accordingly, and to also work with configuration files for reusability.

在本教程中,我们学习了如何使用nload命令监视网络流量。 我们还学习了各种选项,可用于设置自定义监视选项并相应地分析我们的网络带宽和流量,还可以与配置文件一起使用以实现可重用性。

Hope this tutorial serves to be helpful for you to use this useful tool!

希望本教程对您使用此有用的工具有所帮助!



翻译自: https://www.journaldev.com/34012/linux-nload-command

linux nload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值