diff options
author | Adam Leff <adam@leff.co> | 2017-11-13 10:26:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 10:26:22 -0500 |
commit | 73a12b4d2d26273e5fbbb504382b2f764dcb3be8 (patch) | |
tree | ee173ff110495d2a3e521edd9390b7494699a535 | |
parent | 0eeee400bf838357953ac342f66491cc67a6430e (diff) | |
parent | bde66b9fdc40c67f73c69e8086948c5a1a434436 (diff) | |
download | ohai-73a12b4d2d26273e5fbbb504382b2f764dcb3be8.tar.gz |
Merge pull request #1088 from pasiukevich/support_linux_mem_available
Add support for Linux MemAvailable value
-rw-r--r-- | lib/ohai/plugins/linux/memory.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/linux/memory_spec.rb | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/memory.rb b/lib/ohai/plugins/linux/memory.rb index 144ad9d7..03d8057c 100644 --- a/lib/ohai/plugins/linux/memory.rb +++ b/lib/ohai/plugins/linux/memory.rb @@ -30,6 +30,8 @@ Ohai.plugin(:Memory) do memory[:total] = "#{$1}#{$2}" when /^MemFree:\s+(\d+) (.+)$/ memory[:free] = "#{$1}#{$2}" + when /^MemAvailable:\s+(\d+) (.+)$/ + memory[:available] = "#{$1}#{$2}" when /^Buffers:\s+(\d+) (.+)$/ memory[:buffers] = "#{$1}#{$2}" when /^Cached:\s+(\d+) (.+)$/ diff --git a/spec/unit/plugins/linux/memory_spec.rb b/spec/unit/plugins/linux/memory_spec.rb index e3a281ea..5859edd1 100644 --- a/spec/unit/plugins/linux/memory_spec.rb +++ b/spec/unit/plugins/linux/memory_spec.rb @@ -24,6 +24,7 @@ describe Ohai::System, "Linux memory plugin" do allow(@double_file).to receive(:each). and_yield("MemTotal: 131932120 kB"). and_yield("MemFree: 2269032 kB"). + and_yield("MemAvailable: 9208922 kB"). and_yield("Buffers: 646368 kB"). and_yield("Cached: 32346556 kB"). and_yield("SwapCached: 312 kB"). @@ -68,6 +69,11 @@ describe Ohai::System, "Linux memory plugin" do expect(@plugin[:memory][:free]).to eql("2269032kB") end + it "should get available memory" do + @plugin.run + expect(@plugin[:memory][:available]).to eql("9208922kB") + end + it "should get memory used for file buffers" do @plugin.run expect(@plugin[:memory][:buffers]).to eql("646368kB") |