OS
c.OS calls the API's OS group. Get the operating system of target hosts.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
Get(ctx, hostname) | *Response[Collection[OsEntry]] | os:read | Get the operating system of the host. |
Get
func (s *OSService) Get(
ctx context.Context,
hostname string,
) (*Response[Collection[OsEntry]], error)
Get the operating system of the host.
Reads the distribution and its version: the ID and VERSION_ID of /etc/os-release on Linux, and darwin with the ProductVersion of sw_vers on macOS, such as darwin 15.5.
It sends GET /api/node/{hostname}/os, and needs the permission os:read.
The examples of the method's definition:
An Ubuntu host, go run os.go get:
resp, err := c.OS.Get(ctx, target)
Types
The fields of each type are the properties of its schema in the API's spec.
OsEntry
| Field | Type | Description |
|---|---|---|
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
OSInfo | Release | |
Status | RowStatus | What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran. |
Release
| Field | Type | Description |
|---|---|---|
Distribution | string | The distribution, such as ubuntu, or darwin. |
Version | string | The version of the distribution, such as 24.04. |
RowStatus
What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.
A string, one of ok, failed, skipped, timeout.
Example
examples/sdk/client/os.go
runs each example of this page. With no argument, it lists them.