diff options
author | Rein Henrichs <rein@puppetlabs.com> | 2010-08-19 14:32:03 -0700 |
---|---|---|
committer | Rein Henrichs <rein@puppetlabs.com> | 2010-08-19 14:32:03 -0700 |
commit | c9307520cb3729d7cc53a37c06081353bec20f3c (patch) | |
tree | 3e57b585ecd573d95b145102fb76e18c3b76e963 | |
parent | 51bcebe38cab6088c901f1006339bbe40a36d161 (diff) | |
parent | 9c9cabd7ecb458643447d60d56e2fefe947f23c2 (diff) | |
download | facter-c9307520cb3729d7cc53a37c06081353bec20f3c.tar.gz facter-c9307520cb3729d7cc53a37c06081353bec20f3c.tar.xz facter-c9307520cb3729d7cc53a37c06081353bec20f3c.zip |
Merge remote branch 'blkperl/bug/testing/4569'
-rw-r--r-- | lib/facter/util/uptime.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/facter/util/uptime.rb b/lib/facter/util/uptime.rb index 353ebf5..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') - compute_uptime(Time.at(getTickCount.call() / 1000.0)) + 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 |