Sha256: 037ca7a256afabdf2865b03d6715397a0ca6f0c380ed3442ec0bd99b4af9a8f9

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

# A module to gather uptime facts
#
module Facter::Util::Uptime
    def self.get_uptime_simple
        time = Facter::Util::Resolution.exec('uptime')
        if time =~ /up\s*(\d+\s\w+)/
            $1
        elsif time =~ /up\s*(\d+:\d+)/
            $1 + " hours"
        else
            "unknown"
        end
    end

    def self.get_uptime
        r = IO.popen("/bin/cat /proc/uptime")
        uptime, idletime = r.readline.split(" ")        
        r.close
        uptime_seconds = uptime.to_i
    end

    def self.get_uptime_period(seconds, label)
        case label
        when 'days'
            value = seconds / 86400
        when 'hours'
            value = seconds / 3600
        when 'seconds'
            seconds
        end     
    end
end   

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-1.5.7 lib/facter/util/uptime.rb
facter-1.5.5 lib/facter/util/uptime.rb
facter-1.5.6 lib/facter/util/uptime.rb