home / skills / openclaw / skills / mactop

This skill retrieves real-time hardware metrics from Apple Silicon Macs via mactop, enabling monitoring of CPU, memory, GPU, power, thermal, and I/O.

npx playbooks add skill openclaw/skills --skill mactop

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.8 KB
---
name: mactop
description: |
  Retrieve real-time hardware metrics from Apple Silicon Macs using mactop's TOON format.
  Provides CPU, RAM, GPU, power, thermal, network, disk I/O, and Thunderbolt bus information.
  Use when the user wants system stats, hardware monitoring, or performance metrics on Apple Silicon Macs.
---

# Mactop Skill

Execute mactop in headless TOON mode and parse the output for hardware metrics.

## Prerequisites

- **mactop installed**: `brew install mactop`
- **PATH includes /usr/sbin**: Required for sysctl access

## Usage

### Get Full Metrics

```bash
mactop --format toon --headless --count 1
```

### Parse Key Metrics

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

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

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

**Power (total/CPU/GPU):**
```bash
mactop --format toon --headless --count 1 | grep -E "^  (TotalPower|CPUPower|GPUPower):" | awk '{print $2}'
```

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

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

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

**Network I/O (bytes/sec):**
```bash
mactop --format toon --headless --count 1 | grep -E "^(  InBytesPerSec|  OutBytesPerSec):" | awk '{print $2}'
```

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

## Options

| Option | Description |
|--------|-------------|
| `--count N` | Number of samples (default: 1) |
| `--interval MS` | Sample interval in milliseconds (default: 1000) |

## TOON Format

```
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
```

## Response Example

Format metrics in a readable box:

```
┌─ 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    │
└─────────────────────────────────────┘
```

## Troubleshooting

- **"sysctl not found"** → Add `/usr/sbin` to PATH
- **No output** → Verify mactop is installed: `which mactop`

Overview

This skill retrieves real-time hardware metrics from Apple Silicon Macs by running mactop in headless TOON mode and parsing its output. It provides CPU, RAM, GPU, power, thermal, network, disk I/O, and Thunderbolt bus information in a concise, script-friendly format. Use it to fetch current system stats for monitoring, alerting, or performance analysis on Apple Silicon.

How this skill works

The skill runs mactop with --format toon and --headless to produce structured TOON output, then extracts key fields (cpu_usage, memory, gpu_usage, power, thermal_state, temperatures, system_info, network and Thunderbolt data). It can run single samples or multiple intervals via --count and --interval and converts raw values (bytes, watts) into readable metrics for display or automation. Common shell pipelines (grep/awk) are demonstrated for quick extraction of each metric.

When to use it

  • Gather live system metrics on Apple Silicon Macs for dashboards or logs.
  • Automate performance checks in CI or maintenance scripts before heavy workloads.
  • Alert on thermal or power anomalies during stress testing or prolonged runs.
  • Collect short-lived samples for debugging GPU/CPU utilization spikes.
  • Inventory connected Thunderbolt devices and basic system info remotely.

Best practices

  • Install mactop via Homebrew and ensure /usr/sbin is in PATH to avoid sysctl errors.
  • Use --count >1 with --interval to sample trends rather than single snapshots.
  • Convert memory bytes to GB and format power/temperature units consistently in your scripts.
  • Fail gracefully when mactop is missing: check which mactop and provide clear instructions.
  • Run parsing commands under a restricted timeframe to avoid excessive sampling overhead.

Example use cases

  • One-line shell script to print CPU and RAM usage for a monitoring agent.
  • Periodic cron job collecting TOON samples and pushing them to a time-series DB.
  • Pre-deployment health check that verifies thermal_state is Normal and SoC < threshold.
  • Live troubleshooting where GPU and CPU power consumption are correlated with app behavior.
  • Asset audit that lists system_info.Name and connected Thunderbolt buses for inventory.

FAQ

What do I need installed to use this skill?

Install mactop (brew install mactop) and ensure /usr/sbin is included in your PATH so sysctl works.

How do I get a trend rather than a single sample?

Use --count N with --interval MS to capture multiple samples at the specified millisecond interval.