# sys_metrics

CPU and RAM sample on Linux/macOS. System values are not container limits; cgroup quota and memory headroom are separate. Missing fields are unavailable.

**In short:** Risk class [`read`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `sys_metrics`; over HTTP send `"tool": "sys_metrics"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

No other arguments.

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `observed_at_ms` | `integer` | yes | Unix milliseconds when the observation request completed. |
| `visible_cgroup_cpu` | `object` | no | Raw charged CPU-time delta and local quota, only for a qualified visible cgroup-v2 root. This is not a host percentage or effective ancestor entitlement. |
| `visible_cgroup_memory` | `object` | no | Current process's cgroup memory limits across the visible hierarchy, if known. Neither a host memory reading nor a guarantee of all hidden ancestor limits. |
| `visible_system_cpu` | `object` | no | CPU execution percentage across the visible system, not the caller's cgroup quota. Absent if a valid counter delta could not be established. |
| `visible_system_memory` | `object` | no | Visible system memory, as reported by the OS/library; not container entitlement. |

## Examples

**MCP**

```json
{
  "name": "sys_metrics",
  "arguments": {
    "machine": "<machine>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.dev/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "x-cmdop: 1" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"sys_metrics","args":{}}'
```

## Limits

The call times out after 10 s (`timed_out`). Available since version 0.1.18. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).

## Notes

The values describe the system visible to the machine program. The Linux cgroup fields, when
available, describe observed CPU quota and memory headroom separately; they are not host-wide
percentages or free RAM. Those fields are unavailable on macOS. An absent reading means
unavailable, not zero. Native Windows is not supported by this tool.

This is a manual CPU and memory observation. For automatic reporting in Computers, see
[`resource_reporting`](https://docs.cmdop.ai/reference/config/ceiling-json.md).
