网淘吧来吧,欢迎您!

mactop技能使用说明

2026-03-31 新闻来源:网淘吧 围观:6
电脑广告
手机广告

Mactop 技能

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

先决条件

  • 已安装mactop:brew install mactop
  • PATH包含/usr/sbin: 访问sysctl所必需

用法

获取完整指标

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

解析关键指标

CPU使用率:

mactop

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

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第408256名访客 今日有0篇新文章/评论