diff options
author | Irving Popovetsky <irving@getchef.com> | 2015-08-13 09:19:07 -0700 |
---|---|---|
committer | Irving Popovetsky <irving@getchef.com> | 2015-08-13 09:19:07 -0700 |
commit | e5a0cc265049e120c75120c664ad43914ea3a9fa (patch) | |
tree | 34055e42ce4c958ec8ea2ff5a0433e957101e11a | |
parent | f3152b4f5fae2d43e26696fe43fa71749027b931 (diff) | |
parent | 4d478cac6ac714b204eb081a282e8514ecf5f26c (diff) | |
download | ohai-e5a0cc265049e120c75120c664ad43914ea3a9fa.tar.gz |
Merge pull request #598 from sh9189/aix_memory_plugin
Fix aix memory plugin output
-rw-r--r-- | lib/ohai/plugins/aix/memory.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/aix/memory_spec.rb | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index da74a778..92c6e887 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -20,7 +20,7 @@ Ohai.plugin(:Memory) do provides "memory" collect_data(:aix) do - memory = Mash.new + memory Mash.new meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout memory[:total], u, memory[:free] = meminfo.split diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb new file mode 100644 index 00000000..1a128f57 --- /dev/null +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -0,0 +1,35 @@ +# +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') + +describe Ohai::System, "AIX memory plugin" do + before(:each) 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)) + end + + it "should get total memory" do + @plugin.run + expect(@plugin['memory']['total']).to eql("513280.00") + end + + it "should get free memory" do + @plugin.run + expect(@plugin['memory']['free']).to eql("173245.83") + end +end |