diff options
author | Shahul Hameed <sh9189@gmail.com> | 2015-08-19 10:33:34 -0400 |
---|---|---|
committer | Shahul Hameed <sh9189@gmail.com> | 2015-08-19 10:33:34 -0400 |
commit | c74fd8ab8748cfd718ff404c4485f1f8144474e8 (patch) | |
tree | e6e1bd79629d39530c0dee56dc1723e10ed56c79 | |
parent | aa90b5ad1f00994137e7222cc405b1f8fd33d49a (diff) | |
download | ohai-c74fd8ab8748cfd718ff404c4485f1f8144474e8.tar.gz |
Make solaris memory plugin output consistent with linux
-rw-r--r-- | lib/ohai/plugins/solaris2/memory.rb | 6 | ||||
-rw-r--r-- | spec/unit/plugins/solaris2/memory_spec.rb | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/ohai/plugins/solaris2/memory.rb b/lib/ohai/plugins/solaris2/memory.rb index 908a6380..c818698a 100644 --- a/lib/ohai/plugins/solaris2/memory.rb +++ b/lib/ohai/plugins/solaris2/memory.rb @@ -21,12 +21,12 @@ Ohai.plugin(:Memory) do memory Mash.new memory[:swap] = Mash.new meminfo = shell_out("prtconf | grep Memory").stdout - memory[:total] = meminfo.split[2].to_i + memory[:total] = "#{meminfo.split[2].to_i * 1024}kB" tokens = shell_out("swap -s").stdout.strip.split used_swap = tokens[8][0..-1].to_i #strip k from end free_swap = tokens[10][0..-1].to_i #strip k from end - memory[:swap][:total] = (used_swap + free_swap )/ 1024.0 #convert to MB - memory[:swap][:free] = free_swap / 1024.0 #convert to MB + memory[:swap][:total] = "#{used_swap + free_swap}kB" + memory[:swap][:free] = "#{free_swap}kB" end end diff --git a/spec/unit/plugins/solaris2/memory_spec.rb b/spec/unit/plugins/solaris2/memory_spec.rb index 6723768b..f2ef882b 100644 --- a/spec/unit/plugins/solaris2/memory_spec.rb +++ b/spec/unit/plugins/solaris2/memory_spec.rb @@ -27,17 +27,17 @@ describe Ohai::System, "Solaris2.X memory plugin" do it "should get the total memory" do @plugin.run - expect(@plugin['memory']['total']).to eql(8194) + expect(@plugin[:memory][:total]).to eql("#{8194 * 1024}kB") end it "should get total swap" do @plugin.run - expect(@plugin['memory']['swap']['total']).to eql((470096232 + 47057688) / 1024.0 ) + expect(@plugin[:memory][:swap][:total]).to eql("#{(470096232 + 47057688)}kB" ) end it "should get free swap" do @plugin.run - expect(@plugin['memory']['swap']['free']).to eql(47057688 / 1024.0 ) + expect(@plugin[:memory][:swap][:free]).to eql("47057688kB") end end |