前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >一款基于 Python 语言的 Linux 资源监视器!

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

作者头像
杰哥的IT之旅
发布2020-08-11 14:18:11
7270
发布2020-08-11 14:18:11
举报
文章被收录于专栏:GitHub专栏GitHub专栏

大家好,我是 JackTian。

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

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

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

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

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

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

代码语言:javascript
复制
#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"

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

安装

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

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

代码语言:javascript
复制
# python3 -m pip install psutil

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

代码语言:javascript
复制
# brew install osx-cpu-temp

手动安装 Linux,OSX 和 FreeBSD

代码语言:javascript
复制
# git clone https://github.com/aristocratos/bpytop.git
# cd bpytop
# sudo make install
命令行选项
代码语言:javascript
复制
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

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

最后贴下该项目 GitHub 地址,大家感兴趣的可前去围观:

https://github.com/aristocratos/bpytop

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-08-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 杰哥的IT之旅 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 特征
  • 安装
  • 命令行选项
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档