diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-02 10:19:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-02 10:19:56 -0800 |
commit | a588f55f633e0d92841018518b5af7c730f7cf28 (patch) | |
tree | 4055f2f7b05393caab80c798ac16158b86164d98 /lib/ohai | |
parent | e2fe5ce19f4c253f3e00028486df57610f69c7f0 (diff) | |
parent | 501133a3d9bc294e121e90b3e98e87fe1499845d (diff) | |
download | ohai-a588f55f633e0d92841018518b5af7c730f7cf28.tar.gz |
Merge pull request #1148 from chef/kill_win2k3
Remove support for Windows 2003 from uptime/cpu plugins
Diffstat (limited to 'lib/ohai')
-rw-r--r-- | lib/ohai/plugins/uptime.rb | 9 | ||||
-rw-r--r-- | lib/ohai/plugins/windows/cpu.rb | 18 |
2 files changed, 4 insertions, 23 deletions
diff --git a/lib/ohai/plugins/uptime.rb b/lib/ohai/plugins/uptime.rb index fce9eb0e..a2294fb3 100644 --- a/lib/ohai/plugins/uptime.rb +++ b/lib/ohai/plugins/uptime.rb @@ -28,7 +28,6 @@ Ohai.plugin(:Uptime) do require "ohai/mixin/seconds_to_human" provides "uptime", "uptime_seconds" provides "idletime", "idletime_seconds" # linux only - depends "platform_version" def collect_uptime(path) # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009 @@ -87,12 +86,8 @@ Ohai.plugin(:Uptime) do collect_data(:windows) do require "wmi-lite/wmi" wmi = WmiLite::Wmi.new - if platform_version.to_f >= 6.0 ## for newer version of Windows starting from Windows Server 2008 ## - last_boot_up_time = wmi.first_of("Win32_OperatingSystem")["lastbootuptime"] - uptime_seconds Time.new.to_i - Time.parse(last_boot_up_time).to_i - else ## for older version of Windows starting from Windows Server 2003 ## - uptime_seconds wmi.first_of("Win32_PerfFormattedData_PerfOS_System")["systemuptime"].to_i - end + last_boot_up_time = wmi.first_of("Win32_OperatingSystem")["lastbootuptime"] + uptime_seconds Time.new.to_i - Time.parse(last_boot_up_time).to_i uptime seconds_to_human(uptime_seconds) end diff --git a/lib/ohai/plugins/windows/cpu.rb b/lib/ohai/plugins/windows/cpu.rb index e8ad9138..f36317f3 100644 --- a/lib/ohai/plugins/windows/cpu.rb +++ b/lib/ohai/plugins/windows/cpu.rb @@ -32,23 +32,9 @@ Ohai.plugin(:CPU) do processors.each_with_index do |processor, index| current_cpu = index.to_s cpu[current_cpu] = Mash.new - # - # On Windows Server 2003 R2 (i.e. 5.2.*), numberofcores property - # doesn't exist on the Win32_Processor class unless the user has - # patched their system with: - # http://support.microsoft.com/kb/932370 - # - # We're returning nil for cpu["cores"] - # when we don't see numberofcores property - # - begin - cpu[current_cpu]["cores"] = processor["numberofcores"] - cores += processor["numberofcores"] - rescue NoMethodError => e - Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370") - cpu[current_cpu]["cores"] = nil - end + cpu[current_cpu]["cores"] = processor["numberofcores"] + cores += processor["numberofcores"] logical_processors += processor["numberoflogicalprocessors"] cpu[current_cpu]["vendor_id"] = processor["manufacturer"] |