️ Real-time system monitor for Apple Silicon Macs (M1–M5). No sudo. TUI, JSON/Prometheus metrics server, and Rust library.
️ Real-time system monitor for Apple Silicon Macs (M1–M5). No sudo. TUI, JSON/Prometheus metrics server, and Rust library.
macmon – Mac Monitormacmon is a sudoless performance monitor for Apple Silicon Macs. It reads real-time CPU / GPU / ANE power usage, temperatures, and memory stats through a private macOS API — the same data powermetrics exposes — without requiring root access.
brew install macmonInstall using MacPorts:
sudo port install macmonInstall using Cargo:
cargo install macmonInstall using Nix:
nix-env -i macmonUsage: macmon [OPTIONS] [COMMAND]
Commands:
pipe Output metrics in JSON format
serve Serve metrics over HTTP
debug Print debug information
stress Generate load for testing metrics
help Print this message or the help of the given subcommand(s)
Options:
-i, --interval <INTERVAL> Update interval in milliseconds [default: 1000]
-h, --help Print help
-V, --version Print versionRun macmon without a subcommand to open the terminal UI.
Controls:
c - change color
v - switch charts view: gauge / sparkline
d - toggle detailed CPU/RAM view
r - switch ratio mode: scaled / active
q - quitYou can use the pipe subcommand to output metrics in JSON format, which makes it suitable for piping into other tools or scripts. For example:
macmon pipe | jqThis command runs macmon in "pipe" mode and sends the output to jq for pretty-printing.
You can also specify the number of samples to collect using the -s or --samples parameter (default: 0, which runs indefinitely), and set the update interval in milliseconds using the -i or --interval parameter (default: 1000 ms). For example:
macmon pipe -s 10 -i 500 | jqThis will collect 10 samples with an update interval of 500 milliseconds.
You can use the serve subcommand to expose metrics over HTTP. This is useful for integrating with monitoring systems like Prometheus and Grafana.
macmon serve # default port 9090, interval 1000ms
macmon serve --host 127.0.0.1 # listen on localhost only
macmon serve -p 8080 # custom port
macmon serve -i 500 # sampling interval 500ms
macmon serve & # run in backgroundTwo endpoints are available:
| Endpoint | Format | Description |
|---|---|---|
GET /json |
JSON | Current metrics snapshot (same format as pipe --soc-info) |
GET /metrics |
Prometheus | Metrics in Prometheus text format |
To start macmon serve automatically on login and keep it running:
macmon serve --install # install and start (default port 9090)
macmon serve --port 8080 --install # with custom port
macmon serve --host 127.0.0.1 --install # listen on localhost only
macmon serve --uninstall # stop and removeThis creates a launchd agent at ~/Library/LaunchAgents/com.macmon.plist that auto-starts on login and restarts on crash.
The /metrics endpoint exposes metrics in Prometheus format. See examples/grafana for a local demo stack with Prometheus and Grafana.
…Use macmon stress to generate load while checking metric behavior:
macmon stress
macmon stress pulse --duration 30
macmon stress cpu --duration 30
macmon stress cpu --workers 8 --duration 30
macmon stress gpu --duration 30
macmon stress all --duration 30The default pulse mode generates a predictable cyclic CPU load with a fixed 50% duty cycle on half of the logical CPUs. The cpu and gpu modes continuously load only the selected processor, while all loads both. The cpu and all modes use all logical CPUs unless --workers is specified; --workers has no effect in gpu mode.
The pipe command and the HTTP /json endpoint return the same metrics:
…active_ratio is the share of the sampling interval during which the processor was doing any work. scaled_ratio is the same measure adjusted for operating frequency, showing the share of the processor's maximum possible capacity that was used.
For interval $T$, $t_i$ is the time spent doing work at frequency $f_i$, and $f_\text{max}$ is the hardware maximum frequency for the CPU cluster or GPU. The product $T f_\text{max}$ is the theoretical maximum frequency-time the processor could deliver at full load without thermal or power throttling:
R_\text{active} = \frac{\sum_i t_i}{T}
\qquad
R_\text{scaled} = \frac{\sum_i t_i f_i}{T f_\text{max}}CPU ratios are calculated per core and averaged across the cluster. A core that did no work contributes zero; combined CPU ratios average all cores from both clusters:
R_\text{cluster} = \frac{1}{N_\text{cores}}\sum_j R_jExamples:
active = 1.0, scaled = 0.5.active = 0.5, scaled = 0.5.active = scaled = 0.1.macmon can be used as a Rust library to collect Apple Silicon metrics in your own applications.
Add it to your project:
cargo add macmon --no-default-featuresThe default app feature enables the macmon executable and its terminal UI dependencies. Disable default features when using macmon only as a library.
Run the standalone demo app:
cargo run --manifest-path examples/demo-app/Cargo.tomlThen use the Sampler to collect metrics:
…get_metrics(duration_ms) blocks the calling thread while collecting one IOReport delta over the complete interval. For a UI, server, or async application, create the sampler inside a dedicated worker thread and send the completed metrics back through a channel:
…Creating Sampler inside the worker keeps its low-level macOS handles on that thread. In an async runtime, use its blocking-thread facility rather than calling get_metrics directly from an executor worker.
All contributions are welcome! Feel free to open an issue or submit a pull request.
Distributed under the MIT License.
No open issues yet, or sync has not completed.