Module Facter::Util::Uptime
In: lib/facter/util/uptime.rb

A module to gather uptime facts

Methods

Public Class methods

[Source]

    # File lib/facter/util/uptime.rb, line 16
16:     def self.get_uptime
17:         uptime, idletime = File.open("/proc/uptime").gets.split(" ")
18:         uptime_seconds = uptime.to_i
19:     end

[Source]

    # File lib/facter/util/uptime.rb, line 21
21:     def self.get_uptime_period(seconds, label)
22:         
23:         case label
24:         when 'days'
25:             value = seconds / 86400
26:         when 'hours'
27:             value = seconds / 3600
28:         when 'seconds'
29:             seconds
30:         end     
31:    
32:     end

[Source]

    # File lib/facter/util/uptime.rb, line 5
 5:     def self.get_uptime_simple
 6:         time = Facter::Util::Resolution.exec('uptime')
 7:             if time =~ /up\s*(\d+\s\w+)/
 8:                 $1
 9:             elsif time =~ /up\s*(\d+:\d+)/
10:                 $1 + " hours"
11:             else
12:                 "unknown"
13:             end
14:     end

[Validate]