diff options
author | Tim Smith <tsmith@chef.io> | 2020-11-18 11:36:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 11:36:52 -0800 |
commit | f45a5908d21ae7c376c4b73ceb904d0b46ac723f (patch) | |
tree | 16f4aab1534b59042aee1269baf1b61861a81f0e | |
parent | 600d6edf1bba6cce239a8146e64baf149cfd1e35 (diff) | |
parent | f7ea3f520a73b6504cb4ed61bb1dc1815c7d363f (diff) | |
download | ohai-f45a5908d21ae7c376c4b73ceb904d0b46ac723f.tar.gz |
Merge pull request #1572 from chef/memory
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/aix/memory_spec.rb | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index 2869dcdc..3dfde67e 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -25,10 +25,10 @@ Ohai.plugin(:Memory) do memory Mash.new memory[:swap] = Mash.new - meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout + meminfo = shell_out("svmon -G -O unit=KB,summary=longreal | grep '[0-9]'").stdout 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" + memory[:total] = "#{total_in_mb.to_i}kB" + memory[:free] = "#{free_in_mb.to_i}kB" swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks memory[:swap]["total"] = "#{swap_info[2].to_i * 4}kB" diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index 046f7442..c518a621 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -22,28 +22,28 @@ describe Ohai::System, "AIX memory plugin" do before do @plugin = get_plugin("aix/memory") allow(@plugin).to receive(:collect_os).and_return(:aix) - allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil)) + allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=KB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 25165824 7255120 17910704 4507712 4913152 19409452 1572864\n", nil)) @swap_s = "allocated = 23887872 blocks used = 288912 blocks free = 23598960 blocks\n" allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil)) end it "gets total memory" do @plugin.run - expect(@plugin["memory"]["total"]).to eql("#{513280 * 1024}kB") + expect(@plugin["memory"]["total"]).to eql("25165824kB") end it "gets free memory" do @plugin.run - expect(@plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB") + expect(@plugin["memory"]["free"]).to eql("17910704kB") end it "gets total swap" do @plugin.run - expect(@plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB") + expect(@plugin["memory"]["swap"]["total"]).to eql( "95551488kB") end it "gets free swap" do @plugin.run - expect(@plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB") + expect(@plugin["memory"]["swap"]["free"]).to eql( "94395840kB") end end |