Uptime
c.Uptime calls the API's Uptime group. Get the uptime of target hosts.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
Get(ctx, hostname) | *Response[Collection[UptimeEntry]] | uptime:read | Get the uptime of the host. |
Get
func (s *UptimeService) Get(
ctx context.Context,
hostname string,
) (*Response[Collection[UptimeEntry]], error)
Get the uptime of the host.
Reads how long the host has run since it booted: /proc/uptime on Linux, and the boot time that sysctl gives on macOS. The uptime is in days, hours and minutes, and in seconds.
It sends GET /api/node/{hostname}/uptime, and needs the permission
uptime:read.
The examples of the method's definition:
A host up for a day, two hours and five minutes, go run uptime.go get:
resp, err := c.Uptime.Get(ctx, target)
Types
The fields of each type are the properties of its schema in the API's spec.
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.
UptimeEntry
| Field | Type | Description |
|---|---|---|
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
Seconds | int | How long the host has run, in seconds. |
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. |
Uptime | string | How long the host has run, in days, hours and minutes. |
Example
examples/sdk/client/uptime.go
runs each example of this page. With no argument, it lists them.