ohai 8.26.1 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -4
- data/Rakefile +14 -0
- data/lib/ohai/application.rb +1 -0
- data/lib/ohai/config.rb +2 -88
- data/lib/ohai/dsl/plugin.rb +0 -4
- data/lib/ohai/exception.rb +0 -1
- data/lib/ohai/loader.rb +11 -2
- data/lib/ohai/log.rb +3 -1
- data/lib/ohai/mixin/command.rb +1 -318
- data/lib/ohai/mixin/do_metadata.rb +47 -0
- data/lib/ohai/mixin/ec2_metadata.rb +2 -29
- data/lib/ohai/mixin/gce_metadata.rb +0 -37
- data/lib/ohai/mixin/http_helper.rb +56 -0
- data/lib/ohai/mixin/network_constants.rb +0 -5
- data/lib/ohai/plugins/cloud.rb +144 -157
- data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
- data/lib/ohai/plugins/digital_ocean.rb +24 -42
- data/lib/ohai/plugins/dmi.rb +81 -77
- data/lib/ohai/plugins/ec2.rb +33 -60
- data/lib/ohai/plugins/gce.rb +3 -1
- data/lib/ohai/plugins/hostname.rb +1 -16
- data/lib/ohai/plugins/linux/filesystem.rb +130 -81
- data/lib/ohai/plugins/linux/mdadm.rb +3 -45
- data/lib/ohai/plugins/linux/network.rb +1 -26
- data/lib/ohai/plugins/linux/platform.rb +4 -2
- data/lib/ohai/plugins/linux/virtualization.rb +1 -5
- data/lib/ohai/plugins/scala.rb +1 -13
- data/lib/ohai/plugins/solaris2/network.rb +1 -2
- data/lib/ohai/plugins/uptime.rb +0 -9
- data/lib/ohai/plugins/windows/cpu.rb +2 -1
- data/lib/ohai/plugins/windows/network.rb +1 -1
- data/lib/ohai/runner.rb +0 -5
- data/lib/ohai/system.rb +38 -8
- data/lib/ohai/version.rb +2 -2
- data/ohai.gemspec +1 -1
- data/spec/functional/application_spec.rb +0 -40
- data/spec/functional/plugins/powershell_spec.rb +1 -1
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/support/integration_helper.rb +17 -0
- data/spec/support/platform_helpers.rb +17 -0
- data/spec/unit/application_spec.rb +0 -1
- data/spec/unit/config_spec.rb +0 -111
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +1 -1
- data/spec/unit/loader_spec.rb +26 -1
- data/spec/unit/mixin/command_spec.rb +1 -69
- data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +0 -1
- data/spec/unit/plugins/abort_spec.rb +1 -1
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +1 -1
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/aix/os_spec.rb +1 -1
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/c_spec.rb +1 -1
- data/spec/unit/plugins/chef_spec.rb +1 -2
- data/spec/unit/plugins/cloud_spec.rb +210 -50
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
- data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
- data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
- data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
- data/spec/unit/plugins/darwin/network_spec.rb +1 -1
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
- data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +10 -62
- data/spec/unit/plugins/elixir_spec.rb +1 -1
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
- data/spec/unit/plugins/fail_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/hostname_spec.rb +16 -41
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +17 -1
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linode_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
- data/spec/unit/plugins/linux/fips_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
- data/spec/unit/plugins/linux/memory_spec.rb +1 -1
- data/spec/unit/plugins/linux/network_spec.rb +3 -44
- data/spec/unit/plugins/linux/platform_spec.rb +4 -4
- data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +1 -1
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/openstack_spec.rb +2 -3
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -1
- data/spec/unit/plugins/passwd_spec.rb +17 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +1 -1
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +1 -1
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +1 -2
- data/spec/unit/plugins/root_group_spec.rb +2 -2
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +3 -37
- data/spec/unit/plugins/shard_spec.rb +1 -1
- data/spec/unit/plugins/shells_spec.rb +1 -1
- data/spec/unit/plugins/softlayer_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/sysconf_spec.rb +1 -1
- data/spec/unit/plugins/timezone_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +1 -1
- data/spec/unit/plugins/vmware_spec.rb +2 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
- data/spec/unit/plugins/windows/fips_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +68 -76
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -20
- data/lib/ohai/plugins/cloud_v2.rb +0 -315
- data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
- data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
- data/lib/ohai/plugins/linux/lspci.rb +0 -76
- data/lib/ohai/plugins/network_listeners.rb +0 -60
- data/lib/ohai/plugins/sigar/cpu.rb +0 -44
- data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
- data/lib/ohai/plugins/sigar/memory.rb +0 -39
- data/lib/ohai/plugins/sigar/network.rb +0 -168
- data/lib/ohai/plugins/sigar/network_route.rb +0 -64
- data/lib/ohai/plugins/sigar/platform.rb +0 -30
- data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
- data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -14,7 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
|
17
|
+
require_relative "../../spec_helper.rb"
|
18
18
|
|
19
19
|
describe Ohai::System, "plugin elixir" do
|
20
20
|
let(:plugin) { get_plugin("elixir") }
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
|
22
22
|
before(:each) do
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
|
16
|
+
require_relative "../../spec_helper.rb"
|
17
17
|
|
18
18
|
describe Ohai::System, "plugin go" do
|
19
19
|
let(:plugin) { get_plugin("go") }
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "plugin groovy" do
|
22
22
|
let(:plugin) { get_plugin("groovy") }
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
|
17
|
+
require_relative "../../spec_helper.rb"
|
18
18
|
|
19
19
|
describe Ohai::System, "plugin haskell" do
|
20
20
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "hostname plugin" do
|
22
22
|
before(:each) do
|
@@ -25,50 +25,25 @@ describe Ohai::System, "hostname plugin" do
|
|
25
25
|
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
26
26
|
end
|
27
27
|
|
28
|
-
context "
|
29
|
-
|
30
|
-
|
31
|
-
expect(@plugin).not_to receive(:get_fqdn_from_sigar)
|
32
|
-
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
|
33
|
-
end
|
34
|
-
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
35
|
-
|
36
|
-
it "should use #resolve_fqdn to find the fqdn" do
|
37
|
-
@plugin.run
|
38
|
-
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should set the domain to everything after the first dot of the fqdn" do
|
42
|
-
@plugin.run
|
43
|
-
expect(@plugin[:domain]).to eq("bethell")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should set the [short] hostname to everything before the first dot of the fqdn" do
|
47
|
-
@plugin.run
|
48
|
-
expect(@plugin[:hostname]).to eq("katie")
|
49
|
-
end
|
28
|
+
context "default behavior"
|
29
|
+
before(:each) do
|
30
|
+
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
|
50
31
|
end
|
32
|
+
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
51
33
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
58
|
-
it "should set the fqdn to the returned value from sigar" do
|
59
|
-
@plugin.run
|
60
|
-
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
61
|
-
end
|
34
|
+
it "should use #resolve_fqdn to find the fqdn" do
|
35
|
+
@plugin.run
|
36
|
+
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
37
|
+
end
|
62
38
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
39
|
+
it "should set the domain to everything after the first dot of the fqdn" do
|
40
|
+
@plugin.run
|
41
|
+
expect(@plugin[:domain]).to eq("bethell")
|
42
|
+
end
|
67
43
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
44
|
+
it "should set the [short] hostname to everything before the first dot of the fqdn" do
|
45
|
+
@plugin.run
|
46
|
+
expect(@plugin[:hostname]).to eq("katie")
|
72
47
|
end
|
73
48
|
|
74
49
|
context "when a system has a bare hostname without a FQDN" do
|
@@ -1,9 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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_relative "../../spec_helper.rb"
|
18
|
+
require "ipaddr_extensions"
|
7
19
|
|
8
20
|
describe Ohai::System, "plugin ip_scopes" do
|
9
21
|
let(:plugin) { get_plugin("ip_scopes") }
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "../../spec_helper.rb"
|
21
21
|
|
22
22
|
describe Ohai::System, "plugin java (Java5 Client VM)" do
|
23
23
|
let(:plugin) { get_plugin("java") }
|
@@ -1,4 +1,20 @@
|
|
1
|
-
|
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_relative "../../spec_helper.rb"
|
2
18
|
|
3
19
|
describe Ohai::System, "plugin joyent" do
|
4
20
|
let(:plugin) { get_plugin("joyent") }
|
@@ -16,10 +16,10 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "Linux filesystem plugin" do
|
22
|
-
let(:plugin) { get_plugin("linux/filesystem") }
|
22
|
+
let (:plugin) { get_plugin("linux/filesystem") }
|
23
23
|
before(:each) do
|
24
24
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
25
25
|
|
@@ -27,15 +27,10 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
27
27
|
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
|
28
28
|
allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
|
29
29
|
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
|
30
|
-
allow(plugin).to receive(:shell_out).with("blkid
|
31
|
-
allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, "", ""))
|
32
|
-
allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, "", ""))
|
30
|
+
allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, "", ""))
|
33
31
|
|
34
|
-
allow(plugin).to receive(:shell_out).
|
35
|
-
|
36
|
-
allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID").
|
37
|
-
and_return(mock_shell_out(0, "", ""))
|
38
|
-
allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
|
32
|
+
allow(plugin).to receive(:shell_out).
|
33
|
+
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
39
34
|
and_return(mock_shell_out(0, "", ""))
|
40
35
|
|
41
36
|
allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
|
@@ -57,6 +52,11 @@ describe Ohai::System, "Linux filesystem plugin" do
|
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
55
|
+
it "sets both filesystem and filesystem2 attributes" do
|
56
|
+
plugin.run
|
57
|
+
expect(plugin[:filesystem]).to eq(plugin[:filesystem2])
|
58
|
+
end
|
59
|
+
|
60
60
|
describe "when gathering filesystem usage data from df" do
|
61
61
|
before(:each) do
|
62
62
|
@stdout = <<-DF
|
@@ -93,42 +93,42 @@ DFi
|
|
93
93
|
|
94
94
|
it "should set kb_size to value from df -P" do
|
95
95
|
plugin.run
|
96
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_size]).to eq("97605057")
|
96
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should set kb_used to value from df -P" do
|
100
100
|
plugin.run
|
101
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_used]).to eq("53563253")
|
101
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should set kb_available to value from df -P" do
|
105
105
|
plugin.run
|
106
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:kb_available]).to eq("44041805")
|
106
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should set percent_used to value from df -P" do
|
110
110
|
plugin.run
|
111
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:percent_used]).to eq("56%")
|
111
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should set mount to value from df -P" do
|
115
115
|
plugin.run
|
116
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
116
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should set total_inodes to value from df -iP" do
|
120
120
|
plugin.run
|
121
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865")
|
121
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should set inodes_used to value from df -iP" do
|
125
125
|
plugin.run
|
126
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380")
|
126
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should set inodes_available to value from df -iP" do
|
130
130
|
plugin.run
|
131
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485")
|
131
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -161,228 +161,142 @@ MOUNT
|
|
161
161
|
|
162
162
|
it "should set mount to value from mount" do
|
163
163
|
plugin.run
|
164
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
164
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should set fs_type to value from mount" do
|
168
168
|
plugin.run
|
169
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
|
169
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should set mount_options to an array of values from mount" do
|
173
173
|
plugin.run
|
174
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime})
|
174
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
describe "when gathering filesystem type data from blkid" do
|
179
179
|
before(:each) do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
/dev/
|
185
|
-
/
|
186
|
-
/dev
|
187
|
-
/dev/
|
188
|
-
/dev/mapper/sys.vg-
|
189
|
-
/dev/mapper/sys.vg-
|
190
|
-
/dev/mapper/sys.vg-
|
191
|
-
/dev/mapper/sys.vg-
|
192
|
-
/dev/mapper/sys.vg-
|
193
|
-
/dev/
|
194
|
-
|
195
|
-
allow(plugin).to receive(:shell_out).with("
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should run blkid -s TYPE" do
|
199
|
-
expect(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, ""))
|
200
|
-
plugin.run
|
201
|
-
end
|
180
|
+
# blkid and lsblk output are coorelated with df/mount output, so the
|
181
|
+
# most full test of them actually requires we have both
|
182
|
+
@dfstdout = <<-DF
|
183
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
184
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
185
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
186
|
+
udev 2025576 228 2025348 1% /dev
|
187
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
188
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
189
|
+
/dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
|
190
|
+
/dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
|
191
|
+
/dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
|
192
|
+
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
|
193
|
+
/dev/md0 960492 36388 875312 4% /boot
|
194
|
+
DF
|
195
|
+
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
|
202
196
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
197
|
+
@inode_stdout = <<-DFi
|
198
|
+
Filesystem Inodes IUsed IFree IUse% Mounted on
|
199
|
+
/dev/xvda1 1310720 107407 1203313 9% /
|
200
|
+
/dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
|
201
|
+
tmpfs 126922 273 126649 1% /run
|
202
|
+
none 126922 1 126921 1% /run/lock
|
203
|
+
none 126922 1 126921 1% /run/shm
|
204
|
+
DFi
|
205
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
208
206
|
|
209
|
-
describe "when gathering filesystem type data from lsblk" do
|
210
|
-
before(:each) do
|
211
|
-
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
212
207
|
@stdout = <<-BLKID_TYPE
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
NAME="debian--7-root (dm-0)" FSTYPE="ext4"
|
208
|
+
/dev/sdb1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
|
209
|
+
/dev/sdb2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
|
210
|
+
/dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
|
211
|
+
/dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
|
212
|
+
/dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
|
213
|
+
/dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
|
214
|
+
/dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
|
215
|
+
/dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
|
216
|
+
/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
|
217
|
+
/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
|
218
|
+
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
|
219
|
+
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
|
226
220
|
BLKID_TYPE
|
227
|
-
allow(plugin).to receive(:shell_out).with("
|
228
|
-
and_return(mock_shell_out(0, @stdout, ""))
|
221
|
+
allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, ""))
|
229
222
|
end
|
230
223
|
|
231
|
-
it "should run
|
232
|
-
expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE").
|
233
|
-
and_return(mock_shell_out(0, @stdout, ""))
|
224
|
+
it "should run blkid" do
|
234
225
|
plugin.run
|
235
226
|
end
|
236
227
|
|
237
|
-
it "should set
|
228
|
+
it "should set kb_size to value from blkid" do
|
238
229
|
plugin.run
|
239
|
-
expect(plugin[:filesystem]["/dev/md1"][:fs_type]).to eq("LVM2_member")
|
240
|
-
|
241
|
-
|
242
|
-
it "should ignore extra info in name and set fs_type to value from lsblk -P -n -o NAME,FSTYPE" do
|
243
|
-
plugin.run
|
244
|
-
expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:fs_type]).to eq("ext4")
|
230
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
|
231
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
|
232
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
|
245
233
|
end
|
246
234
|
end
|
247
235
|
|
248
|
-
describe "when gathering filesystem
|
236
|
+
describe "when gathering filesystem type data from lsblk" do
|
249
237
|
before(:each) do
|
250
|
-
@
|
251
|
-
|
252
|
-
/dev/
|
253
|
-
/
|
254
|
-
/dev
|
255
|
-
/dev/
|
256
|
-
/dev/
|
257
|
-
/dev/mapper/sys.vg-
|
258
|
-
/dev/mapper/sys.vg-
|
259
|
-
/dev/mapper/sys.vg-
|
260
|
-
/dev/mapper/sys.vg-
|
261
|
-
/dev/
|
262
|
-
|
263
|
-
|
264
|
-
BLKID_UUID
|
265
|
-
allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
266
|
-
end
|
267
|
-
|
268
|
-
it "should run blkid -s UUID" do
|
269
|
-
expect(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, ""))
|
270
|
-
plugin.run
|
271
|
-
end
|
238
|
+
@dfstdout = <<-DF
|
239
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
240
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
241
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
242
|
+
udev 2025576 228 2025348 1% /dev
|
243
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
244
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
245
|
+
/dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
|
246
|
+
/dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
|
247
|
+
/dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
|
248
|
+
/dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
|
249
|
+
/dev/md0 960492 36388 875312 4% /boot
|
250
|
+
DF
|
251
|
+
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
|
272
252
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
253
|
+
@inode_stdout = <<-DFi
|
254
|
+
Filesystem Inodes IUsed IFree IUse% Mounted on
|
255
|
+
/dev/xvda1 1310720 107407 1203313 9% /
|
256
|
+
/dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
|
257
|
+
tmpfs 126922 273 126649 1% /run
|
258
|
+
none 126922 1 126921 1% /run/lock
|
259
|
+
none 126922 1 126921 1% /run/shm
|
260
|
+
DFi
|
261
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
278
262
|
|
279
|
-
describe "when gathering filesystem uuid data from lsblk" do
|
280
|
-
before(:each) do
|
281
263
|
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
282
|
-
@stdout = <<-
|
283
|
-
NAME
|
284
|
-
NAME
|
285
|
-
NAME
|
286
|
-
NAME
|
287
|
-
NAME
|
288
|
-
NAME
|
289
|
-
NAME
|
290
|
-
NAME
|
291
|
-
NAME
|
292
|
-
NAME
|
293
|
-
NAME
|
294
|
-
NAME
|
295
|
-
NAME
|
296
|
-
|
297
|
-
allow(plugin).to receive(:shell_out).
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
it "should run lsblk -P -n -o NAME,UUID" do
|
302
|
-
expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID").
|
264
|
+
@stdout = <<-BLKID_TYPE
|
265
|
+
NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
|
266
|
+
NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
|
267
|
+
NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
|
268
|
+
NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
|
269
|
+
NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
|
270
|
+
NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
|
271
|
+
NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
|
272
|
+
NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
|
273
|
+
NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
|
274
|
+
NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" FSTYPE=\"ext4\"
|
275
|
+
NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
|
276
|
+
NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
|
277
|
+
NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
|
278
|
+
BLKID_TYPE
|
279
|
+
allow(plugin).to receive(:shell_out).
|
280
|
+
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
303
281
|
and_return(mock_shell_out(0, @stdout, ""))
|
304
|
-
plugin.run
|
305
|
-
end
|
306
|
-
|
307
|
-
it "should set uuid to value from lsblk -P -n -o NAME,UUID" do
|
308
|
-
plugin.run
|
309
|
-
expect(plugin[:filesystem]["/dev/sda2"][:uuid]).to eq(
|
310
|
-
"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa"
|
311
|
-
)
|
312
|
-
end
|
313
|
-
|
314
|
-
it "should ignore extra info in name and set uuid to value from lsblk -P -n -o NAME,UUID" do
|
315
|
-
plugin.run
|
316
|
-
expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:uuid]).to eq(
|
317
|
-
"09187faa-3512-4505-81af-7e86d2ccb99a"
|
318
|
-
)
|
319
282
|
end
|
320
|
-
end
|
321
283
|
|
322
|
-
|
323
|
-
before(:each) do
|
324
|
-
@stdout = <<-BLKID_LABEL
|
325
|
-
/dev/sda1: LABEL=\"fuego:0\"
|
326
|
-
/dev/sda2: LABEL=\"fuego:1\"
|
327
|
-
/dev/sdb1: LABEL=\"fuego:0\"
|
328
|
-
/dev/sdb2: LABEL=\"fuego:1\"
|
329
|
-
/dev/md0: LABEL=\"/boot\"
|
330
|
-
/dev/mapper/sys.vg-root.lv: LABEL=\"/\"
|
331
|
-
/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\"
|
332
|
-
/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\"
|
333
|
-
/dev/mapper/sys.vg-var.lv: LABEL=\"/var\"
|
334
|
-
/dev/mapper/sys.vg-home.lv: LABEL=\"/home\"
|
335
|
-
/dev/mapper/debian--7-root: LABEL=\"root\"
|
336
|
-
BLKID_LABEL
|
337
|
-
allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
338
|
-
end
|
339
|
-
|
340
|
-
it "should run blkid -s LABEL" do
|
341
|
-
expect(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, ""))
|
284
|
+
it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
|
342
285
|
plugin.run
|
343
286
|
end
|
344
287
|
|
345
|
-
it "should set
|
346
|
-
plugin.run
|
347
|
-
expect(plugin[:filesystem]["/dev/md0"][:label]).to eq("/boot")
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
describe "when gathering filesystem label data from lsblk" do
|
352
|
-
before(:each) do
|
353
|
-
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
354
|
-
@stdout = <<-BLKID_LABEL
|
355
|
-
NAME="sda1" LABEL="fuego:0"
|
356
|
-
NAME="sda2" LABEL="fuego:1"
|
357
|
-
NAME="sdb1" LABEL="fuego:0"
|
358
|
-
NAME="sdb2" LABEL="fuego:1"
|
359
|
-
NAME="md0" LABEL="/boot"
|
360
|
-
NAME="sys.vg-root.lv" LABEL="/"
|
361
|
-
NAME="sys.vg-tmp.lv" LABEL="/tmp"
|
362
|
-
NAME="sys.vg-usr.lv" LABEL="/usr"
|
363
|
-
NAME="sys.vg-var.lv" LABEL="/var"
|
364
|
-
NAME="sys.vg-home.lv" LABEL="/home"
|
365
|
-
NAME="debian--7-root (dm-0)" LABEL="root"
|
366
|
-
BLKID_LABEL
|
367
|
-
allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
|
368
|
-
and_return(mock_shell_out(0, @stdout, ""))
|
369
|
-
end
|
370
|
-
|
371
|
-
it "should run lsblk -P -n -o NAME,LABEL" do
|
372
|
-
expect(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL").
|
373
|
-
and_return(mock_shell_out(0, @stdout, ""))
|
288
|
+
it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
|
374
289
|
plugin.run
|
290
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
|
291
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
|
292
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
|
375
293
|
end
|
376
294
|
|
377
|
-
it "should set label to value from lsblk -P -
|
295
|
+
it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
|
378
296
|
plugin.run
|
379
|
-
expect(plugin[:filesystem]["/dev/
|
297
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
|
380
298
|
end
|
381
299
|
|
382
|
-
it "should ignore extra info in name and set label to value from lsblk -P -n -o NAME,LABEL" do
|
383
|
-
plugin.run
|
384
|
-
expect(plugin[:filesystem]["/dev/mapper/debian--7-root"][:label]).to eq("root")
|
385
|
-
end
|
386
300
|
end
|
387
301
|
|
388
302
|
describe "when gathering data from /proc/mounts" do
|
@@ -419,18 +333,110 @@ MOUNTS
|
|
419
333
|
|
420
334
|
it "should set mount to value from /proc/mounts" do
|
421
335
|
plugin.run
|
422
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special")
|
336
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
|
423
337
|
end
|
424
338
|
|
425
339
|
it "should set fs_type to value from /proc/mounts" do
|
426
340
|
plugin.run
|
427
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs")
|
341
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
|
428
342
|
end
|
429
343
|
|
430
344
|
it "should set mount_options to an array of values from /proc/mounts" do
|
431
345
|
plugin.run
|
432
|
-
expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
|
346
|
+
expect(plugin[:filesystem]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
|
433
347
|
end
|
434
348
|
end
|
435
349
|
|
350
|
+
describe "when gathering filesystem data with devices mounted more than once" do
|
351
|
+
before(:each) do
|
352
|
+
# there's a few different examples one can run into in this output:
|
353
|
+
# 1. A device physically mounted in more than one place: /home and /home2
|
354
|
+
# 2. A bind-mounted directory, which shows up as the same device in a
|
355
|
+
# subdir: / and /var/chroot
|
356
|
+
# 3. tmpfs in multiple places.
|
357
|
+
@dfstdout = <<-DF
|
358
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
359
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
360
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
361
|
+
udev 2025576 228 2025348 1% /dev
|
362
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
363
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
364
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2
|
365
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot
|
366
|
+
DF
|
367
|
+
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
|
368
|
+
|
369
|
+
@inode_stdout = <<-DFi
|
370
|
+
Filesystem Inodes IUsed IFree IUse% Mounted on
|
371
|
+
/dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
|
372
|
+
tmpfs 126922 273 126649 1% /lib/init/rw
|
373
|
+
none 126922 1 126921 1% /dev/shm
|
374
|
+
udev 126922 1 126921 1% /dev
|
375
|
+
/dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
|
376
|
+
/dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2
|
377
|
+
/dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot
|
378
|
+
DFi
|
379
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
380
|
+
|
381
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
382
|
+
@stdout = <<-BLKID_TYPE
|
383
|
+
NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
|
384
|
+
NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
|
385
|
+
BLKID_TYPE
|
386
|
+
allow(plugin).to receive(:shell_out).
|
387
|
+
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
388
|
+
and_return(mock_shell_out(0, @stdout, ""))
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should provide a devices view with all mountpoints" do
|
392
|
+
plugin.run
|
393
|
+
expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
|
394
|
+
expect(plugin[:filesystem]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
|
395
|
+
expect(plugin[:filesystem]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
describe "when gathering filesystem data with double-mounts" do
|
400
|
+
before(:each) do
|
401
|
+
@dfstdout = <<-DF
|
402
|
+
Filesystem 1024-blocks Used Available Capacity Mounted on
|
403
|
+
/dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
|
404
|
+
tmpfs 2030944 0 2030944 0% /lib/init/rw
|
405
|
+
udev 2025576 228 2025348 1% /dev
|
406
|
+
tmpfs 2030944 2960 2027984 1% /dev/shm
|
407
|
+
/dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
|
408
|
+
/dev/sdb1 97605056 53563252 44041804 55% /mnt
|
409
|
+
/dev/sdc1 4805760 378716 4182924 9% /mnt
|
410
|
+
DF
|
411
|
+
allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
|
412
|
+
|
413
|
+
@inode_stdout = <<-DFi
|
414
|
+
Filesystem Inodes IUsed IFree IUse% Mounted on
|
415
|
+
/dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
|
416
|
+
tmpfs 126922 273 126649 1% /lib/init/rw
|
417
|
+
none 126922 1 126921 1% /dev/shm
|
418
|
+
udev 126922 1 126921 1% /dev
|
419
|
+
/dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
|
420
|
+
/dev/sdb1 60891136 4696030 56195106 8% /mnt
|
421
|
+
/dev/sdc1 1310720 107407 1203313 9% /mnt
|
422
|
+
DFi
|
423
|
+
allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
|
424
|
+
|
425
|
+
allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
|
426
|
+
@stdout = <<-BLKID_TYPE
|
427
|
+
NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
|
428
|
+
NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
|
429
|
+
NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
|
430
|
+
NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
|
431
|
+
BLKID_TYPE
|
432
|
+
allow(plugin).to receive(:shell_out).
|
433
|
+
with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
|
434
|
+
and_return(mock_shell_out(0, @stdout, ""))
|
435
|
+
end
|
436
|
+
|
437
|
+
it "should provide a mounts view with all devices" do
|
438
|
+
plugin.run
|
439
|
+
expect(plugin[:filesystem]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
|
440
|
+
end
|
441
|
+
end
|
436
442
|
end
|