OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  mactop-stats:针对 Apple Silicon Mac 的实时硬件指标与功耗监控

mactop-stats:针对 Apple Silicon Mac 的实时硬件指标与功耗监控

 
  git ·  2026-02-07 04:38:56 · 3 次点击  · 0 条评论  

名称: mactop
描述: |
通过 mactop 的 TOON 格式获取 Apple Silicon Mac 的实时硬件指标。
提供 CPU、RAM、GPU、功耗、温度、网络、磁盘 I/O 和 Thunderbolt 总线信息。
适用于用户需要获取 Apple Silicon Mac 的系统状态、硬件监控或性能指标时。


Mactop 技能

在无头 TOON 模式下执行 mactop 并解析其输出,以获取硬件指标。

前提条件

  • 已安装 mactopbrew install mactop
  • PATH 包含 /usr/sbin:用于 sysctl 访问

使用方法

获取完整指标

mactop --format toon --headless --count 1

解析关键指标

CPU 使用率:

mactop --format toon --headless --count 1 | grep "^cpu_usage:" | awk '{print $2}'

内存(已用/总量 GB):

mactop --format toon --headless --count 1 | grep -E "^  (Used|Total):" | awk '{printf "%.1f", $2/1073741824}'

GPU 使用率:

mactop --format toon --headless --count 1 | grep "^gpu_usage:" | awk '{print $2}'

功耗(总功耗/CPU/GPU):

mactop --format toon --headless --count 1 | grep -E "^  (TotalPower|CPUPower|GPUPower):" | awk '{print $2}'

散热状态:

mactop --format toon --headless --count 1 | grep "^thermal_state:" | awk '{print $2}'

温度:

mactop --format toon --headless --count 1 | grep "^  SocTemp:" | awk '{print $2}'

芯片信息:

mactop --format toon --headless --count 1 | grep "^  Name:" | awk '{print $2}'

网络 I/O(字节/秒):

mactop --format toon --headless --count 1 | grep -E "^(  InBytesPerSec|  OutBytesPerSec):" | awk '{print $2}'

Thunderbolt 总线:

mactop --format toon --headless --count 1 | grep "^    Name:" | awk '{print $2}'

选项

选项 说明
--count N 采样次数(默认:1)
--interval MS 采样间隔(毫秒,默认:1000)

TOON 格式示例

timestamp: "2026-01-25T20:00:00-07:00"
soc_metrics:
  CPUPower: 0.15
  GPUPower: 0.02
  TotalPower: 8.5
  SocTemp: 42.3
memory:
  Total: 25769803776
  Used: 14852408320
  Available: 10917395456
cpu_usage: 5.2
gpu_usage: 1.8
thermal_state: Normal
system_info:
  Name: Apple M4 Pro
  CoreCount: 12

响应示例

将指标格式化为易读的框体:

┌─ Apple M4 Pro ──────────────────────┐
│ CPU:   5.2%  |  RAM: 13.8/24.0 GB  │
│ GPU:   1.8%  |  Power: 8.5W total  │
│ Thermal: Normal  |  SoC: 42.3°C    │
└─────────────────────────────────────┘

故障排除

  • “sysctl 未找到” → 将 /usr/sbin 添加到 PATH 中
  • 无输出 → 验证 mactop 是否已安装:which mactop
3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor