# System inventory

> What every device is and runs (hardware, operating system, packages, ports, processes, users and services), kept current in the realm.

The security sensor on each device reads what the machine is and what it runs, and keeps the realm's copy current.
You see it across the whole realm: which operating systems you have, which packages are installed where, which
ports are open, and which services and browser extensions are running.

## Before you begin

- **Privilege:** a realm administrator's session, with `READ` on the realm's configuration, which `RealmViewer` and
  `RealmOwner` hold, in the realm or a realm above it ([Who can call](../../api/#who-can-call)).
- **Where:** the API.
- **The device's sensor must be running.** It is on every enrolled device unless it was stopped; check with
  [Health and actions](../health-and-actions/).

## How it works

The sensor reads the inventory when it starts and every hour after, and sends what changed. The realm keeps the
latest state of each device, in your realm's [security log](../../../detection-response/security-log/).

| Kind | In the API | What it lists |
|---|---|---|
| System | `system` | Host name, operating system and its version, kernel and architecture |
| Hardware | `hardware` | Processor, memory and serial number |
| Packages | `packages` | Installed packages and their versions |
| Hotfixes | `hotfixes` | Installed operating-system updates, where the system has them |
| Browser extensions | `browserExtensions` | Extensions installed in the device's browsers |
| Processes | `processes` | Running processes |
| Interfaces, networks, protocols | `interfaces`, `networks`, `protocols` | Network interfaces, their addresses and settings |
| Ports | `ports` | Open and listening ports, and what holds them |
| Users and groups | `users`, `groups` | Local accounts and groups |
| Services | `services` | System services and their state |

## Set it up

Nothing to turn on. Through the API ([Call the API](../../../develop/api/)), read the realm's totals (devices by
operating system, the most common packages, listening ports, processes, users and services), then a page of one kind;
`agent` narrows either to one device:

```sh
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/inventory/summary \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

curl "https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/inventory/packages?agent=<sensor id>" \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{"page": 1, "pageSize": 50}'
```

A page answers `data`, `totalPages` and `totalCount`. `GET .../inventory/<kind>/fields` lists the fields a kind
filters on. Add `?agent=<sensor id>` to any of these for one device; the sensor id is `dar.agentId` on the
[device records](../device-records/).

## If it fails

| Status | When | What to do |
|---|---|---|
| `403` | You don't administer this realm | Ask a realm administrator to [grant you](../../api/#who-can-call) `RealmViewer` |
| `400`, `no inventory kind '<kind>'` | The kind isn't one of those above | Use a kind from the table |

## Limits and defaults

| What | Default | Set by |
|---|---|---|
| First inventory of a new device | Within minutes of its sensor starting | |
| Refresh | Every hour | The sensor's [group configuration](../../../detection-response/sensors/group-configuration/) |
| History | None: the latest state only | |
| A removed device's inventory | Cleared when its removal deletes its sensor | |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A new device has no inventory yet | Its sensor hasn't finished its first read | Wait a few minutes; check the sensor is `running` with the `status` action |
| A change on the device isn't shown | The next hourly read hasn't run | Wait for it, or restart the sensor (`restart-dar`), which reads again when it starts |
| A device's inventory stopped changing | Its sensor stopped, or the device is offline | Check `connected`, then [Health and actions](../health-and-actions/) |

## Audit record

Reading the inventory writes nothing to the realm's audit trail.

## Good to know

- **Read-only.** Inventory reads the device; it changes nothing.
- **Latest state, not history.** Each kind holds what the device has now, so it has no time range.
- **What and how often** are the sensor's group configuration; see
  [Group configuration](../../../detection-response/sensors/group-configuration/).

## Coming next

- **Known vulnerabilities in these packages**: see
  [What's next for detection](../../../detection-response/detection/whats-next/#vulnerability-detection).
- **Applications as a list of their own**: see [App inventory](../whats-next/#app-inventory).

## Related

- [Health and actions](../health-and-actions/): the device client's own state.
- [Configuration assessment](../../../detection-response/detection/configuration-assessment/): the device's settings,
  scored against hardening policies.
