Sha256: b3d66dfbc6314ff7e8596742ac971fbb4250a0cfd0f069f8981890c37d7b6991

Contents?: true

Size: 430 Bytes

Versions: 2

Compression:

Stored size: 430 Bytes

Contents

require 'facter/util/uptime'

Facter.add(:uptime) do
  setcode do
    seconds = Facter.fact(:uptime_seconds).value

    unless seconds
      "unknown"
    else
      days    = seconds / (60 * 60 * 24)
      hours   = seconds / (60 * 60) % 24
      minutes = seconds / 60 % 60

      case days
      when 0 then "#{hours}:#{"%02d" % minutes} hours"
      when 1 then '1 day'
      else "#{days} days"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facter-1.5.9 lib/facter/uptime.rb
facter-1.5.8 lib/facter/uptime.rb