在Linux系统上使用Bashtop和Bpytop监控系统资源
发布时间:2023-07-15 15:02:36 所属栏目:Linux 来源:
导读:监控工具对于系统管理是非常重要的,每个 Linux 系统管理员都知道这一点。借助资源监控程序,我们可以在任务运行时不断地观察系统资源的运行状况。
本文将介绍两个 Linux 和类 Unix 操作系统中的系统资源监视器:
本文将介绍两个 Linux 和类 Unix 操作系统中的系统资源监视器:
监控工具对于系统管理是非常重要的,每个 Linux 系统管理员都知道这一点。借助资源监控程序,我们可以在任务运行时不断地观察系统资源的运行状况。 本文将介绍两个 Linux 和类 Unix 操作系统中的系统资源监视器:Bashtop 和 Bpytop。Bashtop 和 Bpytop 资源监视器可以显示系统的使用情况,以及处理器、内存、磁盘、网络和进程的状态,对系统管理非常有帮助。 Bashtop 和 Bpytop 没有太大的区别,这两个工具的目的和功能特性基本相同。唯一的区别是两者是用不同的编程语言所开发的。Bashtop 使用 Bash Shell 开发,而 Bpytop 使用 Python 开发。Bashtop 和 Bpytop 都支持 GNU/Linux,Mac OS 和 FreeBSD 。 在Linux上安装Bashtop资源监视器 Bashtop 可以在安装了以下依赖项的现代 Linux 系统上运行: 终端支持 24 位 Truecolor, Bash 4.4 或更高版本, GIT GNU Coreutils, GNU sed, GNU awk, GNU grep, procps-ng 的 ps(v3.1.15或更高版本), Python 3.6或更高版本, Psutil(v5.7.0或更高版本), 可选包: Lm传感器 – 显示CPU温度, iostat(sysstat的一部分) – 显示磁盘读/写状态,并且不使用 psutil 数据收集, curl -下载 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 从源码安装Bashtop 你也可以下载源码进行编译安装。当然前提是,你要确保已安装上述依赖项。 可以使用以下 git 命令将 Bashtop 源代码下载到本地: $ git clone https://github.com/aristocratos/bashtop.git 上面的命令将在当前目录中创建名为 bashtop 的目录,并将 Bashtop github 源码库的内容下载到里面。我们首先切换到它的源码目录: $ cd bashtop 再执行以下命令从源码安装 Bashtop : $ sudo make install 如果要卸载,只需切换到 bashtop 目录并运行以下命令: $ sudo make uninstall 在Linux上安装Bpytop资源监视器 Bpytop 是 Bashtop 的 python 版本。开发者介绍说 Bpytop 比 Bashtop 速度快得多,并且具有更多功能。 从源码安装Bpytop 在安装 Bpytop 之前,请先确保你的系统已经安装以下依赖项: 具有 24 位 truecolor 支持的终端, Python 3(v3.6或更高版本), psutil 模块(v5.7.0或更高版本)。 安装必备组件后,使用以下 git 命令将 Bpytop 的源码克隆到本地: $ git clone https://github.com/aristocratos/bpytop.git 使用 cd 命令进入 bpytop 目录,按以下命令安装 bpytop: $ cd bpytop $ sudo make install 如果要卸载 Bpytop ,只需在 bpytop 目录里运行以下命令: $ sudo make uninstall 在Linux中使用Bashtop和Bpytop监视系统资源 想要开始监视您的 Linux 系统资源,需要先运行 Bashtop 或 Bpytop : $ bashtop 或 $ bpytop 输出示例: 从上面的输出界面中可以看到,Bashtop 可以显示以下信息: CPU使用率图表, 处理器时钟速度, 总CPU使用率, 每个CPU核的使用率, 总内存, 已用的内存, 可用内存, 高速缓存, 可用的缓存, 交换使用情况(已用的和可用的), 当前磁盘的读写速度。 Bashtop/Bpytop 的默认刷新率是2500毫秒,可以按(+,A,a)键增加 100 ms,按(-,S,s)键减少 100 ms。 查看过程信息 使用上/下键浏览进程及使用情况。按 Pg Up 和 Pg Down 键可在进程列表中上下翻页。按 home 或 End 键跳到进程列表中的第一页或最后一页。 进程部分按列显示以下详细信息: 进程ID(PID) 进程名称 参数 线程 进程的所有者 该进程的内存使用情况的详细信息 进程的CPU使用率 你可以使用 ← 或 → 箭头键在各列之间切换。 进程名称由 PID 降序排列,最大的 PID 将显示在顶部。您可以使用 R 或 r 键在“进程”部分中反转排序顺序。 如果需要显示所选过程的详细信息,可以按一下回车。 如果要关闭选定的过程详细信息,可以再次按一下回车键。 筛选进程 如果你想要根据特定字符串筛选出来需要的进程,可以按 F 键并输入字符串名称。例如,如果键入 ssh ,则将筛选出所有以 ssh 字符串开头的进程。 终止进程 可以通过按 T 键发送 SIGTERM 信号来终止选定的进程。 杀掉进程 可以通过按 K 键发送 SIGKILL 信号杀死选定的进程。 这个过程相当于 kill -9 命令。 中断程序 可以通过按 I 键发送 SIGINT中断选定的进程。 显示帮助 你也可以键入 F1,或者 H 键来显示帮助信息。 也可以通过按 Esc,M 键来调出 Bashtop/Bpytop 的主菜单。 配置Bashtop/Bpytop Bashtop 和 Bpytop 配置文件分别位于 $HOME/.config/bashtop 和 $HOME/.config/bpytop 文件夹中。 可以通过 cat 命令来查看 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 界面中按 M 来查看当前配置信息。 退出Bashtop/Bpytop 如果需要退出 Bashtop/Bpytop,只需按 Ctrl-C 或 Q 键即可 。 (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐