Skip to main content

Uptime

Get the uptime of target hosts. osapi behavior get --name uptime and osapi behavior method get show the same.

Behavior​

Nameuptime
DescriptionGet the uptime of target hosts
Placementnode
Internalno
APIyes
CLIyes
Nextno
Platformslinux, darwin
Sudonone
Runsnone
Writesnone
Keeps stateno
Usesnone
Used bystatus

Methods (1)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
getreadGET/api/node/{hostname}/uptimeuptime:readGet the uptime of the host

Types (1)​

NAMEINPUTOUTPUT
getGetInputEntry { uptime, seconds }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.uptime.<method>
Child spansexec sysctl
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputsnone

Method get​

Nameget
Verbread
DescriptionGet the uptime of the host
DetailReads 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.
HTTPGET
Route/api/node/{hostname}/uptime
Permissionuptime:read
Commandosapi client node uptime get
Input typeGetInput
Output typeEntry

Input (0)​

None. The method takes no input; its command needs only --target.

Output (2)​

FIELDTYPEDESCRIPTION
uptimestringHow long the host has run, in days, hours and minutes
secondsintegerHow long the host has run, in seconds

Examples (1)​

EXAMPLEINPUTOUTPUT
A host up for a day, two hours and five minutes(none)uptime=1 day, 2 hours, 5 minutes, seconds=93900