Skip to content

发布版本 2.0.3:修复 df 权限错误及新增 excludeIowait 配置项#46

Merged
SunilWang merged 1 commit intomasterfrom
develop
Apr 7, 2026
Merged

发布版本 2.0.3:修复 df 权限错误及新增 excludeIowait 配置项#46
SunilWang merged 1 commit intomasterfrom
develop

Conversation

@SunilWang
Copy link
Copy Markdown
Owner

Background

Linux 桌面环境(GNOME/KDE)中,/run/user/1000/doc 等 FUSE
虚拟挂载点在非 root 权限下会导致 df 命令以 exit code 1
退出,进而使磁盘监控功能整体失败(#37)。

CPU 使用率在 I/O 密集型场景下存在虚高问题:iowait 期间 CPU
实际处于空闲状态,但被计入 overall 使用率,与 top
等工具的展示口径不一致(#39)。

Key Changes

  • LinuxAdapter.getDiskInfo() / getDiskUsage():当 df
    有有效 stdout 输出时,不再强依赖 exit code 为
    0,权限错误仅影响对应挂载点,不阻断整体磁盘数据返回
  • CPUConfig 新增 excludeIowait?: boolean(默认
    false),CPUMonitor.transformCPUUsage() 在该选项启用时从
    overall 中减去 iowaitiowait 字段本身不受影响
  • 受影响模块:src/adapters/linux-adapter.tssrc/monitors/c pu-monitor.tssrc/types/config.ts
  • 潜在风险:df 容错逻辑仅在 stdout 行数 ≥ 2
    时生效,完全失败场景仍正常抛出 MonitorError,无回归风险

Test Matrix

Platform Command Result
macOS npm run build
macOS npm run test:unit ✅ 160 passing
Other npm run test:linux / windows (if applicable) N/A
Lint npm run lint:check

Related Issues

Platform & Permissions

  • df 权限容错仅对 Linux 生效,macOS / Windows 不涉及
  • excludeIowait 仅在 Linux 采样数据中有意义(macOS / Windows
    适配器不返回 iowait 字段,设置后无副作用)

Documentation

  • Updated README.md / README-zh.md:全局配置示例补充
    excludeIowait,CPU 监控器章节新增配置项说明表格及代码示例

Additional Notes

- 修复 #37:Linux 下 df 遇到 FUSE 挂载点(如 /run/user/1000/doc)权限不足
  时不再整体失败,只要 stdout 有有效数据即正常返回其余磁盘信息
- 解决 #39:CPUConfig 新增 excludeIowait 选项(默认 false 保持现有行为),
  设为 true 时从 overall 使用率中剔除 iowait,适合 I/O 密集型场景
- 补充对应单元测试(linux-adapter: 4 个,cpu-monitor: 4 个)
- 同步更新 README.md 与 README-zh.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SunilWang SunilWang merged commit 400ba8d into master Apr 7, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude IOWAIT from CPU stats osu.drive failing

1 participant