summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/facter/util/uptime.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/facter/util/uptime.rb b/lib/facter/util/uptime.rb
index b62d7e9..6c60ace 100644
--- a/lib/facter/util/uptime.rb
+++ b/lib/facter/util/uptime.rb
@@ -8,9 +8,12 @@ module Facter::Util::Uptime
end
def self.get_uptime_seconds_win
- require 'Win32API'
- getTickCount = Win32API.new("kernel32", "GetTickCount", nil, 'L')
- (getTickCount.call() / 1000.0).to_i
+ require 'win32ole'
+ wmi = WIN32OLE.connect("winmgmts://")
+ query = wmi.ExecQuery("select * from Win32_OperatingSystem")
+ last_boot = ""
+ query.each { |x| last_boot = x.LastBootupTime}
+ self.compute_uptime(Time.parse(last_boot.split('.').first))
end
private