This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

uptime

Get the total time a remote server has been running in ruby.
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = host.uptime
result.success?
true

result.days
36

result.hours
871

result.minutes
52287

Result

Returns a single Uptime struct.

Uptime Fields

Field Type Description
boot_time Time Timestamp of when the server was booted.
uptime string String format of total days, hours, minutes and seconds the server has been running.
seconds integer Total seconds the server has been running.
minutes integer Total minutes the server has been running.
hours integer Total hours the server has been running.
days integer Total days the server has been running.

Return Example

host.uptime.data
#<Struct:Kanrisuru::Core::System::Uptime:0x00000640
  boot_time = 2021-12-06 13:30:08.505554234 -0600,
  days = 36,
  hours = 871,
  minutes = 52287,
  seconds = 3137267,
  uptime = "36:7:27:47"
>

Exit Status

Code Description
0 Success
1 Failure

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES