summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkgibbons <mark.gibbons@nordstrom.com>2015-12-28 11:07:33 -0800
committermarkgibbons <mark.gibbons@nordstrom.com>2015-12-28 11:30:50 -0800
commitc88909fd9551ba865de1f64acc361e5e46acef53 (patch)
tree7894917bb114da7bd42c3af182710cc47e209b61
parentb8d2b39cfd46307090f527e98d1cf641a452888b (diff)
downloadohai-c88909fd9551ba865de1f64acc361e5e46acef53.tar.gz
Create kernel[:processor] from uname -p output
An important distiction on solaris servers is x86 vs. sparc processor architecture. Using uname -m to report the machine type does make that distinction explicitly. The uname -p value is explicit about the difference.
-rw-r--r--lib/ohai/plugins/kernel.rb3
-rw-r--r--spec/unit/plugins/kernel_spec.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb
index 17c98314..e9c61549 100644
--- a/lib/ohai/plugins/kernel.rb
+++ b/lib/ohai/plugins/kernel.rb
@@ -29,7 +29,8 @@ Ohai.plugin(:Kernel) do
def init_kernel
kernel Mash.new
[["uname -s", :name], ["uname -r", :release],
- ["uname -v", :version], ["uname -m", :machine]].each do |cmd, property|
+ ["uname -v", :version], ["uname -m", :machine],
+ ["uname -p", :processor]].each do |cmd, property|
so = shell_out(cmd)
kernel[property] = so.stdout.split($/)[0]
end
diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb
index 643e2c23..e4030157 100644
--- a/spec/unit/plugins/kernel_spec.rb
+++ b/spec/unit/plugins/kernel_spec.rb
@@ -28,12 +28,14 @@ describe Ohai::System, "plugin kernel" do
allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
allow(@plugin).to receive(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
+ allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "i386\n", ""))
end
it_should_check_from_mash("kernel", "name", "uname -s", [0, "Darwin\n", ""])
it_should_check_from_mash("kernel", "release", "uname -r", [0, "9.5.0\n", ""])
it_should_check_from_mash("kernel", "version", "uname -v", [0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""])
it_should_check_from_mash("kernel", "machine", "uname -m", [0, "i386\n", ""])
+ it_should_check_from_mash("kernel", "processor", "uname -p", [0, "i386\n", ""])
describe "when running on windows", :windows_only do
before do