diff options
author | Shahul Hameed <skhajamohid1@bloomberg.net> | 2015-08-20 19:23:29 +0000 |
---|---|---|
committer | Shahul Hameed <skhajamohid1@bloomberg.net> | 2015-08-20 19:23:29 +0000 |
commit | efd4241c5c118368255e288e08e837b4ea7fb6be (patch) | |
tree | 6d6a336ac1684338178c10f787a12ba2ffda1703 | |
parent | 0c7303f9cd3ab997bfe174c2741c4d1714ee15bb (diff) | |
download | ohai-efd4241c5c118368255e288e08e837b4ea7fb6be.tar.gz |
Add total cores to linux cpu plugin
-rw-r--r-- | lib/ohai/plugins/linux/cpu.rb | 1 | ||||
-rw-r--r-- | spec/unit/plugins/linux/cpu_spec.rb | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/cpu.rb b/lib/ohai/plugins/linux/cpu.rb index 442cb1a5..d1bca6d0 100644 --- a/lib/ohai/plugins/linux/cpu.rb +++ b/lib/ohai/plugins/linux/cpu.rb @@ -80,5 +80,6 @@ Ohai.plugin(:CPU) do cpu cpuinfo cpu[:total] = cpu_number cpu[:real] = real_cpu.keys.length + cpu[:cores] = real_cpu.keys.length * cpu["0"]["cores"].to_i end end diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index 67452654..13fb4e2e 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -89,6 +89,11 @@ describe Ohai::System, "General Linux cpu plugin" do end it_behaves_like "Common cpu info", 1, 0 + + it "gets total cores" do + @plugin.run + expect(@plugin[:cpu][:cores]).to eql(0) + end it "doesn't have a cpu 1" do @plugin.run |