在 Linux 中使用 Bashtop 和 Bpytop 监控系统资源

监控工具至关重要,每个系统 admin 知道。 借助资源监控应用程序,我们可以在任务运行时持续观察系统资源的健康状况。 今天,我们将讨论两个系统资源监视器,即 巴什顶桌面 监控 Linux 和类 Unix 操作系统中的系统资源。 Bashtop 和 Bpytop 资源监视器将向您显示系统的使用情况以及处理器、内存、磁盘、网络和进程的统计信息。

这个duo监控工具的作者首先开发了Bashtop,然后创建了Bashtop的Python端口并命名为Bpytop。 他们没有太大区别。 这两个实用程序具有相同的目的并具有相同的功能集。 唯一的区别是两者都是用不同的编程语言编写的。 Bashtop 是用 Bash 编写的,而 Bpytop 是用 Python 编写的。 Bashtop 和 Bpytop 支持 GNU/Linux、Mac OS 和 FreeBSD。

开发人员声称 Bpytop 比 Bashtop 更快,并且 Bpytop 具有更多功能,并建议我们使用 Bpytop 而不是 Bashtop。 然而,这是您个人的选择。 您可以尝试两者并挑选适合您的西装。

在 Linux 上安装 Bashtop 资源监视器

Bashtop 应该可以在具有以下依赖项的任何现代 *nix 系统上运行:

  • 支持 24 位真彩色的终端,
  • 重击 4.4 或更新版本,
  • 吉特,
  • GNU Coreutils,
  • GNU sed,
  • GNU awk,
  • GNU grep,
  • 来自procps-ng的ps (v3.1.15 或更高版本),
  • Python 3.6 或更高版本,
  • 实用工具 (v5.7.0 或更高版本),
  • 可选包;
    • Lm 传感器 – 显示 CPU 温度,
    • iostat(系统统计的一部分) – 显示磁盘读/写统计信息并且不使用 psutil 数据收集,
    • curl – 下载 bashtop 主题并获取有关更新的消息。

在 Arch Linux 上安装 bashtop

尽管 Bashtop 是新的,但它在很短的时间内就变得非常流行,并进入了流行的 Linux 发行版的官方存储库。

在 Arch Linux 上,Bashtop 包含在 [Community] 存储库。 要在 Arch Linux 及其变体如 Manjaro Linux 上安装 Bashtop,请运行:

$ sudo pacman -S bashtop

它也可用于 AUR,因此您可以使用任何 AUR 帮助程序安装它 example .

$ yay -S bashtop-git

在 Debian 上安装 bashtop

自 Debian 11 起,Bashtop 在官方 Debian 存储库中可用。要在 Debian 上安装 Bashtop,请运行:

$ sudo apt install bashtop

安装 bashtop Fedora

$ sudo dnf install bashtop

在 CentOS 8 / RHEL 8 上安装 bashtop

$ sudo dnf config-manager --set-enabled PowerTools
$ sudo dnf install epel-release
$ sudo dnf install bashtop

在 Ubuntu 上安装 bashtop

自 Ubuntu 20.10 起,Bashtop 在官方 Ubuntu 存储库中可用。

要在 Ubuntu 和 Linux Mint 等衍生产品上安装 Bashtop,请运行:

$ sudo apt install bashtop

从 Snap 商店安装 bashtop

它也可用作 Snap 应用程序:

$ sudo snap install bashtop

从 PPA 安装 bashtop

还有一个官方的 PPA 可用。 添加 Bashtop PPA 并将其安装在 Ubuntu 上,通过一一运行以下命令:

$ sudo add-apt-repository ppa:bashtop-monitor/bashtop
$ sudo apt update
$ sudo apt install bashtop

从源代码安装 Bashtop

您也可以从源代码安装它。 只要确保您已安装上述依赖项即可。

Git 使用以下命令克隆 Bashtop 存储库:

$ git clone https://github.com/aristocratos/bashtop.git

上述命令将克隆 Bashtop github 存储库的内容到当前目录中名为“bashtop”的目录中。 转到克隆的目录:

$ cd bashtop

并运行以下命令从源代码安装 Bashtop:

$ sudo make install

要卸载它,只需从 bashtop 目录运行以下命令:

$ sudo make uninstall

在 Linux 上安装 Bpytop 资源监视器

Bpytop 是 Bashtop 的 python 端口。 作者声称 Bpytop 比 Bashtop 快得多并且具有更多功能。

Bpytop 可作为 snap 应用程序使用。 要在支持 snapd 的 Linux 发行版上安装 Bpytop,请运行:

$ sudo snap install bpytop

从源代码安装 Bpytop

确保您的系统具有以下依赖项:

  • 支持 24 位真彩色的终端,
  • Python 3(v3.6 或更高版本),
  • psutil 模块(v5.7.0 或更高版本)。

安装先决条件后,使用以下命令 git clone Bpytop 存储库:

$ git clone https://github.com/aristocratos/bpytop.git

上述命令会将 bpytop 的内容克隆到名为“bpytop”的本地目录中。 cd到它并安装它,如下所示:

$ cd bpytop 
$ sudo make install

要卸载 Bpytop,只需从 bpytop 目录运行以下命令:

$ sudo make uninstall

在 Linux 中使用 Bashtop 和 Bpytop 监控系统资源

就像我已经说过的,Bashtop 和 Bpytop 具有相同的目的,即监控系统资源并显示 CPU、内存、磁盘、进程和网络等的统计信息。

要开始监视您的 Linux 系统资源,请运行 Bashtop 或 Bpytop,如下所示:

$ bashtop

或者,

$ bpytop

样本输出:

在 Linux 中使用 Bashtop 监控系统资源

正如您在上面的输出中看到的,Bashtop 显示以下详细信息:

  • CPU 使用率图,
  • 处理器时钟速度,
  • 总 CPU 使用率,
  • 每个 CPU 内核的使用情况,
  • 总内存,
  • 用过的内存,
  • 可用内存,
  • 高速缓存存储器,
  • 可用的高速缓存,
  • 交换使用(已使用和免费),
  • 当前磁盘的读写速度。

Bashtop/Bpytop 的默认刷新率是 2500 毫秒. 按 (+, A, a) 键添加 100 毫秒以更新计时器。 按 (-, S, s) 键从更新计时器中减去 100 毫秒。

选择和查看进程

采用 上/下 键来浏览过程或使用。 按 上一页向下 键在进程列表中跳转 1 页。 按 (家 或者 结尾) 键跳转到进程列表中的第一页或最后一页。

进程部分按列显示以下详细信息:

  • 进程 ID (PID),
  • 进程名称,
  • 论据,
  • 线程,
  • 流程所有者,
  • 进程的内存使用细节,
  • 进程的 CPU 使用率。

您可以在列之间切换 (剩下 或者 对) 方向键。

进程名称按 PID 降序排列。 IE 最大的 PID 将显示在顶部。 您可以使用 (R, r) 在流程部分中反转排序顺序的键。

要显示选定进程的详细信息,请按 ENTER。

查看 Bashtop 中选定进程的详细信息

到 close 选定的进程详细信息框,按 ENTER 键。

过滤过程

要按特定字符串过滤进程,请按 (女,女) 键并键入字符串名称。 例如,如果您键入 “ssh”,您将看到所有以“ssh”字母开头的进程。

在 Bashtop 和 Bpytop 中按特定字符串过滤进程

在 Bashtop 中按特定字符串过滤进程

要清除任何输入的过滤器,请按 (三,三) 键。

终止进程

您可以通过按 SIGTERM 终止选定的进程 (T, t) 键。

在 Bashtop 和 Bpytop 中终止进程

在 Bashtop 中终止进程

杀死进程

要使用 SIGKILL 终止选定的进程,请按 (K, k) 键。

这相当于“kill -9 ”命令。

中断进程

要使用 SIGINT 中断选定的进程,请按 (我,我) 键。

显示帮助

您可以按 F1、H、h 键来显示帮助部分。

显示 Bashtop 帮助部分

显示 Bashtop 帮助部分

您可以通过按 Esc、M、m 键调出 Bashtop/Bpytop 主菜单。

Exit Bashtop/Bpytop

要退出 Bashtop/Bpytop,只需按 (Ctrl-C, Q, q) 键。

配置 Bashtop/Bpytop

Bashtop 和 Bpytop 配置文件存储在 “$HOME/.config/bashtop”“$HOME/.config/bpytop” 文件夹分别。

您可以通过查看文件来查看 Bashtop/Bpytop 的当前配置选项。

Bashtop 配置文件:

$ cat ~/.config/bashtop/bashtop.cfg

Bpytop 配置文件:

$ cat ~/.config/bashtop/bpytop.cfg

样本输出:

#? Config file for bashtop v. 0.9.25

#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes" and "$HOME/.config/bashtop/user_themes"
#* Should be prefixed with either "themes/" or "user_themes/" depending on location, "Default" for builtin default theme
color_theme="Default"

#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
update_ms="2300"

#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive"
#* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly
proc_sorting="pid"

#* Reverse sorting order, "true" or "false"
proc_reversed="false"

#* Show processes as a tree
proc_tree="false"

#* Check cpu temperature, only works if "sensors", "vcgencmd" or "osx-cpu-temp" commands is available
check_temp="false"

#* Draw a clock at top of screen, formatting according to strftime, empty string to disable
draw_clock="%X"

#* Update main ui when menus are showing, set this to false if the menus is flickering too much for comfort
background_update="true"

#* Custom cpu model name, empty string to disable
custom_cpu_name=""

#* Enable error logging to "$HOME/.config/bashtop/error.log", "true" or "false"
error_logging="true"

#* Show color gradient in process list, "true" or "false"
proc_gradient="true"

#* If process cpu usage should be of the core it's running on or usage of the total available cpu power
proc_per_core="false"

#* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with space
disks_filter=""

#* Enable check for new version from github.com/aristocratos/bashtop at start
update_check="true"

#* Enable graphs with double the horizontal resolution, increases cpu usage
hires_graphs="false"

#* Enable the use of psutil python3 module for data collection, default on OSX
use_psutil="true"

只需根据自己的喜好更改设置即可。

或者,您可以通过按从 Bashtop/Bpytop TUI 查看当前选项 “米” 信。

Bashtop 和 Bpytop 配置选项窗口

Bashtop 选项窗口

相关阅读:

  • 您可能想知道的“顶级”命令行实用程序的一些替代方案

资源:

特色图片由 布拉克·K像素.