一款基于 Python 语言的 Linux 资源监视器!

柳随风
发布于 2020-9-4 10:36
浏览
0收藏

大家好,我是 JackTian。

 

还记得前不久给大家推荐的《一款霸榜 GitHub 的开源 Linux 资源监视器!—— bashtop》吗?它是一个用 Bash 编写的 Linux 资源监视器。

 

昨天刚好闲逛 GitHub,发现这个作者又开源了一款基于 Python 语言的 Linux / OSX / FreeBSD 资源监视器 —— bpytop,其主要作用跟之前的 bashtop 大同小异,用于显示处理器,内存,磁盘,网络和进程的使用情况和状态。

 

首先我们先来看看 bpytop 资源监视器主界面。

一款基于 Python 语言的 Linux 资源监视器!-鸿蒙开发者社区

特征

  • 易使用,带有游戏启发的菜单系统;
  • 完全支持鼠标,所有带有突出显示键的按钮均可单击,并且鼠标滚动可在进程列表和菜单框中使用;
  • 快速反应灵敏的 UI,带有 UP,DOWN 键可自行过程选择;
  • 用于显示所选进程的详细统计信息的功能;
  • 具有过滤过程的能力,可输入多个过滤器;
  • 在排序选项之间轻松切换;
  • 将 SIGTERM,SIGKILL,SIGINT 发送到选定的进程;
  • 用于更改所有配置文件选项的 UI 菜单;
  • 网络使用情况的自动缩放图;
  • 如有新版本可用,可在菜单选项中进行显示;
  • 显示磁盘的当前读写速度;

 

一款基于 Python 语言的 Linux 资源监视器!-鸿蒙开发者社区

Bpytop 使用与 bashtop 相同的主题文件,因此为 bashtop 制作的任何主题都可以使用。

 

可根据自己的需求修改及设置 Main 配色,在自定义设置主题时,重新生成一个名为.theme的主题文件并设置默认变量赋值。

 

#Bashtop theme with default colors and black background
......
# Main background, empty for terminal default, need to be empty if you want transparent background
theme[main_bg]="#00"

# Main text color
theme[main_fg]="#cc"

# Title color for boxes
theme[title]="#ee"

# Higlight color for keyboard shortcuts
theme[hi_fg]="#90"

# Background color of selected item in processes box
theme[selected_bg]="#7e2626" 

# Foreground color of selected item in processes box
theme[selected_fg]="#ee"

# Color of inactive/disabled text
theme[inactive_fg]="#40"

# Misc colors for processes box including mini cpu graphs, details memory graph and details status text
theme[proc_misc]="#0de756"

# Cpu box outline color
theme[cpu_box]="#3d7b46"

# Memory/disks box outline color
theme[mem_box]="#8a882e"

# Net up/down box outline color
theme[net_box]="#423ba5"

# Processes box outline color
theme[proc_box]="#923535"

# Box divider line and small boxes line color
theme[div_line]="#30"

# Temperature graph colors
theme[temp_start]="#4897d4"
theme[temp_mid]="#5474e8"
theme[temp_end]="#ff40b6"

# CPU graph colors
theme[cpu_start]="#50f095"
theme[cpu_mid]="#f2e266"
theme[cpu_end]="#fa1e1e"

# Mem/Disk free meter
theme[free_start]="#223014"
theme[free_mid]="#b5e685"
theme[free_end]="#dcff85"

# Mem/Disk cached meter
theme[cached_start]="#0b1a29"
theme[cached_mid]="#74e6fc"
theme[cached_end]="#26c5ff"

# Mem/Disk available meter
theme[available_start]="#292107"
theme[available_mid]="#ffd77a"
theme[available_end]="#ffb814"

# Mem/Disk used meter
theme[used_start]="#3b1f1c"
theme[used_mid]="#d9626d"
theme[used_end]="#ff4769"

# Download graph colors
theme[download_start]="#231a63"
theme[download_mid]="#4f43a3"
theme[download_end]="#b0a9de"

# Upload graph colors
theme[upload_start]="#510554"
theme[upload_mid]="#7d4180"
theme[upload_end]="#dcafde"
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.

更多的主题配色,可通过 Bpytop 项目中的 themes 文件夹查看。

一款基于 Python 语言的 Linux 资源监视器!-鸿蒙开发者社区

安装

依赖项安装 Linux,使用 python3 和 git 安装

 

安装 psutil python 模块(可能需要sudo)

# python3 -m pip install psutil
  • 1.

依赖项安装 OSX,用于显示 CPU 温度。

# brew install osx-cpu-temp
  • 1.

手动安装 Linux,OSX 和 FreeBSD

# git clone https://github.com/aristocratos/bpytop.git
# cd bpytop
# sudo make install
  • 1.
  • 2.
  • 3.

 

命令行选项

USAGE: bpytop [argument]

Arguments:
    -m, --mini            Start in minimal mode without memory and net boxes  // 最小模式下启动
    -v, --version         Show version info and exit  // 显示版本信息并退出
    -h, --help            Show this help message and exit  // 显示此帮助信息并退出
    --debug               Start with loglevel set to DEBUG overriding value set in config
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

 

由此看来目前 bpytop 还处于开发阶段,接下来,还有很多要去做新功能:

一款基于 Python 语言的 Linux 资源监视器!-鸿蒙开发者社区

 

分类
收藏
回复
举报
回复
    相关推荐