diff options
author | Shahul Hameed <sh9189@gmail.com> | 2015-08-19 10:24:26 -0400 |
---|---|---|
committer | Shahul Hameed <sh9189@gmail.com> | 2015-08-19 10:24:26 -0400 |
commit | aa90b5ad1f00994137e7222cc405b1f8fd33d49a (patch) | |
tree | a1f563c3973d28920c47e9e2307216e35696b3db | |
parent | c417715ce2684cad8d70d646d2d05727392ecac5 (diff) | |
download | ohai-aa90b5ad1f00994137e7222cc405b1f8fd33d49a.tar.gz |
Make AIX memory plugin output consistent with linux
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 8 | ||||
-rw-r--r-- | spec/unit/plugins/aix/memory_spec.rb | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index 9a8a26a7..c6729ea1 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -24,10 +24,12 @@ Ohai.plugin(:Memory) do memory[:swap] = Mash.new meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout - memory[:total], u, memory[:free] = meminfo.split + total_in_mb, u, free_in_mb = meminfo.split + memory[:total] = "#{total_in_mb.to_i * 1024}kB" + memory[:free] = "#{free_in_mb.to_i * 1024}kB" swapinfo = shell_out("swap -s").stdout.split #returns swap info in 4K blocks - memory[:swap]['total'] = (swapinfo[2].to_i / 1024.0) * 4 - memory[:swap]['free'] = (swapinfo[10].to_i / 1024.0) * 4 + memory[:swap]['total'] = "#{(swapinfo[2].to_i) * 4}kB" + memory[:swap]['free'] = "#{(swapinfo[10].to_i) * 4}kB" end end diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index d4270127..4aa98626 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -27,21 +27,21 @@ describe Ohai::System, "AIX memory plugin" do it "should get total memory" do @plugin.run - expect(@plugin['memory']['total']).to eql("513280.00") + expect(@plugin['memory']['total']).to eql("#{513280 * 1024}kB") end it "should get free memory" do @plugin.run - expect(@plugin['memory']['free']).to eql("173245.83") + expect(@plugin['memory']['free']).to eql("#{173245.83.to_i * 1024}kB") end it "should get total swap" do @plugin.run - expect(@plugin['memory']['swap']['total']).to eql( (23887872 / 1024.0) * 4) + expect(@plugin['memory']['swap']['total']).to eql( "#{23887872 * 4}kB") end it "should get free swap" do @plugin.run - expect(@plugin['memory']['swap']['free']).to eql( (23598960 / 1024.0) * 4) + expect(@plugin['memory']['swap']['free']).to eql( "#{23598960 * 4}kB") end end |