lib/ohai/plugins/kernel.rb in ohai-16.7.18 vs lib/ohai/plugins/kernel.rb in ohai-16.7.37
- old
+ new
@@ -32,11 +32,11 @@
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]
+ kernel[property] = so.stdout.strip
end
kernel
end
# common *bsd code for collecting modules data
@@ -113,11 +113,10 @@
when 14 then "MSDOS"
when 15 then "WIN3x"
when 16 then "WIN95"
when 17 then "WIN98"
when 19 then "WINCE"
- else nil
end
end
# decode the PCSystemType field from WMI Win32_OperatingSystem class
# https://msdn.microsoft.com/en-us/library/aa394239(v=vs.85).aspx
@@ -132,11 +131,10 @@
when 3 then "Workstation"
when 5 then "SOHO Server"
when 6 then "Appliance PC"
when 7 then "Performance Server"
when 8 then "Maximum"
- else nil
end
end
# see if a WMI name is in the blocked list so we can avoid writing
# out useless data to ohai
@@ -168,11 +166,11 @@
collect_data(:darwin) do
kernel init_kernel
kernel[:os] = kernel[:name]
so = shell_out("sysctl -n hw.optional.x86_64")
- if so.stdout.split($/)[0].to_i == 1
+ if so.stdout.strip.to_i == 1
kernel[:machine] = "x86_64"
end
modules = Mash.new
so = shell_out("kextstat -k -l")
@@ -188,22 +186,22 @@
collect_data(:freebsd, :dragonflybsd) do
kernel init_kernel
kernel[:os] = kernel[:name]
so = shell_out("uname -i")
- kernel[:ident] = so.stdout.split($/)[0]
+ kernel[:ident] = so.stdout.strip
so = shell_out("sysctl kern.securelevel")
kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
kernel[:modules] = bsd_modules("/sbin/kldstat")
end
collect_data(:linux) do
kernel init_kernel
so = shell_out("uname -o")
- kernel[:os] = so.stdout.split($/)[0]
+ kernel[:os] = so.stdout.strip
modules = Mash.new
so = shell_out("env lsmod")
so.stdout.lines do |line|
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
@@ -231,10 +229,10 @@
collect_data(:solaris2) do
kernel init_kernel
so = shell_out("uname -s")
- kernel[:os] = so.stdout.split($/)[0]
+ kernel[:os] = so.stdout.strip
so = file_open("/etc/release", &:gets)
md = /(?<update>\d.*\d)/.match(so)
kernel[:update] = md[:update] if md