Loading...
Loading...
Compare original and translation side by side
Skill by ara.so — Daily 2026 Skills collection.
htopiostatvm_statpowermetricslaunchctl来自 ara.so 的技能 — 2026每日技能合集。
htopiostatvm_statpowermetricslaunchctlgit clone https://github.com/matthart1983/syswatch.git && cd syswatch
cargo build --release
./target/release/syswatchCrates.io, Homebrew, and pre-built binaries are planned for the v0.1 release.
git clone https://github.com/matthart1983/syswatch.git && cd syswatch
cargo build --release
./target/release/syswatchCrates.io、Homebrew 以及预编译二进制包计划在 v0.1 版本中推出。
undefinedundefined
---
---1 2 3 4 5 6 7 8 9 Overview / CPU / Mem / Disks / FS / Procs / GPU / Power / Services
0 - + Net / Timeline / Insights
Tab / Shift-Tab Cycle tabs forward / backward
↑ / ↓ Select row (Procs, Services tabs)
s Cycle sort column (Procs, Services tabs)
← / → Scrub session backward / forward (Timeline tab)
Home / End Jump to oldest sample / return to live
p Pause collection
q / Ctrl-C Quit1 2 3 4 5 6 7 8 9 概览 / CPU / 内存 / 磁盘 / 文件系统 / 进程 / GPU / 电源 / 服务
0 - + 网络 / 时间线 / 分析见解
Tab / Shift-Tab 向前/向后切换标签页
↑ / ↓ 选择行(进程、服务标签页)
s 切换排序列(进程、服务标签页)
← / → 向前/向后回溯会话(时间线标签页)
Home / End 跳转到最早记录 / 返回实时状态
p 暂停数据收集
q / Ctrl-C 退出程序| Key | Tab | Data Source / Replaces |
|---|---|---|
| Overview | Dashboard of all subsystems |
| CPU | |
| Memory | |
| Disks | |
| Filesystems | |
| Procs | |
| GPU | |
| Power | |
| Services | |
| Net | |
| Timeline | Session log + scrubber |
| Insights | Plain-English anomaly cards |
| 按键 | 标签页 | 数据源 / 替代工具 |
|---|---|---|
| 概览 | 所有子系统的仪表盘 |
| CPU | |
| 内存 | |
| 磁盘 | |
| 文件系统 | |
| 进程 | |
| GPU | |
| 电源 | |
| 服务 | |
| 网络 | |
| 时间线 | 会话日志 + 回溯器 |
| 分析见解 | 通俗易懂的异常提示卡片 |
src/
├── main.rs CLI entry point + arg parsing
├── app.rs Event loop, tab state, scrub plumbing
├── collect/
│ ├── collector.rs sysinfo-backed CPU/Mem/Procs + dispatch
│ ├── gpu.rs system_profiler / sysfs DRM
│ ├── power.rs ioreg / pmset / sysfs power_supply
│ ├── services.rs launchctl / systemctl
│ └── ring.rs Bounded history ring + nth_back for scrubbing
├── insights/ Pure functions over (History, &Snapshot)
├── tabs/ One file per tab — thin renderers over the model
└── ui/
├── chrome.rs Header, tab bar, footer
├── palette.rs Single color source of truth
└── widgets.rs block_bar, sparkline, panel helperssrc/
├── main.rs CLI入口 + 参数解析
├── app.rs 事件循环、标签页状态、回溯机制
├── collect/
│ ├── collector.rs 基于sysinfo的CPU/内存/进程数据收集 + 调度
│ ├── gpu.rs system_profiler / sysfs DRM
│ ├── power.rs ioreg / pmset / sysfs power_supply
│ ├── services.rs launchctl / systemctl
│ └── ring.rs 有限容量历史环形缓冲区 + 回溯读取nth_back
├── insights/ 基于(History, &Snapshot)的纯函数逻辑
├── tabs/ 每个标签页对应一个文件 — 基于数据模型的轻量渲染器
└── ui/
├── chrome.rs 页眉、标签栏、页脚
├── palette.rs 统一颜色配置源
└── widgets.rs 块进度条、火花图、面板辅助工具src/collect/Snapshotcollector.rs// src/collect/my_subsystem.rs
use crate::collect::ring::Ring;
#[derive(Debug, Clone)]
pub struct MySnapshot {
pub value: f64,
pub label: String,
}
pub struct MyCollector {
history: Ring<MySnapshot>,
}
impl MyCollector {
pub fn new(capacity: usize) -> Self {
Self {
history: Ring::new(capacity),
}
}
pub fn collect(&mut self) -> MySnapshot {
// Replace with real data collection
let snap = MySnapshot {
value: 42.0,
label: "example".to_string(),
};
self.history.push(snap.clone());
snap
}
/// Returns the nth most recent snapshot (for scrubbing).
pub fn nth_back(&self, n: usize) -> Option<&MySnapshot> {
self.history.nth_back(n)
}
}collector.rscollect()src/collect/Snapshotcollector.rs// src/collect/my_subsystem.rs
use crate::collect::ring::Ring;
#[derive(Debug, Clone)]
pub struct MySnapshot {
pub value: f64,
pub label: String,
}
pub struct MyCollector {
history: Ring<MySnapshot>,
}
impl MyCollector {
pub fn new(capacity: usize) -> Self {
Self {
history: Ring::new(capacity),
}
}
pub fn collect(&mut self) -> MySnapshot {
// 替换为真实的数据收集逻辑
let snap = MySnapshot {
value: 42.0,
label: "example".to_string(),
};
self.history.push(snap.clone());
snap
}
/// 返回第n个最近的快照(用于回溯)。
pub fn nth_back(&self, n: usize) -> Option<&MySnapshot> {
self.history.nth_back(n)
}
}collector.rscollect()src/tabs/ratatuiFrame// src/tabs/my_tab.rs
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style},
widgets::{Block, Borders, Paragraph},
Frame,
};
use crate::collect::my_subsystem::MySnapshot;
pub fn render(f: &mut Frame, area: Rect, snap: &MySnapshot) {
let block = Block::default()
.title(" My Tab ")
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Cyan));
let text = Paragraph::new(format!(
"Value: {:.2}\nLabel: {}",
snap.value, snap.label
))
.block(block);
f.render_widget(text, area);
}app.rsui/chrome.rssrc/tabs/ratatuiFrame// src/tabs/my_tab.rs
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style},
widgets::{Block, Borders, Paragraph},
Frame,
};
use crate::collect::my_subsystem::MySnapshot;
pub fn render(f: &mut Frame, area: Rect, snap: &MySnapshot) {
let block = Block::default()
.title(" My Tab ")
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Cyan));
let text = Paragraph::new(format!(
"Value: {:.2}\nLabel: {}",
snap.value, snap.label
))
.block(block);
f.render_widget(text, area);
}app.rsui/chrome.rssrc/insights/// src/insights/my_insight.rs
use crate::collect::my_subsystem::MySnapshot;
#[derive(Debug, Clone)]
pub struct InsightCard {
pub title: String,
pub body: String,
pub suggested_tab: &'static str,
}
pub fn check(snap: &MySnapshot) -> Vec<InsightCard> {
let mut cards = vec![];
if snap.value > 90.0 {
cards.push(InsightCard {
title: "High value detected".to_string(),
body: format!(
"Current value is {:.1}, which exceeds the 90.0 threshold.",
snap.value
),
suggested_tab: "my_tab",
});
}
cards
}insights/mod.rssrc/insights/// src/insights/my_insight.rs
use crate::collect::my_subsystem::MySnapshot;
#[derive(Debug, Clone)]
pub struct InsightCard {
pub title: String,
pub body: String,
pub suggested_tab: &'static str,
}
pub fn check(snap: &MySnapshot) -> Vec<InsightCard> {
let mut cards = vec![];
if snap.value > 90.0 {
cards.push(InsightCard {
title: "High value detected".to_string(),
body: format!(
"Current value is {:.1}, which exceeds the 90.0 threshold.",
snap.value
),
suggested_tab: "my_tab",
});
}
cards
}insights/mod.rsRing<T>src/collect/ring.rsRingnth_backuse crate::collect::ring::Ring;
// Create a ring holding 3600 samples (1 hour at 1 Hz)
let mut ring: Ring<f64> = Ring::new(3600);
// Push a new sample each tick
ring.push(42.0);
// In scrub mode, app.rs tracks `scrub_offset: usize`
// 0 = live, N = N ticks in the past
let scrub_offset = 5; // 5 seconds ago
if let Some(val) = ring.nth_back(scrub_offset) {
println!("Value 5s ago: {}", val);
}app.rs←→scrub_offsetsrc/collect/ring.rsRing<T>Ringnth_backuse crate::collect::ring::Ring;
// 创建一个可存储3600个样本的环形缓冲区(1 Hz频率下存储1小时数据)
let mut ring: Ring<f64> = Ring::new(3600);
// 每次更新时推入新样本
ring.push(42.0);
// 在回溯模式下,app.rs 跟踪 `scrub_offset: usize`
// 0 = 实时状态,N = 过去N次更新的状态
let scrub_offset = 5; // 5秒前的状态
if let Some(val) = ring.nth_back(scrub_offset) {
println!("Value 5s ago: {}", val);
}app.rs←→scrub_offsetundefinedundefined
Build with a feature:
```bash
cargo build --release --features gpu-nvidia
cargo build --release --features smart
cargo build --release --features gpu-nvidia,smart
启用特性构建:
```bash
cargo build --release --features gpu-nvidia
cargo build --release --features smart
cargo build --release --features gpu-nvidia,smartioreg AGXAccelerator PerformanceStatisticssudo powermetricsioreg AGXAccelerator PerformanceStatisticssudo powermetrics/sys/class/thermal//sys/class/drm/sys/class/power_supply/sys/class/thermal//sys/class/drm/sys/class/power_supply// In app.rs, scrub_offset == 0 means "live"
pub struct App {
pub scrub_offset: usize,
// ...
}
// In a tab renderer:
pub fn render(f: &mut Frame, area: Rect, app: &App) {
let snap = if app.scrub_offset == 0 {
app.collector.latest()
} else {
app.collector.nth_back(app.scrub_offset)
.unwrap_or_else(|| app.collector.latest())
};
// render snap...
}// 在app.rs中,scrub_offset == 0 表示"实时状态"
pub struct App {
pub scrub_offset: usize,
// ...
}
// 在标签页渲染器中:
pub fn render(f: &mut Frame, area: Rect, app: &App) {
let snap = if app.scrub_offset == 0 {
app.collector.latest()
} else {
app.collector.nth_back(app.scrub_offset)
.unwrap_or_else(|| app.collector.latest())
};
// 渲染snap...
}papp.paused = truecollect()if !app.paused {
app.collector.collect();
}papp.paused = truecollect()if !app.paused {
app.collector.collect();
}| Symptom | Fix |
|---|---|
| Ensure Xcode Command Line Tools are installed: |
| GPU tab shows "no data" on Apple Silicon | Normal without sudo for temp/power; util + memory should appear via ioreg |
| Services tab is slow to update | Expected — launchctl/systemctl are subprocess-heavy; they run on the 5 s slow loop |
| Timeline scrubbing shows stale data | The ring capacity is set at startup; scrubbing is limited to collected history |
| Net tab shows no interfaces | May need to run as a user with access to network stats; check |
| Use lowercase tab names: |
| 症状 | 解决方法 |
|---|---|
macOS下 | 确保安装了Xcode命令行工具: |
| Apple Silicon上GPU标签页显示"无数据" | 温度/功耗数据需要sudo,属于正常情况;利用率和内存数据应通过ioreg显示 |
| 服务标签页更新缓慢 | 属于预期情况 — launchctl/systemctl依赖子进程,运行在5秒慢速循环中 |
| 时间线回溯显示过期数据 | 环形缓冲区容量在启动时设置;回溯范围仅限于已收集的历史数据 |
| 网络标签页无接口显示 | 可能需要使用有权限访问网络统计的用户运行;检查 |
| 使用小写标签页名称: |