diff options
author | Thom May <thom@may.lt> | 2015-08-14 15:04:53 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2015-08-14 15:04:53 +0100 |
commit | ce963906aff3ec9ffb431f9c3c3dedb31d9e0637 (patch) | |
tree | 9841461d3693431ba98cd2fa0e22a3dcc563289e | |
parent | 3835cac6756082591c26692803b39540326e4cdc (diff) | |
parent | f1778f439c6345ee53b38aaad91b2df971b521bb (diff) | |
download | ohai-ce963906aff3ec9ffb431f9c3c3dedb31d9e0637.tar.gz |
Merge pull request #602 from sh9189/aix_swap_info
Add swap space attributes for AIX
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 5 | ||||
-rw-r--r-- | spec/unit/plugins/aix/memory_spec.rb | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index 92c6e887..9a8a26a7 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -21,8 +21,13 @@ Ohai.plugin(:Memory) do collect_data(:aix) do memory Mash.new + 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 + + 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 end end diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index 1a128f57..d4270127 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -21,6 +21,8 @@ describe Ohai::System, "AIX memory plugin" 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)) + @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 "should get total memory" do @@ -32,4 +34,14 @@ describe Ohai::System, "AIX memory plugin" do @plugin.run expect(@plugin['memory']['free']).to eql("173245.83") end + + it "should get total swap" do + @plugin.run + expect(@plugin['memory']['swap']['total']).to eql( (23887872 / 1024.0) * 4) + end + + it "should get free swap" do + @plugin.run + expect(@plugin['memory']['swap']['free']).to eql( (23598960 / 1024.0) * 4) + end end |