Skip to main content

OS

c.OS calls the API's OS group. Get the operating system of target hosts.

Methods​

MethodReturnsPermissionDescription
Get(ctx, hostname)*Response[Collection[OsEntry]]os:readGet 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​

FieldTypeDescription
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
OSInfoRelease
StatusRowStatusWhat 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​

FieldTypeDescription
DistributionstringThe distribution, such as ubuntu, or darwin.
VersionstringThe 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.