Skip to main content

Disk

c.Disk calls the API's Disk group. Get the disk usage of target hosts.

Methods​

MethodReturnsPermissionDescription
Get(ctx, hostname)*Response[Collection[DiskEntry]]disk:readGet the disk usage of the host.

Get​

func (s *DiskService) Get(
ctx context.Context,
hostname string,
) (*Response[Collection[DiskEntry]], error)

Get the disk usage of the host.

Reads the size, the used space and the free space of each local filesystem, in bytes: the mounts of /proc/mounts on Linux and of mount on macOS, with their sizes from df. Local is ext4, xfs and btrfs on Linux, and apfs and hfs on macOS. Network and special filesystems are left out.

It sends GET /api/node/{hostname}/disk, and needs the permission disk:read.

The examples of the method's definition:

A host with one local filesystem, go run disk.go get:

resp, err := c.Disk.Get(ctx, target)

Types​

The fields of each type are the properties of its schema in the API's spec.

Disk​

FieldTypeDescription
FreeintThe bytes free to use.
NamestringWhere the filesystem is mounted.
TotalintThe size of the filesystem in bytes.
UsedintThe bytes in use.

DiskEntry​

FieldTypeDescription
Disks[]DiskEach local filesystem.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
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.

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/disk.go runs each example of this page. With no argument, it lists them.