开启辅助访问 切换到窄版

打印 上一主题 下一主题

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

[复制链接]
作者:langhunbei 
版块:
嵌入式操作系统 linux 发布时间:2020-9-13 20:20:05
21110
楼主
跳转到指定楼层
| 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Written by Sk August 10, 2020

监管工具非常重要,每个系统管理员都知道这一点。在资源监管应用程序的帮助下,我们可以在任务运行时持续观察系统资源的分配是否处于健康状态。今天,我们将讨论两个系统资源监视器,即BashtopBpytop,用于监管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位真色彩的终端
  • Bash 4.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 20.10起,Bashtop就可以在官方Ubuntu存储库中使用。
要在Ubuntu和Linux Mint等衍生系统上安装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 http://github.com/aristocratos/bashtop.git上面的命令将克隆Bashtop官方Github仓库中的内容到当前目录下名为“Bashtop”的文件夹中。进入克隆目录:
$ cd bashtop并运行以下命令从源代码安装Bashtop:
$ sudo make install要卸载它,只需在bashtop目录下运行以下命令:
$ sudo make uninstallBpytop是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 http://github.com/aristocratos/bpytop.git上面的命令会将仓库克隆本地目录“bpytop”中。进入该目录,并使用如下命令来安装它:
$ cd bpytop $ sudo make install要卸载Bpytop,只需在Bpytop目录下运行以下命令:
如前所述,Bashtop和Bpytop的作用是相同的,即监视系统资源并显示CPU、内存、磁盘、进程和网络等的统计数据。
要开始监控你的Linux系统资源,运行Bashtop或Bpytop,如下所示:
$ bashtop或者,
$ bpytop在Linux中使用Bashtop监视系统资源
正如你在上面的输出中看到的,Bashtop显示了以下细节:

  • CPU使用率
  • 处理器时钟速度
  • CPU总使用率
  • 每个CPU核心的使用情况
  • 总内存
  • 已使用内存
  • 空闲内存
  • 高速缓存
  • 可用高速缓存
  • 交换空间使用率(已使用和空闲)
  • 磁盘的当前读取和写入速度
Bashtop/Bpytop的默认刷新速率是2500毫秒。按(+,A, a)键可以向更新计时器添加100ms的时间。按(-,S, s)键可以从更新计时器中减去100ms。
选择和查看进程使用向上/向下键浏览进程或使用情况。按向上翻页向下翻页可以在进程列表中进行翻页。按(HomeEnd)键跳转到进程列表的第一页或最后一页。
进程部分以列的方式显示以下详细信息:

  • 进程ID (PID)
  • 进程名称
  • 参数
  • 线程
  • 进程的所有者
  • 进程的内存使用细节
  • 进程的CPU使用情况
您可以使用(左右)箭头键在列之间切换。
进程名按PID降序排列。也就是说,最大的PID将显示在顶部。您可以使用(R, r)键来逆转进程部分的排序顺序。
要显示所选进程的详细信息,请按回车键。
在Bashtop中查看所选进程的详细信息
要关闭选定的进程的详细信息框,请按ENTER键。
要按特定字符串过滤进程,按(F, f)键并键入字符串。例如,如果您键入"ssh",您将看到所有以"ssh"字母开头的进程。
在Bashtop中通过特定字符串过滤进程
终止Bashtop中的进程
(K, k)键,用SIGKILL杀死选中的进程。
这等同于“kill -9 ”命令。
中断进程显示Bashtop帮助内容
你可以按Esc, M, M键打开Bashtop/Bpytop主菜单。
Bashtop and Bpytop config files are stored in "$HOME/.config/bashtop" and "$HOME/.config/bpytop" folders respectively.
Bashtop和Bpytop配置文件存储在"$HOME/中。配置/ bashtop“ *和”$ HOME /。分别配置/ bpytop“文件夹中。
您可以通过查看当前的配置文件来获取Bashtop/Bpytop的配置选项。
Bashtop配置文件:
$ cat ~/.config/bashtop/bashtop.cfgBpytop配置文件:
$ 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 themecolor_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 graphsupdate_ms="2300"#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive"#* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directlyproc_sorting="pid"#* Reverse sorting order, "true" or "false"proc_reversed="false"#* Show processes as a treeproc_tree="false"#* Check cpu temperature, only works if "sensors", "vcgencmd" or "osx-cpu-temp" commands is availablecheck_temp="false"#* Draw a clock at top of screen, formatting according to strftime, empty string to disabledraw_clock="%X"#* Update main ui when menus are showing, set this to false if the menus is flickering too much for comfortbackground_update="true"#* Custom cpu model name, empty string to disablecustom_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 powerproc_per_core="false"#* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with spacedisks_filter=""#* Enable check for new version from github.com/aristocratos/bashtop at startupdate_check="true"#* Enable graphs with double the horizontal resolution, increases cpu usagehires_graphs="false"#* Enable the use of psutil python3 module for data collection, default on OSXuse_psutil="true"只要根据您的喜好更改设置。
或者,您可以通过按"m"键从Bashtop/Bpytop TUI查看当前选项。
Bashtop选项窗口
本文译自: Monitor System Resources With Bashtop And Bpytop In Linux
作者: Sk
译者: 生材有道
校对: 开源科学计算
原文及本文遵循: [CC BY-NC4.0协议]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表