ohai 8.6.0.alpha.1 → 8.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -12
  3. data/lib/ohai/config.rb +3 -0
  4. data/lib/ohai/dsl/plugin/versionvii.rb +41 -0
  5. data/lib/ohai/exception.rb +1 -0
  6. data/lib/ohai/mixin/softlayer_metadata.rb +64 -0
  7. data/lib/ohai/plugin_config.rb +46 -0
  8. data/lib/ohai/plugins/aix/cpu.rb +23 -18
  9. data/lib/ohai/plugins/aix/memory.rb +9 -2
  10. data/lib/ohai/plugins/aix/network.rb +1 -1
  11. data/lib/ohai/plugins/cloud.rb +34 -3
  12. data/lib/ohai/plugins/ec2.rb +6 -0
  13. data/lib/ohai/plugins/linux/network.rb +245 -190
  14. data/lib/ohai/plugins/linux/platform.rb +50 -15
  15. data/lib/ohai/plugins/linux/virtualization.rb +3 -1
  16. data/lib/ohai/plugins/softlayer.rb +47 -0
  17. data/lib/ohai/plugins/solaris2/cpu.rb +46 -17
  18. data/lib/ohai/plugins/solaris2/memory.rb +9 -1
  19. data/lib/ohai/plugins/vmware.rb +73 -0
  20. data/lib/ohai/plugins/windows/memory.rb +38 -0
  21. data/lib/ohai/version.rb +1 -1
  22. data/spec/unit/config_spec.rb +28 -0
  23. data/spec/unit/dsl/plugin_spec.rb +73 -0
  24. data/spec/unit/mixin/softlayer_metadata_spec.rb +71 -0
  25. data/spec/unit/plugin_config_spec.rb +118 -0
  26. data/spec/unit/plugins/aix/cpu_spec.rb +31 -12
  27. data/spec/unit/plugins/aix/memory_spec.rb +47 -0
  28. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  29. data/spec/unit/plugins/ec2_spec.rb +35 -13
  30. data/spec/unit/plugins/linux/memory_spec.rb +204 -0
  31. data/spec/unit/plugins/linux/network_spec.rb +40 -0
  32. data/spec/unit/plugins/linux/platform_spec.rb +62 -6
  33. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -0
  34. data/spec/unit/plugins/softlayer_spec.rb +60 -0
  35. data/spec/unit/plugins/solaris2/cpu_spec.rb +2887 -42
  36. data/spec/unit/plugins/solaris2/memory_spec.rb +15 -2
  37. data/spec/unit/plugins/vmware_spec.rb +62 -0
  38. data/spec/unit/plugins/windows/memory_spec.rb +52 -0
  39. metadata +18 -5
@@ -0,0 +1,71 @@
1
+ #
2
+ # Author:: Alexey Karpik <alexey.karpik@rightscale.com>
3
+ # Author:: Peter Schroeter <peter.schroeter@rightscale.com>
4
+ # Author:: Stas Turlo <stanislav.turlo@rightscale.com>
5
+ # Copyright:: Copyright (c) 2010-2014 RightScale Inc
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
21
+ require 'ohai/mixin/softlayer_metadata'
22
+
23
+
24
+ describe ::Ohai::Mixin::SoftlayerMetadata do
25
+
26
+ let(:mixin) {
27
+ mixin = Object.new.extend(::Ohai::Mixin::SoftlayerMetadata)
28
+ mixin
29
+ }
30
+
31
+ def make_request(item)
32
+ "/rest/v3.1/SoftLayer_Resource_Metadata/#{item}"
33
+ end
34
+
35
+ def make_res(body)
36
+ double("response", {:body => body, :code => "200"})
37
+ end
38
+
39
+
40
+ context 'fetch_metadata' do
41
+ it "riases error if softlayer api query results with error" do
42
+ http_mock = double('http', {:ssl_version= => true, :use_ssl= => true, :ca_file= => true})
43
+ allow(http_mock).to receive(:get).and_raise(StandardError.new("API return fake error"))
44
+ allow(::Net::HTTP).to receive(:new).with('api.service.softlayer.com', 443).and_return(http_mock)
45
+
46
+ expect(::Ohai::Log).to receive(:error).at_least(:once)
47
+ expect{mixin.fetch_metadata}.to raise_error(StandardError)
48
+ end
49
+
50
+ it "query api service" do
51
+ http_mock = double('http', {:ssl_version= => true, :use_ssl= => true, :ca_file= => true})
52
+ allow(::Net::HTTP).to receive(:new).with('api.service.softlayer.com', 443).and_return(http_mock)
53
+
54
+ expect(http_mock).to receive(:get).with(make_request('getFullyQualifiedDomainName.txt')).and_return(make_res('abc.host.org')).once
55
+ expect(http_mock).to receive(:get).with(make_request('getPrimaryBackendIpAddress.txt')).and_return(make_res('10.0.1.10')).once
56
+ expect(http_mock).to receive(:get).with(make_request('getPrimaryIpAddress.txt')).and_return(make_res('8.8.8.8')).once
57
+ expect(http_mock).to receive(:get).with(make_request('getId.txt')).and_return(make_res('1111')).once
58
+ expect(http_mock).to receive(:get).with(make_request('getDatacenter.txt')).and_return(make_res('dal05')).once
59
+
60
+
61
+ metadata = mixin.fetch_metadata
62
+ expect(metadata).not_to be_nil
63
+ expect(metadata["public_fqdn"]).to eq('abc.host.org')
64
+ expect(metadata["local_ipv4"]).to eq('10.0.1.10')
65
+ expect(metadata["instance_id"]).to eq('1111')
66
+ expect(metadata["region"]).to eq('dal05')
67
+ expect(metadata["public_ipv4"]).to eq('8.8.8.8')
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,118 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require_relative '../spec_helper'
19
+
20
+ require 'ohai/plugin_config'
21
+
22
+ describe "Ohai::PluginConfig" do
23
+
24
+ describe "#[]=" do
25
+
26
+ let(:plugin_config) { Ohai::PluginConfig.new }
27
+
28
+ shared_examples_for "success" do
29
+
30
+ it "sets the value" do
31
+ plugin_config[key] = value
32
+ expect(plugin_config).to have_key(key)
33
+ expect(plugin_config[key]).to eq(value)
34
+ end
35
+
36
+ end
37
+
38
+ shared_examples_for "failure" do
39
+
40
+ it "raises an error" do
41
+ expect { plugin_config[key] = value }.
42
+ to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
43
+ end
44
+
45
+ end
46
+
47
+ describe "when the key is a Symbol" do
48
+
49
+ let(:key) { :foo }
50
+
51
+ describe "when the value is a Hash" do
52
+
53
+ describe "when all Hash keys are symbols" do
54
+
55
+ let(:value) {
56
+ {
57
+ :bar0 => true,
58
+ :bar1 => [ :baz0, :baz1, :baz2 ],
59
+ :bar2 => { :qux0 => true, :qux1 => false }
60
+ }
61
+ }
62
+
63
+ include_examples "success"
64
+
65
+ end
66
+
67
+ describe "when some top-level Hash key is not a symbol" do
68
+
69
+ let(:value) {
70
+ {
71
+ :bar0 => true,
72
+ "bar1" => [ :baz0, :baz1, :baz2 ],
73
+ :bar2 => { :qux0 => true, :qux1 => false }
74
+ }
75
+ }
76
+
77
+ include_examples "failure"
78
+
79
+ end
80
+
81
+ describe "when some nested Hash key is not a symbol" do
82
+
83
+ let(:value) {
84
+ {
85
+ :bar0 => true,
86
+ :bar1 => [ :baz0, :baz1, :baz2 ],
87
+ :bar2 => { :qux0 => true, "qux1" => false }
88
+ }
89
+ }
90
+
91
+ include_examples "failure"
92
+
93
+ end
94
+
95
+ end
96
+
97
+ describe "when the value is not a Hash" do
98
+
99
+ let(:value) { true }
100
+
101
+ include_examples "success"
102
+
103
+ end
104
+
105
+ end
106
+
107
+ describe "when the key is not a Symbol" do
108
+
109
+ let(:key) { "foo" }
110
+ let(:value) { false }
111
+
112
+ include_examples "failure"
113
+
114
+ end
115
+
116
+ end
117
+
118
+ end
@@ -31,50 +31,69 @@ smt_threads 2 Processor SMT threads False
31
31
  state enable Processor state False
32
32
  type PowerPC_POWER5 Processor type False
33
33
  LSATTR_EL
34
+
35
+ @pmcycles_m = <<-PMCYCLES_M
36
+ CPU 0 runs at 1654 MHz
37
+ CPU 1 runs at 1654 MHz
38
+ CPU 2 runs at 1654 MHz
39
+ CPU 3 runs at 1654 MHz
40
+ PMCYCLES_M
41
+
34
42
  @plugin = get_plugin("aix/cpu")
35
43
  allow(@plugin).to receive(:collect_os).and_return(:aix)
36
44
 
37
45
  allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_Cc_processor, nil))
38
46
  allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_El_proc0, nil))
47
+ allow(@plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil))
39
48
  @plugin.run
40
49
  end
41
50
 
42
51
 
43
52
  it "sets the vendor id to IBM" do
44
- expect(@plugin[:cpu][:vendor_id]).to eq("IBM")
53
+ expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
45
54
  end
46
55
 
47
56
  it "sets the available attribute" do
48
57
  expect(@plugin[:cpu][:available]).to eq(1)
49
58
  end
50
59
 
51
- it "sets the total number of devices" do
52
- expect(@plugin[:cpu][:total]).to eq(2)
60
+ it "sets the total number of processors" do
61
+ expect(@plugin[:cpu][:total]).to eq(4)
62
+ end
63
+
64
+ it "sets the real number of processors" do
65
+ expect(@plugin[:cpu][:real]).to eq(2)
66
+ end
67
+
68
+ it "sets the number of cores" do
69
+ #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
70
+ #on AIX number of cores and processors are considered same
71
+ expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real])
53
72
  end
54
73
 
55
74
  it "detects the model" do
56
- expect(@plugin[:cpu][:model]).to eq("PowerPC_POWER5")
75
+ expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
57
76
  end
58
77
 
59
78
  it "detects the mhz" do
60
- expect(@plugin[:cpu][:mhz]).to eq(1615570)
79
+ expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
61
80
  end
62
81
 
63
82
  it "detects the status of the device" do
64
- expect(@plugin[:cpu][:proc0][:status]).to eq("Available")
83
+ expect(@plugin[:cpu]["0"][:status]).to eq("Available")
65
84
  end
66
85
 
67
86
  it "detects the location of the device" do
68
- expect(@plugin[:cpu][:proc0][:location]).to eq("00-00")
87
+ expect(@plugin[:cpu]["0"][:location]).to eq("00-00")
69
88
  end
70
89
 
71
90
  context "lsattr -El device_name" do
72
91
  it "detects all the attributes of the device" do
73
- expect(@plugin[:cpu][:proc0][:frequency]).to eq("1654344000")
74
- expect(@plugin[:cpu][:proc0][:smt_enabled]).to eq("true")
75
- expect(@plugin[:cpu][:proc0][:smt_threads]).to eq("2")
76
- expect(@plugin[:cpu][:proc0][:state]).to eq("enable")
77
- expect(@plugin[:cpu][:proc0][:type]).to eq("PowerPC_POWER5")
92
+ expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
93
+ expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true")
94
+ expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2")
95
+ expect(@plugin[:cpu]["0"][:state]).to eq("enable")
96
+ expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
78
97
  end
79
98
  end
80
99
  end
@@ -0,0 +1,47 @@
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
18
+
19
+ describe Ohai::System, "AIX memory plugin" do
20
+ before(:each) do
21
+ @plugin = get_plugin("aix/memory")
22
+ allow(@plugin).to receive(:collect_os).and_return(:aix)
23
+ 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))
24
+ @swap_s = "allocated = 23887872 blocks used = 288912 blocks free = 23598960 blocks\n"
25
+ allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0,@swap_s, nil))
26
+ end
27
+
28
+ it "should get total memory" do
29
+ @plugin.run
30
+ expect(@plugin['memory']['total']).to eql("#{513280 * 1024}kB")
31
+ end
32
+
33
+ it "should get free memory" do
34
+ @plugin.run
35
+ expect(@plugin['memory']['free']).to eql("#{173245.83.to_i * 1024}kB")
36
+ end
37
+
38
+ it "should get total swap" do
39
+ @plugin.run
40
+ expect(@plugin['memory']['swap']['total']).to eql( "#{23887872 * 4}kB")
41
+ end
42
+
43
+ it "should get free swap" do
44
+ @plugin.run
45
+ expect(@plugin['memory']['swap']['free']).to eql( "#{23598960 * 4}kB")
46
+ end
47
+ end
@@ -67,7 +67,7 @@ ARP_AN
67
67
  allow(@plugin).to receive(:collect_os).and_return(:aix)
68
68
  @plugin[:network] = Mash.new
69
69
  allow(@plugin).to receive(:shell_out).with("netstat -rn |grep default").and_return(mock_shell_out(0, @netstat_rn_grep_default, nil))
70
- allow(@plugin).to receive(:shell_out).with("lsdev -Cc if").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
70
+ allow(@plugin).to receive(:shell_out).with("lsdev -Cc if | grep Available").and_return(mock_shell_out(0, @lsdev_Cc_if, nil))
71
71
  allow(@plugin).to receive(:shell_out).with("ifconfig en0").and_return(mock_shell_out(0, @ifconfig_en0, nil))
72
72
  allow(@plugin).to receive(:shell_out).with("entstat -d en0 | grep \"Hardware Address\"").and_return(mock_shell_out(0, "Hardware Address: be:42:80:00:b0:05", nil))
73
73
  allow(@plugin).to receive(:shell_out).with("netstat -nrf inet").and_return(mock_shell_out(0, @netstat_nrf_inet, nil))
@@ -19,6 +19,7 @@
19
19
 
20
20
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
21
21
  require 'open-uri'
22
+ require 'base64'
22
23
 
23
24
  describe Ohai::System, "plugin ec2" do
24
25
  before(:each) do
@@ -49,19 +50,20 @@ describe Ohai::System, "plugin ec2" do
49
50
  allow(File).to receive(:exist?).and_return(false)
50
51
  end
51
52
 
52
- it "should recursively fetch all the ec2 metadata" do
53
- expect(@http_client).to receive(:get).
54
- with("/2012-01-12/meta-data/").
55
- and_return(double("Net::HTTP Response", :body => "instance_type\nami_id\nsecurity-groups", :code => "200"))
56
- expect(@http_client).to receive(:get).
57
- with("/2012-01-12/meta-data/instance_type").
58
- and_return(double("Net::HTTP Response", :body => "c1.medium", :code => "200"))
59
- expect(@http_client).to receive(:get).
60
- with("/2012-01-12/meta-data/ami_id").
61
- and_return(double("Net::HTTP Response", :body => "ami-5d2dc934", :code => "200"))
62
- expect(@http_client).to receive(:get).
63
- with("/2012-01-12/meta-data/security-groups").
64
- and_return(double("Net::HTTP Response", :body => "group1\ngroup2", :code => "200"))
53
+ context "with common metadata paths" do
54
+ let(:paths) do
55
+ { "meta-data/" => "instance_type\nami_id\nsecurity-groups",
56
+ "meta-data/instance_type" => "c1.medium",
57
+ "meta-data/ami_id" => "ami-5d2dc934",
58
+ "meta-data/security-groups" => "group1\ngroup2"
59
+ }
60
+ end
61
+ it "recursively fetches all the ec2 metadata" do
62
+ paths.each do |name,body|
63
+ expect(@http_client).to receive(:get).
64
+ with("/2012-01-12/#{name}").
65
+ and_return(double("Net::HTTP Response", :body => body, :code => "200"))
66
+ end
65
67
  expect(@http_client).to receive(:get).
66
68
  with("/2012-01-12/user-data/").
67
69
  and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
@@ -74,6 +76,26 @@ describe Ohai::System, "plugin ec2" do
74
76
  expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
75
77
  end
76
78
 
79
+ it "fetches binary userdata opaquely" do
80
+ paths.each do |name,body|
81
+ expect(@http_client).to receive(:get).
82
+ with("/2012-01-12/#{name}").
83
+ and_return(double("Net::HTTP Response", :body => body, :code => "200"))
84
+ end
85
+ expect(@http_client).to receive(:get).
86
+ with("/2012-01-12/user-data/").
87
+ and_return(double("Net::HTTP Response", :body => "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", :code => "200"))
88
+
89
+ @plugin.run
90
+
91
+ expect(@plugin[:ec2]).not_to be_nil
92
+ expect(@plugin[:ec2]['instance_type']).to eq("c1.medium")
93
+ expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934")
94
+ expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
95
+ expect(@plugin[:ec2]['userdata']).to eq(Base64.decode64("Xl88OEI+XkheSDxDNz5VXkBeQ3NvbWV0aGluZ15AS1Q8Qzg+PEM5PiwpPEM5\nPklVKEktLkk8Q0I+PENDPkk8RTU+XkJeQF5RejxCRj48QjA+XlJeQF5AXkA="))
96
+ end
97
+ end
98
+
77
99
  it "should parse ec2 network/ directory as a multi-level hash" do
78
100
  expect(@http_client).to receive(:get).
79
101
  with("/2012-01-12/meta-data/").
@@ -0,0 +1,204 @@
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
18
+
19
+ describe Ohai::System, "Linux memory plugin" do
20
+ before(:each) do
21
+ @plugin = get_plugin("linux/memory")
22
+ allow(@plugin).to receive(:collect_os).and_return(:linux)
23
+ @double_file = double("/proc/meminfo")
24
+ allow(@double_file).to receive(:each).
25
+ and_yield("MemTotal: 131932120 kB").
26
+ and_yield("MemFree: 2269032 kB").
27
+ and_yield("Buffers: 646368 kB").
28
+ and_yield("Cached: 32346556 kB").
29
+ and_yield("SwapCached: 312 kB").
30
+ and_yield("Active: 98595796 kB").
31
+ and_yield("Inactive: 18477320 kB").
32
+ and_yield("HighTotal: 0 kB").
33
+ and_yield("HighFree: 0 kB").
34
+ and_yield("LowTotal: 131932120 kB").
35
+ and_yield("LowFree: 2269032 kB").
36
+ and_yield("SwapTotal: 16777208 kB").
37
+ and_yield("SwapFree: 14127356 kB").
38
+ and_yield("Dirty: 3212 kB").
39
+ and_yield("Writeback: 0 kB").
40
+ and_yield("AnonPages: 84082132 kB").
41
+ and_yield("Mapped: 3445224 kB").
42
+ and_yield("Slab: 9892096 kB").
43
+ and_yield("SReclaimable: 362636 kB").
44
+ and_yield("SUnreclaim: 18860 kB").
45
+ and_yield("PageTables: 1759332 kB").
46
+ and_yield("NFS_Unstable: 0 kB").
47
+ and_yield("Bounce: 0 kB").
48
+ and_yield("CommitLimit: 148709328 kB").
49
+ and_yield("Committed_AS: 333717060 kB").
50
+ and_yield("VmallocTotal: 34359738367 kB").
51
+ and_yield("VmallocUsed: 276796 kB").
52
+ and_yield("VmallocChunk: 34359461515 kB").
53
+ and_yield("HugePages_Total: 0").
54
+ and_yield("HugePages_Free: 0").
55
+ and_yield("HugePages_Rsvd: 0").
56
+ and_yield("Hugepagesize: 2048 kB")
57
+ allow(File).to receive(:open).with("/proc/meminfo").and_return(@double_file)
58
+ end
59
+
60
+ it "should get total memory" do
61
+ @plugin.run
62
+ expect(@plugin[:memory][:total]).to eql("131932120kB")
63
+ end
64
+
65
+ it "should get free memory" do
66
+ @plugin.run
67
+ expect(@plugin[:memory][:free]).to eql("2269032kB")
68
+ end
69
+
70
+ it "should get memory used for file buffers" do
71
+ @plugin.run
72
+ expect(@plugin[:memory][:buffers]).to eql("646368kB")
73
+ end
74
+
75
+ it "should get cache memory" do
76
+ @plugin.run
77
+ expect(@plugin[:memory][:cached]).to eql("32346556kB")
78
+ end
79
+
80
+ it "should get active memory" do
81
+ @plugin.run
82
+ expect(@plugin[:memory][:active]).to eql("98595796kB")
83
+ end
84
+
85
+ it "should get inactive memory" do
86
+ @plugin.run
87
+ expect(@plugin[:memory][:inactive]).to eql("18477320kB")
88
+ end
89
+
90
+ it "should get high_total memory" do
91
+ @plugin.run
92
+ expect(@plugin[:memory][:high_total]).to eql("0kB")
93
+ end
94
+
95
+ it "should get high_free memory" do
96
+ @plugin.run
97
+ expect(@plugin[:memory][:high_free]).to eql("0kB")
98
+ end
99
+
100
+ it "should get low_total memory" do
101
+ @plugin.run
102
+ expect(@plugin[:memory][:low_total]).to eql("131932120kB")
103
+ end
104
+
105
+ it "should get low_free memory" do
106
+ @plugin.run
107
+ expect(@plugin[:memory][:low_free]).to eql("2269032kB")
108
+ end
109
+
110
+ it "should get dirty memory" do
111
+ @plugin.run
112
+ expect(@plugin[:memory][:dirty]).to eql("3212kB")
113
+ end
114
+
115
+ it "should get writeback memory" do
116
+ @plugin.run
117
+ expect(@plugin[:memory][:writeback]).to eql("0kB")
118
+ end
119
+
120
+ it "should get anon_pages memory" do
121
+ @plugin.run
122
+ expect(@plugin[:memory][:anon_pages]).to eql("84082132kB")
123
+ end
124
+
125
+ it "should get mapped memory" do
126
+ @plugin.run
127
+ expect(@plugin[:memory][:mapped]).to eql("3445224kB")
128
+ end
129
+
130
+
131
+ it "should get slab memory" do
132
+ @plugin.run
133
+ expect(@plugin[:memory][:slab]).to eql("9892096kB")
134
+ end
135
+
136
+ it "should get slab_reclaimable memory" do
137
+ @plugin.run
138
+ expect(@plugin[:memory][:slab_reclaimable]).to eql("362636kB")
139
+ end
140
+
141
+ it "should get slab_reclaimable memory" do
142
+ @plugin.run
143
+ expect(@plugin[:memory][:slab_unreclaim]).to eql("18860kB")
144
+ end
145
+
146
+ it "should get page_tables memory" do
147
+ @plugin.run
148
+ expect(@plugin[:memory][:page_tables]).to eql("1759332kB")
149
+ end
150
+
151
+
152
+ it "should get nfs_unstable memory" do
153
+ @plugin.run
154
+ expect(@plugin[:memory][:nfs_unstable]).to eql("0kB")
155
+ end
156
+
157
+ it "should get bounce memory" do
158
+ @plugin.run
159
+ expect(@plugin[:memory][:bounce]).to eql("0kB")
160
+ end
161
+
162
+ it "should get commit_limit memory" do
163
+ @plugin.run
164
+ expect(@plugin[:memory][:commit_limit]).to eql("148709328kB")
165
+ end
166
+
167
+ it "should get committed_as memory" do
168
+ @plugin.run
169
+ expect(@plugin[:memory][:committed_as]).to eql("333717060kB")
170
+ end
171
+
172
+ it "should get vmalloc_total memory" do
173
+ @plugin.run
174
+ expect(@plugin[:memory][:vmalloc_total]).to eql("34359738367kB")
175
+ end
176
+
177
+ it "should get vmalloc_used memory" do
178
+ @plugin.run
179
+ expect(@plugin[:memory][:vmalloc_used]).to eql("276796kB")
180
+ end
181
+
182
+ it "should get vmalloc_chunk memory" do
183
+ @plugin.run
184
+ expect(@plugin[:memory][:vmalloc_chunk]).to eql("34359461515kB")
185
+ end
186
+
187
+ it "should get total swap" do
188
+ @plugin.run
189
+ expect(@plugin[:memory][:swap][:total]).to eql("16777208kB")
190
+ end
191
+
192
+ it "should get cached swap" do
193
+ @plugin.run
194
+ expect(@plugin[:memory][:swap][:cached]).to eql("312kB")
195
+ end
196
+
197
+ it "should get free swap" do
198
+ @plugin.run
199
+ expect(@plugin[:memory][:swap][:free]).to eql("14127356kB")
200
+ end
201
+
202
+
203
+
204
+ end