[Request]: container machine stats to show machine resource usage
- Dominant language
- Swift
- Stars
- 49.9k
- Forks
- 1.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 22
Description
### Feature or enhancement request details
`container stats` shows live CPU / memory / network / block-I/O / process stats for containers, but there is no equivalent for container machines — `container machine` only covers lifecycle (create, run, ls, inspect, set, set-default, logs, stop, rm). When running a machine as a persistent Linux environment there is no first-class way to see its resource usage; today you would have to discover the machine's internal backing-container id and run `container stats `.
**Proposed:** add `container machine stats [] [--no-stream] [--format table|json|yaml|toml]`, the machine counterpart to `container stats`:
- Resolves the target machine like `container machine inspect` (positional id, default machine if omitted).
- A running machine is already backed by a container (`MachineSnapshot.containerId`), so the data comes straight from the existing path (`ContainerClient().stats(id:)`) — the same call `container machine run` already uses on the backing container — so no new collection logic and no new API route.
- Output labeled by machine id; same streaming / `--no-stream` / format options as `container stats`.
Example:
```
$ container machine stats my-machine
Machine ID Cpu % Memory Usage Net Rx/Tx Block I/O Pids
my-machine 0.42% 512.00 MiB / 2.00 GiB 1.20 KiB / 0.80 KiB 4.00 MiB / 0.00 KiB 7
```
I've opened a PR implementing this: #1920 — it extracts the shared sampling / CPU% / rendering out of `container stats` into a helper reused by both commands, with unit + integration tests and docs.
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Review the existing container stats and container machine inspect/run command paths, focusing on MachineSnapshot.containerId and ContainerClient().stats(id:). Compare the requested streaming and formatting behavior with PR #1920 and its unit, integration, and documentation changes; done means machine-labeled stats work for an explicit or default machine without new collection logic or an API route.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100