lib/ohai/plugins/kernel.rb in ohai-15.1.5 vs lib/ohai/plugins/kernel.rb in ohai-15.2.5
- old
+ new
@@ -30,13 +30,13 @@
def init_kernel
kernel Mash.new
[["uname -s", :name], ["uname -r", :release],
["uname -v", :version], ["uname -m", :machine],
["uname -p", :processor]].each do |cmd, property|
- so = shell_out(cmd)
- kernel[property] = so.stdout.split($/)[0]
- end
+ so = shell_out(cmd)
+ kernel[property] = so.stdout.split($/)[0]
+ end
kernel
end
# common *bsd code for collecting modules data
# @return [Mash]
@@ -69,12 +69,13 @@
53, # Server Solutions Premium Core
46, # Storage Server Enterprise Core
43, # Storage Server Express Core
44, # Storage Server Standard Core
45, # Storage Server Workgroup Core
- 29 # Web Server Core
+ 29, # Web Server Core
].include?(sku)
+
false
end
# given the SystemType value from WMI's Win32_ComputerSystem class
# https://msdn.microsoft.com/en-us/library/aa394102(v=vs.85).aspx
@@ -82,20 +83,22 @@
# @param [String] sys_type SystemType value from Win32_ComputerSystem
# @return [String] x86_64 or i386
def arch_lookup(sys_type)
return "x86_64" if sys_type == "x64-based PC"
return "i386" if sys_type == "X86-based PC"
+
sys_type
end
# given the ProductType value from WMI's Win32_OperatingSystem class
# https://msdn.microsoft.com/en-us/library/aa394239(v=vs.85).aspx
# return either workstation or server
# @param [Integer] type ProductType value from Win32_OperatingSystem
# @return [String] Workstation or Server
def product_type_decode(type)
return "Workstation" if type == 1
+
"Server"
end
# decode the OSType field from WMI Win32_OperatingSystem class
# https://msdn.microsoft.com/en-us/library/aa394239(v=vs.85).aspx
@@ -224,11 +227,11 @@
kernel init_kernel
so = shell_out("uname -s")
kernel[:os] = so.stdout.split($/)[0]
- so = File.open("/etc/release") { |file| file.gets }
+ so = File.open("/etc/release", &:gets)
md = /(?<update>\d.*\d)/.match(so)
kernel[:update] = md[:update] if md
modules = Mash.new
@@ -258,10 +261,11 @@
host = wmi.first_of("Win32_OperatingSystem")
kernel[:os_info] = Mash.new
host.wmi_ole_object.properties_.each do |p|
next if blacklisted_wmi_name?(p.name.wmi_underscore)
+
kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
end
kernel[:name] = (kernel[:os_info][:caption]).to_s
kernel[:release] = (kernel[:os_info][:version]).to_s
@@ -272,9 +276,10 @@
kernel[:cs_info] = Mash.new
host = wmi.first_of("Win32_ComputerSystem")
host.wmi_ole_object.properties_.each do |p|
next if blacklisted_wmi_name?(p.name.wmi_underscore)
+
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
end
kernel[:machine] = arch_lookup((kernel[:cs_info][:system_type]).to_s)
kernel[:system_type] = pc_system_type_decode(kernel[:cs_info][:pc_system_type])