Get the uptime of target hosts. osapi behavior get --name uptime and
osapi behavior method get show the same.
Behavior
| |
|---|
| Name | uptime |
| Description | Get the uptime of target hosts |
| Placement | node |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | linux, darwin |
| Sudo | none |
| Runs | none |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | status |
Methods (1)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|
| get | read | GET | /api/node/{hostname}/uptime | uptime:read | Get the uptime of the host |
Types (1)
| NAME | INPUT | OUTPUT |
|---|
| get | GetInput | Entry { uptime, seconds } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| |
|---|
| Span | behavior.uptime.<method> |
| Child spans | exec sysctl |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | none |
Method get
| |
|---|
| Name | get |
| Verb | read |
| Description | Get the uptime of the host |
| Detail | 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. |
| HTTP | GET |
| Route | /api/node/{hostname}/uptime |
| Permission | uptime:read |
| Command | osapi client node uptime get |
| Input type | GetInput |
| Output type | Entry |
None. The method takes no input; its command needs only --target.
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|
| uptime | string | How long the host has run, in days, hours and minutes |
| seconds | integer | How long the host has run, in seconds |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|
| A host up for a day, two hours and five minutes | (none) | uptime=1 day, 2 hours, 5 minutes, seconds=93900 |