Disk
c.Disk calls the API's Disk group. Get the disk usage of target hosts.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
Get(ctx, hostname) | *Response[Collection[DiskEntry]] | disk:read | Get 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
| Field | Type | Description |
|---|---|---|
Free | int | The bytes free to use. |
Name | string | Where the filesystem is mounted. |
Total | int | The size of the filesystem in bytes. |
Used | int | The bytes in use. |
DiskEntry
| Field | Type | Description |
|---|---|---|
Disks | []Disk | Each local filesystem. |
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
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. |
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.