Linux终端监管,在Linux中使用Bashtop与Bpytop监管系统资源

cef0b6d4fd3b22a5227da9351d210bbb.png

监管工具非常重要,每个系统管理员都知道这一点。在资源监管应用程序的帮助下,我们可以在任务运行时持续观察系统资源的分配是否处于健康状态。今天,我们将讨论两个系统资源监视器,即Bashtop和Bpytop,用于监管Linux和类unix操作系统中的系统资源。Bashtop和Bpytop资源监视器能够显示系统的使用情况和处理器、内存、磁盘、网络和进程的统计数据。

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

开发者声称Bpytop比Bashtop更快,Bpytop有更多的特性,建议我们使用Bpytop而不是Bashtop。这是你个人的选择。你可以两种都试试,挑一个适合你的。

Bashtop应该能够工作在任何满足以下依赖的类Unix系统上:

支持24位真色彩的终端

Bash4.4或更新版本,

Git

GNU Coreutils

GNU sed

GNU awk

GNU grep

ps from procps-ng (v3.1.15或更高版本)

Python 3.6 或更高版本,

Psutil (v5.7.0 或更高版本),

可选包

Lm-sensors-显示CPU温度

iostat (sysstat的一部分)-显示磁盘读/写统计数据,不使用psutil数据收集

curl-下载bashtop主题并获得有关更新的消息。

在Arch Linux上安装bashtop

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

在Arch Linux上,Bashtop包含在[Community]仓库中。要在Arch Linux及其变种(如Manjaro Linux)上安装Bashtop,请运行:

$ sudo pacman -S bashtop

它也在AUR中可用,所以您可以使用任何AUR助手来安装它,例如Yay。

$ yay -S bashtop-git

在Debian上安装bashtop

从Debian 11开始,Bashtop就可以在官方的Debian存储库中使用。要在Debian上安装Bashtop,请运行:

$ sudo apt install bashtop

在Fedora上安装bashtop

$ 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 store安装bashtop

它也可作为Snap应用被获取:

$ sudo snap install bashtop

从PPA源安装bashtop

对于Ubuntu用户,还有一个官方的PPA可用。添加Bashtop PPA并通过逐个运行以下命令来将Bashtop安装到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

Bpytop是Bashtop的Python端版本。作者声称Bpytop比Bashtop快得多,有更多的特性。

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

$ sudo snap install bpytop

从源代码安装Bpytop

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

支持24位真色彩的终端

python3 (v3.6或更高版本)

psutil模块(v5.7.0或更高版本)

安装好依赖后,使用Git命令克隆Bpytop存储库:

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

上面的命令会将仓库克隆本地目录“bpytop”中。进入该目录,并使用如下命令来安装它:

$ cd bpytop

$ sudo make install

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

$ sudo make uninstall

如前所述,Bashtop和Bpytop的作用是相同的,即监视系统资源并显示CPU、内存、磁盘、进程和网络等的统计数据。

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

$ bashtop

或者,

$ bpytop

输出示例:

1271284b982e53c5a56f6bf4b963987a.png

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

正如你在上面的输出中看到的,Bashtop显示了以下细节:

CPU使用率

处理器时钟速度

CPU总使用率

每个CPU核心的使用情况

总内存

已使用内存

空闲内存

高速缓存

可用高速缓存

交换空间使用率(已使用和空闲)

磁盘的当前读取和写入速度

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

选择和查看进程

使用向上/向下键浏览进程或使用情况。按向上翻页和向下翻页可以在进程列表中进行翻页。按(Home或End)键跳转到进程列表的第一页或最后一页。

进程部分以列的方式显示以下详细信息:

进程ID (PID)

进程名称

参数

线程

进程的所有者

进程的内存使用细节

进程的CPU使用情况

您可以使用(左或右)箭头键在列之间切换。

进程名按PID降序排列。也就是说,最大的PID将显示在顶部。您可以使用(R, r)键来逆转进程部分的排序顺序。

要显示所选进程的详细信息,请按回车键。

2d0d7af7ed9242cb64fd2992108b9446.png

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

要关闭选定的进程的详细信息框,请按ENTER键。

过滤进程

要按特定字符串过滤进程,按(F, f)键并键入字符串。例如,如果您键入"ssh",您将看到所有以"ssh"字母开头的进程。

fc5c57aa0a9b110e33cbb0130af86ec5.png

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

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

终止进程

您可以通过按(T, t)键来使用SIGTERM终止所选进程。

793b4e277f6b7b37bde2437b0388f58e.png

终止Bashtop中的进程

杀死进程

按(K, k)键,用SIGKILL杀死选中的进程。

这等同于“kill -9 ”命令。

中断进程

要用SIGINT中断所选进程,按(I, i)键。

显示帮助

您可以键入F1、H、H键来显示帮助内容。

2ef6dd92ec2fd3692ec39444139138a8.png

显示Bashtop帮助内容

你可以按Esc, M, M键打开Bashtop/Bpytop主菜单。

退出Bashtop / Bpytop

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

配置Bashtop / Bpytop

Bashtop和Bpytop配置文件分别存储在"$HOME/中。配置/ bashtop“和”$ HOME /。分别配置/ 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"

只要根据您的喜好更改设置。

11f6335a9264c062865b7a23a850952a.png

2044cc16730a4db373edeb650f48f2c8.png

cf70c691cb4c6573ab586859392b73d1.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值