ohai 8.7.0 → 8.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/ohai/application.rb +3 -1
- data/lib/ohai/loader.rb +4 -3
- data/lib/ohai/mixin/dmi_decode.rb +47 -0
- data/lib/ohai/mixin/os.rb +2 -0
- data/lib/ohai/plugins/aix/kernel.rb +2 -1
- data/lib/ohai/plugins/{freebsd → bsd}/filesystem.rb +21 -3
- data/lib/ohai/plugins/bsd/virtualization.rb +80 -0
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +58 -0
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -0
- data/lib/ohai/plugins/dragonflybsd/network.rb +126 -0
- data/lib/ohai/plugins/dragonflybsd/os.rb +32 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +29 -0
- data/lib/ohai/plugins/freebsd/cpu.rb +14 -8
- data/lib/ohai/plugins/freebsd/os.rb +1 -1
- data/lib/ohai/plugins/hostname.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +12 -0
- data/lib/ohai/plugins/linux/virtualization.rb +8 -37
- data/lib/ohai/plugins/network_listeners.rb +5 -0
- data/lib/ohai/plugins/ps.rb +2 -2
- data/lib/ohai/plugins/solaris2/filesystem.rb +9 -1
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/virtualbox.rb +44 -0
- data/lib/ohai/plugins/windows/cpu.rb +26 -27
- data/lib/ohai/plugins/windows/virtualization.rb +29 -17
- data/lib/ohai/system.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +50 -0
- data/spec/functional/loader_spec.rb +53 -0
- data/spec/unit/loader_spec.rb +51 -53
- data/spec/unit/plugins/aix/kernel_spec.rb +5 -0
- data/spec/unit/plugins/bsd/filesystem_spec.rb +126 -0
- data/spec/unit/plugins/{freebsd → bsd}/virtualization_spec.rb +7 -4
- data/spec/unit/plugins/freebsd/cpu_spec.rb +60 -14
- data/spec/unit/plugins/linux/virtualization_spec.rb +58 -5
- data/spec/unit/plugins/solaris2/filesystem.rb +84 -0
- data/spec/unit/plugins/virtualbox_spec.rb +88 -0
- data/spec/unit/plugins/windows/cpu_spec.rb +3 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +182 -32
- metadata +21 -26
- data/lib/ohai/plugins/freebsd/virtualization.rb +0 -94
- data/lib/ohai/plugins/netbsd/filesystem.rb +0 -57
- data/lib/ohai/plugins/netbsd/virtualization.rb +0 -68
- data/lib/ohai/plugins/openbsd/filesystem.rb +0 -57
- data/lib/ohai/plugins/openbsd/virtualization.rb +0 -68
data/lib/ohai/system.rb
CHANGED
@@ -211,7 +211,7 @@ module Ohai
|
|
211
211
|
Ohai.config.merge!(@config)
|
212
212
|
|
213
213
|
if Ohai.config[:directory] &&
|
214
|
-
!Ohai.config[:plugin_path].include?(Ohai
|
214
|
+
!Ohai.config[:plugin_path].include?(Ohai.config[:directory])
|
215
215
|
Ohai.config[:plugin_path] << Ohai.config[:directory]
|
216
216
|
end
|
217
217
|
end
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'ohai/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ohai"
|
7
|
+
s.version = Ohai::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "Ohai profiles your system and emits JSON"
|
10
|
+
s.description = s.summary
|
11
|
+
s.license = "Apache-2.0"
|
12
|
+
s.author = "Adam Jacob"
|
13
|
+
s.email = "adam@chef.io"
|
14
|
+
s.homepage = "https://docs.chef.io/ohai.html"
|
15
|
+
|
16
|
+
s.required_ruby_version = ">= 2.0.0"
|
17
|
+
|
18
|
+
s.add_dependency "mime-types", "~> 3.0"
|
19
|
+
s.add_dependency "systemu", "~> 2.6.4"
|
20
|
+
s.add_dependency "ffi-yajl", "~> 2.2"
|
21
|
+
s.add_dependency "mixlib-cli"
|
22
|
+
s.add_dependency "mixlib-config", "~> 2.0"
|
23
|
+
s.add_dependency "mixlib-log"
|
24
|
+
s.add_dependency "mixlib-shellout", "~> 2.0"
|
25
|
+
s.add_dependency "ipaddress"
|
26
|
+
s.add_dependency "wmi-lite", "~> 1.0"
|
27
|
+
s.add_dependency "ffi", "~> 1.9"
|
28
|
+
# Note for ohai developers: If chef-config causes you grief, try:
|
29
|
+
# bundle install --with development
|
30
|
+
# this should work as long as chef is a development dependency in Gemfile.
|
31
|
+
#
|
32
|
+
# Chef depends on ohai and chef-config. Ohai depends on chef-config. The
|
33
|
+
# version of chef-config that chef depends on is whatver version chef
|
34
|
+
# happens to be on master. This will need to be updated again once work on
|
35
|
+
# Chef 13 starts, otherwise builds will break.
|
36
|
+
s.add_dependency "chef-config", ">= 12.5.0.alpha.1", "< 13"
|
37
|
+
|
38
|
+
s.add_dependency "rake", "~> 10.1"
|
39
|
+
s.add_development_dependency "rspec-core", "~> 3.0"
|
40
|
+
s.add_development_dependency "rspec-expectations", "~> 3.0"
|
41
|
+
s.add_development_dependency "rspec-mocks", "~> 3.0"
|
42
|
+
s.add_development_dependency "rspec-collection_matchers", "~> 1.0"
|
43
|
+
s.add_development_dependency "rspec_junit_formatter"
|
44
|
+
|
45
|
+
s.bindir = "bin"
|
46
|
+
s.executables = %w(ohai)
|
47
|
+
|
48
|
+
s.require_path = 'lib'
|
49
|
+
s.files = %w(LICENSE README.md Gemfile Rakefile) + Dir.glob("*.gemspec") + Dir.glob("{docs,lib,spec}/**/*")
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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
|
+
RSpec.describe "Ohai::Loader" do
|
21
|
+
let(:loader) { Ohai::Loader.new(Ohai::System.new) }
|
22
|
+
|
23
|
+
describe "#load_all" do
|
24
|
+
context "when the plugin path contains backslash characters", :windows_only do
|
25
|
+
let(:plugin_directory) { Dir.mktmpdir("plugins") }
|
26
|
+
let(:plugin_path) { plugin_directory.gsub("/", "\\") }
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
Ohai.config[:plugin_path] = plugin_path
|
30
|
+
|
31
|
+
plugin_content = <<-EOF
|
32
|
+
Ohai.plugin(:Foo) do
|
33
|
+
provides 'foo'
|
34
|
+
end
|
35
|
+
EOF
|
36
|
+
File.open(File.join(plugin_directory, "foo.rb"), 'w+') do |f|
|
37
|
+
f.write(plugin_content)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:each) do
|
42
|
+
FileUtils.rm_rf(plugin_directory)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "loads all the plugins" do
|
46
|
+
loader.load_all
|
47
|
+
loaded_plugins = loader.instance_variable_get(:@v7_plugin_classes)
|
48
|
+
loaded_plugins_names = loaded_plugins.map { |plugin| plugin.name }
|
49
|
+
expect(loaded_plugins_names).to eq(["Ohai::NamedPlugin::Foo"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -22,17 +22,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
|
22
22
|
describe Ohai::Loader do
|
23
23
|
extend IntegrationSupport
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@ohai = double('Ohai::System', :data => @plugin_data, :provides_map => @provides_map)
|
30
|
-
@loader = Ohai::Loader.new(@ohai)
|
31
|
-
end
|
25
|
+
let(:loader) { Ohai::Loader.new(ohai) }
|
26
|
+
let(:ohai) { double('Ohai::System', :data => Mash.new, :provides_map => provides_map) }
|
27
|
+
let(:provides_map) { Ohai::ProvidesMap.new }
|
32
28
|
|
33
29
|
describe "#initialize" do
|
34
|
-
it "
|
35
|
-
loader = Ohai::Loader.new(
|
30
|
+
it "returns an Ohai::Loader object" do
|
31
|
+
loader = Ohai::Loader.new(ohai)
|
36
32
|
expect(loader).to be_a_kind_of(Ohai::Loader)
|
37
33
|
end
|
38
34
|
end
|
@@ -56,43 +52,45 @@ EOF
|
|
56
52
|
|
57
53
|
describe "load_plugin() method" do
|
58
54
|
describe "when loading a v7 plugin" do
|
59
|
-
|
60
|
-
@plugin = @loader.load_plugin(path_to("zoo.rb"))
|
61
|
-
end
|
55
|
+
let(:plugin) { loader.load_plugin(path_to("zoo.rb")) }
|
62
56
|
|
63
|
-
it "
|
64
|
-
|
57
|
+
it "saves the plugin according to its attribute" do
|
58
|
+
plugin
|
59
|
+
expect(provides_map.map.keys).to include("seals")
|
65
60
|
end
|
66
61
|
|
67
|
-
it "
|
68
|
-
expect(
|
62
|
+
it "saves a single plugin source" do
|
63
|
+
expect(plugin.source).to eql([path_to("zoo.rb")])
|
69
64
|
end
|
70
65
|
|
71
|
-
it "
|
72
|
-
|
73
|
-
|
66
|
+
it "saves all plugin sources" do
|
67
|
+
plugin
|
68
|
+
loader.load_plugin(path_to("zoo_too.rb"))
|
69
|
+
expect(plugin.source).to eql([path_to("zoo.rb"), path_to("zoo_too.rb")])
|
74
70
|
end
|
75
71
|
end
|
76
72
|
|
77
73
|
describe "when loading a v6 plugin" do
|
74
|
+
let(:plugin) { loader.load_plugin(path_to("lake.rb"), path_to(".")) }
|
75
|
+
|
78
76
|
before(:each) do
|
79
77
|
expect(Ohai::Log).to receive(:warn).with(/\[DEPRECATION\]/)
|
80
|
-
@plugin = @loader.load_plugin(path_to("lake.rb"), path_to("."))
|
81
78
|
end
|
82
79
|
|
83
|
-
it "
|
84
|
-
|
80
|
+
it "does not add this plugin's provided attributes to the provides map" do
|
81
|
+
plugin
|
82
|
+
expect(provides_map.map).to be_empty
|
85
83
|
end
|
86
84
|
|
87
|
-
it "
|
88
|
-
expect(
|
85
|
+
it "saves the plugin's source" do
|
86
|
+
expect(plugin.source).to eql(path_to("lake.rb"))
|
89
87
|
end
|
90
88
|
end
|
91
89
|
|
92
|
-
it "
|
90
|
+
it "logs a warning if a plugin doesn't exist" do
|
93
91
|
expect(Ohai::Log).to receive(:warn).with(/Unable to open or read plugin/)
|
94
|
-
|
95
|
-
expect(
|
92
|
+
loader.load_plugin(path_to("rainier.rb"), path_to("."))
|
93
|
+
expect(provides_map.map).to be_empty
|
96
94
|
end
|
97
95
|
end
|
98
96
|
end
|
@@ -146,79 +144,79 @@ EOF
|
|
146
144
|
|
147
145
|
describe "load_plugin() method" do
|
148
146
|
describe "when the plugin uses Ohai.plugin instead of Ohai.plugins" do
|
149
|
-
it "
|
147
|
+
it "logs an unsupported operation warning" do
|
150
148
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("extra_s.rb")}>:/)
|
151
|
-
|
149
|
+
loader.load_plugin(path_to("extra_s.rb"))
|
152
150
|
end
|
153
151
|
|
154
|
-
it "
|
155
|
-
expect{
|
152
|
+
it "does not raise an error" do
|
153
|
+
expect{ loader.load_plugin(path_to("extra_s.rb")) }.not_to raise_error
|
156
154
|
end
|
157
155
|
end
|
158
156
|
|
159
157
|
describe "when the plugin tries to call an unexisting method" do
|
160
158
|
it "shoud log an unsupported operation warning" do
|
161
159
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Method Error: <#{path_to("no_method.rb")}>:/)
|
162
|
-
|
160
|
+
loader.load_plugin(path_to("no_method.rb"))
|
163
161
|
end
|
164
162
|
|
165
|
-
it "
|
166
|
-
expect{
|
163
|
+
it "does not raise an error" do
|
164
|
+
expect{ loader.load_plugin(path_to("no_method.rb")) }.not_to raise_error
|
167
165
|
end
|
168
166
|
end
|
169
167
|
|
170
168
|
describe "when the plugin defines collect_data on the same platform more than once" do
|
171
169
|
it "shoud log an illegal plugin definition warning" do
|
172
170
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Definition Error: <#{path_to("illegal_def.rb")}>:/)
|
173
|
-
|
171
|
+
loader.load_plugin(path_to("illegal_def.rb"))
|
174
172
|
end
|
175
173
|
|
176
|
-
it "
|
177
|
-
expect{
|
174
|
+
it "does not raise an error" do
|
175
|
+
expect{ loader.load_plugin(path_to("illegal_def.rb")) }.not_to raise_error
|
178
176
|
end
|
179
177
|
end
|
180
178
|
|
181
179
|
describe "when an unexpected error is encountered" do
|
182
|
-
it "
|
180
|
+
it "logs a warning" do
|
183
181
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Error: <#{path_to("unexpected_error.rb")}>:/)
|
184
|
-
|
182
|
+
loader.load_plugin(path_to("unexpected_error.rb"))
|
185
183
|
end
|
186
184
|
|
187
|
-
it "
|
188
|
-
expect{
|
185
|
+
it "does not raise an error" do
|
186
|
+
expect{ loader.load_plugin(path_to("unexpected_error.rb")) }.not_to raise_error
|
189
187
|
end
|
190
188
|
end
|
191
189
|
|
192
190
|
describe "when the plugin name symbol has bad syntax" do
|
193
|
-
it "
|
191
|
+
it "logs a syntax error warning" do
|
194
192
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("bad_symbol.rb")}>:/)
|
195
|
-
|
193
|
+
loader.load_plugin(path_to("bad_symbol.rb"))
|
196
194
|
end
|
197
195
|
|
198
|
-
it "
|
199
|
-
expect{
|
196
|
+
it "does not raise an error" do
|
197
|
+
expect{ loader.load_plugin(path_to("bad_symbol.rb")) }.not_to raise_error
|
200
198
|
end
|
201
199
|
end
|
202
200
|
|
203
201
|
describe "when the plugin forgets an 'end'" do
|
204
|
-
it "
|
202
|
+
it "logs a syntax error warning" do
|
205
203
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Syntax Error: <#{path_to("no_end.rb")}>:/)
|
206
|
-
|
204
|
+
loader.load_plugin(path_to("no_end.rb"))
|
207
205
|
end
|
208
206
|
|
209
|
-
it "
|
210
|
-
expect{
|
207
|
+
it "does not raise an error" do
|
208
|
+
expect{ loader.load_plugin(path_to("no_end.rb")) }.not_to raise_error
|
211
209
|
end
|
212
210
|
end
|
213
211
|
|
214
212
|
describe "when the plugin has an invalid name" do
|
215
|
-
it "
|
213
|
+
it "logs an invalid plugin name warning" do
|
216
214
|
expect(Ohai::Log).to receive(:warn).with(/Plugin Name Error: <#{path_to("bad_name.rb")}>:/)
|
217
|
-
|
215
|
+
loader.load_plugin(path_to("bad_name.rb"))
|
218
216
|
end
|
219
217
|
|
220
|
-
it "
|
221
|
-
expect{
|
218
|
+
it "does not raise an error" do
|
219
|
+
expect{ loader.load_plugin(path_to("bad_name.rb")) }.not_to raise_error
|
222
220
|
end
|
223
221
|
end
|
224
222
|
end
|
@@ -26,6 +26,7 @@ describe Ohai::System, "AIX kernel plugin" do
|
|
26
26
|
allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "6", nil))
|
27
27
|
allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "powerpc", nil))
|
28
28
|
allow(@plugin).to receive(:shell_out).with("genkex -d").and_return(mock_shell_out(0, " Text address Size Data address Size File\nf1000000c0338000 77000 f1000000c0390000 1ec8c /usr/lib/drivers/cluster\n 6390000 20000 63a0000 ba8 /usr/lib/drivers/if_en", nil))
|
29
|
+
allow(@plugin).to receive(:shell_out).with("getconf KERNEL_BITMODE").and_return(mock_shell_out(0, "64", nil))
|
29
30
|
@plugin.run
|
30
31
|
end
|
31
32
|
|
@@ -45,6 +46,10 @@ describe Ohai::System, "AIX kernel plugin" do
|
|
45
46
|
expect(@plugin[:kernel][:machine]).to eq("powerpc")
|
46
47
|
end
|
47
48
|
|
49
|
+
it "getconf KERNEL_BITMODE detects the kernel's bittiness" do
|
50
|
+
expect(@plugin[:kernel][:bits]).to eq("64")
|
51
|
+
end
|
52
|
+
|
48
53
|
it "detects the modules" do
|
49
54
|
expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["text"]).to eq({ "address" => "f1000000c0338000", "size" => "77000" })
|
50
55
|
expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"]).to eq({ "address" => "f1000000c0390000", "size" => "1ec8c" })
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matthew Kent (<mkent@magoazul.com>)
|
3
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) 2011-2015 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
|
21
|
+
|
22
|
+
describe Ohai::System, "BSD filesystem plugin" do
|
23
|
+
let(:plugin) { get_plugin("bsd/filesystem") }
|
24
|
+
before(:each) do
|
25
|
+
allow(plugin).to receive(:collect_os).and_return(:freebsd)
|
26
|
+
|
27
|
+
allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, "", ""))
|
28
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
|
29
|
+
allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, "", ""))
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when gathering filesystem usage data from df" do
|
33
|
+
before(:each) do
|
34
|
+
@stdout = <<-DF
|
35
|
+
Filesystem 1K-blocks Used Avail Capacity Mounted on
|
36
|
+
/dev/ada0p2 9637788 3313504 5553264 37% /
|
37
|
+
devfs 1 1 0 100% /dev
|
38
|
+
DF
|
39
|
+
allow(plugin).to receive(:shell_out).with("df").and_return(mock_shell_out(0, @stdout, ""))
|
40
|
+
|
41
|
+
@inode_stdout = <<-DFi
|
42
|
+
Filesystem 512-blocks Used Avail Capacity iused ifree %iused Mounted on
|
43
|
+
/dev/ada0p2 15411832 5109256 9069632 36% 252576 790750 24% /
|
44
|
+
devfs 2 2 0 100% 0 0 100% /dev
|
45
|
+
DFi
|
46
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should run df and df -iP" do
|
50
|
+
expect(plugin).to receive(:shell_out).ordered.with("df").and_return(mock_shell_out(0, @stdout, ""))
|
51
|
+
expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
52
|
+
plugin.run
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set kb_size to value from df" do
|
56
|
+
plugin.run
|
57
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:kb_size]).to eq("9637788")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should set kb_used to value from df" do
|
61
|
+
plugin.run
|
62
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:kb_used]).to eq("3313504")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set kb_available to value from df" do
|
66
|
+
plugin.run
|
67
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:kb_available]).to eq("5553264")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should set percent_used to value from df" do
|
71
|
+
plugin.run
|
72
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:percent_used]).to eq("37%")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should set mount to value from df" do
|
76
|
+
plugin.run
|
77
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set total_inodes to value from df -iP" do
|
81
|
+
plugin.run
|
82
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:total_inodes]).to eq("1043326")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should set inodes_used to value from df -iP" do
|
86
|
+
plugin.run
|
87
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_used]).to eq("252576")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should set inodes_available to value from df -iP" do
|
91
|
+
plugin.run
|
92
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_available]).to eq("790750")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "when gathering mounted filesystem data from mount" do
|
97
|
+
before(:each) do
|
98
|
+
@stdout = <<-MOUNT
|
99
|
+
/dev/ada0p2 on / (ufs, local, journaled soft-updates)
|
100
|
+
devfs on /dev (devfs, local, multilabel)
|
101
|
+
MOUNT
|
102
|
+
allow(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should run mount" do
|
106
|
+
expect(plugin).to receive(:shell_out).with("mount -l").and_return(mock_shell_out(0, @stdout, ""))
|
107
|
+
plugin.run
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should set mount to value from mount" do
|
111
|
+
plugin.run
|
112
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should set fs_type to value from mount" do
|
116
|
+
plugin.run
|
117
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:fs_type]).to eq("ufs")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should set mount_options to an array of values from mount" do
|
121
|
+
plugin.run
|
122
|
+
expect(plugin[:filesystem]["/dev/ada0p2"][:mount_options]).to eq(["local", "journaled soft-updates"])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|