ohai 8.26.1 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -4
  3. data/Rakefile +14 -0
  4. data/lib/ohai/application.rb +1 -0
  5. data/lib/ohai/config.rb +2 -88
  6. data/lib/ohai/dsl/plugin.rb +0 -4
  7. data/lib/ohai/exception.rb +0 -1
  8. data/lib/ohai/loader.rb +11 -2
  9. data/lib/ohai/log.rb +3 -1
  10. data/lib/ohai/mixin/command.rb +1 -318
  11. data/lib/ohai/mixin/do_metadata.rb +47 -0
  12. data/lib/ohai/mixin/ec2_metadata.rb +2 -29
  13. data/lib/ohai/mixin/gce_metadata.rb +0 -37
  14. data/lib/ohai/mixin/http_helper.rb +56 -0
  15. data/lib/ohai/mixin/network_constants.rb +0 -5
  16. data/lib/ohai/plugins/cloud.rb +144 -157
  17. data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
  18. data/lib/ohai/plugins/digital_ocean.rb +24 -42
  19. data/lib/ohai/plugins/dmi.rb +81 -77
  20. data/lib/ohai/plugins/ec2.rb +33 -60
  21. data/lib/ohai/plugins/gce.rb +3 -1
  22. data/lib/ohai/plugins/hostname.rb +1 -16
  23. data/lib/ohai/plugins/linux/filesystem.rb +130 -81
  24. data/lib/ohai/plugins/linux/mdadm.rb +3 -45
  25. data/lib/ohai/plugins/linux/network.rb +1 -26
  26. data/lib/ohai/plugins/linux/platform.rb +4 -2
  27. data/lib/ohai/plugins/linux/virtualization.rb +1 -5
  28. data/lib/ohai/plugins/scala.rb +1 -13
  29. data/lib/ohai/plugins/solaris2/network.rb +1 -2
  30. data/lib/ohai/plugins/uptime.rb +0 -9
  31. data/lib/ohai/plugins/windows/cpu.rb +2 -1
  32. data/lib/ohai/plugins/windows/network.rb +1 -1
  33. data/lib/ohai/runner.rb +0 -5
  34. data/lib/ohai/system.rb +38 -8
  35. data/lib/ohai/version.rb +2 -2
  36. data/ohai.gemspec +1 -1
  37. data/spec/functional/application_spec.rb +0 -40
  38. data/spec/functional/plugins/powershell_spec.rb +1 -1
  39. data/spec/functional/plugins/root_group_spec.rb +1 -1
  40. data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
  41. data/spec/ohai_spec.rb +1 -1
  42. data/spec/support/integration_helper.rb +17 -0
  43. data/spec/support/platform_helpers.rb +17 -0
  44. data/spec/unit/application_spec.rb +0 -1
  45. data/spec/unit/config_spec.rb +0 -111
  46. data/spec/unit/dsl/plugin_spec.rb +1 -1
  47. data/spec/unit/hints_spec.rb +1 -1
  48. data/spec/unit/loader_spec.rb +26 -1
  49. data/spec/unit/mixin/command_spec.rb +1 -69
  50. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  51. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  52. data/spec/unit/plugin_config_spec.rb +0 -1
  53. data/spec/unit/plugins/abort_spec.rb +1 -1
  54. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  55. data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
  56. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  57. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  58. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  59. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  60. data/spec/unit/plugins/aix/os_spec.rb +1 -1
  61. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  62. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  63. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  64. data/spec/unit/plugins/azure_spec.rb +1 -1
  65. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  66. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  67. data/spec/unit/plugins/c_spec.rb +1 -1
  68. data/spec/unit/plugins/chef_spec.rb +1 -2
  69. data/spec/unit/plugins/cloud_spec.rb +210 -50
  70. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
  71. data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
  72. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  73. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  74. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  75. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  76. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  77. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  78. data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
  79. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  80. data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
  81. data/spec/unit/plugins/dmi_spec.rb +1 -1
  82. data/spec/unit/plugins/ec2_spec.rb +10 -62
  83. data/spec/unit/plugins/elixir_spec.rb +1 -1
  84. data/spec/unit/plugins/erlang_spec.rb +1 -1
  85. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  86. data/spec/unit/plugins/fail_spec.rb +1 -1
  87. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  88. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  89. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  90. data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
  91. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  92. data/spec/unit/plugins/gce_spec.rb +1 -1
  93. data/spec/unit/plugins/go_spec.rb +1 -1
  94. data/spec/unit/plugins/groovy_spec.rb +1 -1
  95. data/spec/unit/plugins/haskell_spec.rb +1 -1
  96. data/spec/unit/plugins/hostname_spec.rb +16 -41
  97. data/spec/unit/plugins/init_package_spec.rb +1 -1
  98. data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
  99. data/spec/unit/plugins/java_spec.rb +1 -1
  100. data/spec/unit/plugins/joyent_spec.rb +17 -1
  101. data/spec/unit/plugins/kernel_spec.rb +1 -1
  102. data/spec/unit/plugins/linode_spec.rb +1 -1
  103. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  104. data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
  105. data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
  106. data/spec/unit/plugins/linux/fips_spec.rb +1 -1
  107. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  108. data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
  109. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
  113. data/spec/unit/plugins/linux/memory_spec.rb +1 -1
  114. data/spec/unit/plugins/linux/network_spec.rb +3 -44
  115. data/spec/unit/plugins/linux/platform_spec.rb +4 -4
  116. data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
  117. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  118. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
  119. data/spec/unit/plugins/lua_spec.rb +1 -1
  120. data/spec/unit/plugins/mono_spec.rb +1 -1
  121. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  122. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  123. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  124. data/spec/unit/plugins/network_spec.rb +1 -1
  125. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  126. data/spec/unit/plugins/ohai_spec.rb +1 -1
  127. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  128. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  129. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  130. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  131. data/spec/unit/plugins/openstack_spec.rb +2 -3
  132. data/spec/unit/plugins/os_spec.rb +1 -1
  133. data/spec/unit/plugins/packages_spec.rb +1 -1
  134. data/spec/unit/plugins/passwd_spec.rb +17 -1
  135. data/spec/unit/plugins/perl_spec.rb +1 -1
  136. data/spec/unit/plugins/php_spec.rb +1 -1
  137. data/spec/unit/plugins/platform_spec.rb +1 -1
  138. data/spec/unit/plugins/powershell_spec.rb +1 -1
  139. data/spec/unit/plugins/python_spec.rb +1 -1
  140. data/spec/unit/plugins/rackspace_spec.rb +1 -2
  141. data/spec/unit/plugins/root_group_spec.rb +2 -2
  142. data/spec/unit/plugins/ruby_spec.rb +1 -1
  143. data/spec/unit/plugins/rust_spec.rb +1 -1
  144. data/spec/unit/plugins/scala_spec.rb +3 -37
  145. data/spec/unit/plugins/shard_spec.rb +1 -1
  146. data/spec/unit/plugins/shells_spec.rb +1 -1
  147. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  148. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  149. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  150. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  151. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  152. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  153. data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
  154. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  155. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  156. data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
  157. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  158. data/spec/unit/plugins/sysconf_spec.rb +1 -1
  159. data/spec/unit/plugins/timezone_spec.rb +1 -1
  160. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  161. data/spec/unit/plugins/vmware_spec.rb +2 -1
  162. data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
  163. data/spec/unit/plugins/windows/fips_spec.rb +1 -1
  164. data/spec/unit/plugins/windows/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  166. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  167. data/spec/unit/provides_map_spec.rb +1 -1
  168. data/spec/unit/runner_spec.rb +1 -1
  169. data/spec/unit/system_spec.rb +68 -76
  170. data/spec/unit/util/file_helper_spec.rb +1 -1
  171. data/spec/unit/util/ip_helper_spec.rb +1 -1
  172. metadata +6 -20
  173. data/lib/ohai/plugins/cloud_v2.rb +0 -315
  174. data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
  175. data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
  176. data/lib/ohai/plugins/linux/lspci.rb +0 -76
  177. data/lib/ohai/plugins/network_listeners.rb +0 -60
  178. data/lib/ohai/plugins/sigar/cpu.rb +0 -44
  179. data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
  180. data/lib/ohai/plugins/sigar/memory.rb +0 -39
  181. data/lib/ohai/plugins/sigar/network.rb +0 -168
  182. data/lib/ohai/plugins/sigar/network_route.rb +0 -64
  183. data/lib/ohai/plugins/sigar/platform.rb +0 -30
  184. data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
  185. data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
  186. data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
  187. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  188. data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -1,437 +0,0 @@
1
- #
2
- # Author:: Matthew Kent (<mkent@magoazul.com>)
3
- # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
-
21
- describe Ohai::System, "Linux filesystem plugin" do
22
- let (:plugin) { get_plugin("linux/filesystem2") }
23
- before(:each) do
24
- allow(plugin).to receive(:collect_os).and_return(:linux)
25
-
26
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, "", ""))
27
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, "", ""))
28
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, "", ""))
29
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(false)
30
- allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, "", ""))
31
-
32
- allow(plugin).to receive(:shell_out).
33
- with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
34
- and_return(mock_shell_out(0, "", ""))
35
-
36
- allow(File).to receive(:exist?).with("/proc/mounts").and_return(false)
37
-
38
- %w{sdb1 sdb2 sda1 sda2 md0 md1 md2}.each do |name|
39
- allow(File).to receive(:exist?).with("/dev/#{name}").and_return(true)
40
- end
41
- %w{
42
- sys.vg-root.lv
43
- sys.vg-swap.lv
44
- sys.vg-tmp.lv
45
- sys.vg-usr.lv
46
- sys.vg-var.lv
47
- sys.vg-home.lv
48
- debian--7-root
49
- }.each do |name|
50
- allow(File).to receive(:exist?).with("/dev/#{name}").and_return(false)
51
- allow(File).to receive(:exist?).with("/dev/mapper/#{name}").and_return(true)
52
- end
53
- end
54
-
55
- describe "when gathering filesystem usage data from df" do
56
- before(:each) do
57
- @stdout = <<-DF
58
- Filesystem 1024-blocks Used Available Capacity Mounted on
59
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
60
- tmpfs 2030944 0 2030944 0% /lib/init/rw
61
- udev 2025576 228 2025348 1% /dev
62
- tmpfs 2030944 2960 2027984 1% /dev/shm
63
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
64
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
65
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
66
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
67
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
68
- /dev/md0 960492 36388 875312 4% /boot
69
- DF
70
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, ""))
71
-
72
- @inode_stdout = <<-DFi
73
- Filesystem Inodes IUsed IFree IUse% Mounted on
74
- /dev/xvda1 1310720 107407 1203313 9% /
75
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
76
- tmpfs 126922 273 126649 1% /run
77
- none 126922 1 126921 1% /run/lock
78
- none 126922 1 126921 1% /run/shm
79
- DFi
80
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
81
- end
82
-
83
- it "should run df -P and df -iP" do
84
- expect(plugin).to receive(:shell_out).ordered.with("df -P").and_return(mock_shell_out(0, @stdout, ""))
85
- expect(plugin).to receive(:shell_out).ordered.with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
86
- plugin.run
87
- end
88
-
89
- it "should set kb_size to value from df -P" do
90
- plugin.run
91
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_size]).to eq("97605057")
92
- end
93
-
94
- it "should set kb_used to value from df -P" do
95
- plugin.run
96
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_used]).to eq("53563253")
97
- end
98
-
99
- it "should set kb_available to value from df -P" do
100
- plugin.run
101
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:kb_available]).to eq("44041805")
102
- end
103
-
104
- it "should set percent_used to value from df -P" do
105
- plugin.run
106
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:percent_used]).to eq("56%")
107
- end
108
-
109
- it "should set mount to value from df -P" do
110
- plugin.run
111
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
112
- end
113
-
114
- it "should set total_inodes to value from df -iP" do
115
- plugin.run
116
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:total_inodes]).to eq("124865")
117
- end
118
-
119
- it "should set inodes_used to value from df -iP" do
120
- plugin.run
121
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_used]).to eq("380")
122
- end
123
-
124
- it "should set inodes_available to value from df -iP" do
125
- plugin.run
126
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:inodes_available]).to eq("124485")
127
- end
128
- end
129
-
130
- describe "when gathering mounted filesystem data from mount" do
131
- before(:each) do
132
- @stdout = <<-MOUNT
133
- /dev/mapper/sys.vg-root.lv on / type ext4 (rw,noatime,errors=remount-ro)
134
- tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
135
- proc on /proc type proc (rw,noexec,nosuid,nodev)
136
- sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
137
- udev on /dev type tmpfs (rw,mode=0755)
138
- tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
139
- devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
140
- /dev/mapper/sys.vg-home.lv on /home type xfs (rw,noatime)
141
- /dev/mapper/sys.vg-special.lv on /special type xfs (ro,noatime)
142
- /dev/mapper/sys.vg-tmp.lv on /tmp type ext4 (rw,noatime)
143
- /dev/mapper/sys.vg-usr.lv on /usr type ext4 (rw,noatime)
144
- /dev/mapper/sys.vg-var.lv on /var type ext4 (rw,noatime)
145
- /dev/md0 on /boot type ext3 (rw,noatime,errors=remount-ro)
146
- fusectl on /sys/fs/fuse/connections type fusectl (rw)
147
- binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
148
- MOUNT
149
- allow(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
150
- end
151
-
152
- it "should run mount" do
153
- expect(plugin).to receive(:shell_out).with("mount").and_return(mock_shell_out(0, @stdout, ""))
154
- plugin.run
155
- end
156
-
157
- it "should set mount to value from mount" do
158
- plugin.run
159
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
160
- end
161
-
162
- it "should set fs_type to value from mount" do
163
- plugin.run
164
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
165
- end
166
-
167
- it "should set mount_options to an array of values from mount" do
168
- plugin.run
169
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime})
170
- end
171
- end
172
-
173
- describe "when gathering filesystem type data from blkid" do
174
- before(:each) do
175
- # blkid and lsblk output are coorelated with df/mount output, so the
176
- # most full test of them actually requires we have both
177
- @dfstdout = <<-DF
178
- Filesystem 1024-blocks Used Available Capacity Mounted on
179
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
180
- tmpfs 2030944 0 2030944 0% /lib/init/rw
181
- udev 2025576 228 2025348 1% /dev
182
- tmpfs 2030944 2960 2027984 1% /dev/shm
183
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
184
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
185
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
186
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
187
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
188
- /dev/md0 960492 36388 875312 4% /boot
189
- DF
190
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
191
-
192
- @inode_stdout = <<-DFi
193
- Filesystem Inodes IUsed IFree IUse% Mounted on
194
- /dev/xvda1 1310720 107407 1203313 9% /
195
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
196
- tmpfs 126922 273 126649 1% /run
197
- none 126922 1 126921 1% /run/lock
198
- none 126922 1 126921 1% /run/shm
199
- DFi
200
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
201
-
202
- @stdout = <<-BLKID_TYPE
203
- /dev/sdb1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
204
- /dev/sdb2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
205
- /dev/sda1: LABEL=\"fuego:0\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" TYPE=\"linux_raid_member\"
206
- /dev/sda2: LABEL=\"fuego:1\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" TYPE=\"linux_raid_member\"
207
- /dev/md0: LABEL=\"/boot\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" TYPE=\"ext3\"
208
- /dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" TYPE=\"LVM2_member\"
209
- /dev/mapper/sys.vg-root.lv: LABEL=\"/\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" TYPE=\"ext4\"
210
- /dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" TYPE=\"swap\"
211
- /dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" TYPE=\"ext4\"
212
- /dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" TYPE=\"ext4\"
213
- /dev/mapper/sys.vg-var.lv: LABEL=\"/var\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" TYPE=\"ext4\"
214
- /dev/mapper/sys.vg-home.lv: LABEL=\"/home\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" TYPE=\"xfs\"
215
- BLKID_TYPE
216
- allow(plugin).to receive(:shell_out).with("blkid").and_return(mock_shell_out(0, @stdout, ""))
217
- end
218
-
219
- it "should run blkid" do
220
- plugin.run
221
- end
222
-
223
- it "should set kb_size to value from blkid" do
224
- plugin.run
225
- expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
226
- expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
227
- expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
228
- end
229
- end
230
-
231
- describe "when gathering filesystem type data from lsblk" do
232
- before(:each) do
233
- @dfstdout = <<-DF
234
- Filesystem 1024-blocks Used Available Capacity Mounted on
235
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
236
- tmpfs 2030944 0 2030944 0% /lib/init/rw
237
- udev 2025576 228 2025348 1% /dev
238
- tmpfs 2030944 2960 2027984 1% /dev/shm
239
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
240
- /dev/mapper/sys.vg-special.lv 97605057 53563253 44041805 56% /special
241
- /dev/mapper/sys.vg-tmp.lv 1919048 46588 1774976 3% /tmp
242
- /dev/mapper/sys.vg-usr.lv 19223252 5479072 12767696 31% /usr
243
- /dev/mapper/sys.vg-var.lv 19223252 3436556 14810212 19% /var
244
- /dev/md0 960492 36388 875312 4% /boot
245
- DF
246
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
247
-
248
- @inode_stdout = <<-DFi
249
- Filesystem Inodes IUsed IFree IUse% Mounted on
250
- /dev/xvda1 1310720 107407 1203313 9% /
251
- /dev/mapper/sys.vg-special.lv 124865 380 124485 1% /special
252
- tmpfs 126922 273 126649 1% /run
253
- none 126922 1 126921 1% /run/lock
254
- none 126922 1 126921 1% /run/shm
255
- DFi
256
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
257
-
258
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
259
- @stdout = <<-BLKID_TYPE
260
- NAME=\"sdb1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
261
- NAME=\"sdb2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
262
- NAME=\"sda1\" UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" LABEL=\"fuego:0\" FSTYPE=\"LVM2_member\"
263
- NAME=\"sda2\" UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" LABEL=\"fuego:1\" FSTYPE=\"LVM2_member\"
264
- NAME=\"md0\" UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" LABEL=\"/boot\" FSTYPE=\"ext3\"
265
- NAME=\"md1\" UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" LABEL=\"\" FSTYPE=\"LVM2_member\"
266
- NAME=\"sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
267
- NAME=\"sys.vg-swap.lv\" UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" LABEL=\"\" FSTYPE=\"swap\"
268
- NAME=\"sys.vg-tmp.lv\" UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" LABEL=\"/tmp\" FSTYPE=\"ext4\"
269
- NAME=\"sys.vg-usr.lv\" UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" LABEL=\"/usr\" FSTYPE=\"ext4\"
270
- NAME=\"sys.vg-var.lv\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/var\" FSTYPE=\"ext4\"
271
- NAME=\"sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
272
- NAME=\"debian--7-root (dm-0)\" UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" LABEL=\"root\" FSTYPE=\"ext4\"
273
- BLKID_TYPE
274
- allow(plugin).to receive(:shell_out).
275
- with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
276
- and_return(mock_shell_out(0, @stdout, ""))
277
- end
278
-
279
- it "should run lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
280
- plugin.run
281
- end
282
-
283
- it "should set kb_size to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
284
- plugin.run
285
- expect(plugin[:filesystem2]["by_pair"]["/dev/md1,"][:fs_type]).to eq("LVM2_member")
286
- expect(plugin[:filesystem2]["by_pair"]["/dev/sda2,"][:uuid]).to eq("e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa")
287
- expect(plugin[:filesystem2]["by_pair"]["/dev/md0,/boot"][:label]).to eq("/boot")
288
- end
289
-
290
- it "should ignore extra info in name and set label to value from lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" do
291
- plugin.run
292
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/debian--7-root,"][:label]).to eq("root")
293
- end
294
-
295
- end
296
-
297
- describe "when gathering data from /proc/mounts" do
298
- before(:each) do
299
- allow(File).to receive(:exist?).with("/proc/mounts").and_return(true)
300
- @double_file = double("/proc/mounts")
301
- @mounts = <<-MOUNTS
302
- rootfs / rootfs rw 0 0
303
- none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
304
- none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
305
- none /dev devtmpfs rw,relatime,size=2025576k,nr_inodes=506394,mode=755 0 0
306
- none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
307
- /dev/mapper/sys.vg-root.lv / ext4 rw,noatime,errors=remount-ro,barrier=1,data=ordered 0 0
308
- tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
309
- tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0
310
- /dev/mapper/sys.vg-home.lv /home xfs rw,noatime,attr2,noquota 0 0
311
- /dev/mapper/sys.vg-special.lv /special xfs ro,noatime,attr2,noquota 0 0
312
- /dev/mapper/sys.vg-tmp.lv /tmp ext4 rw,noatime,barrier=1,data=ordered 0 0
313
- /dev/mapper/sys.vg-usr.lv /usr ext4 rw,noatime,barrier=1,data=ordered 0 0
314
- /dev/mapper/sys.vg-var.lv /var ext4 rw,noatime,barrier=1,data=ordered 0 0
315
- /dev/md0 /boot ext3 rw,noatime,errors=remount-ro,data=ordered 0 0
316
- fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
317
- binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
318
- MOUNTS
319
- @counter = 0
320
- allow(@double_file).to receive(:read_nonblock) do
321
- @counter += 1
322
- raise EOFError if @counter == 2
323
- @mounts
324
- end
325
- allow(@double_file).to receive(:close)
326
- allow(File).to receive(:open).with("/proc/mounts").and_return(@double_file)
327
- end
328
-
329
- it "should set mount to value from /proc/mounts" do
330
- plugin.run
331
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount]).to eq("/special")
332
- end
333
-
334
- it "should set fs_type to value from /proc/mounts" do
335
- plugin.run
336
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:fs_type]).to eq("xfs")
337
- end
338
-
339
- it "should set mount_options to an array of values from /proc/mounts" do
340
- plugin.run
341
- expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota})
342
- end
343
- end
344
-
345
- describe "when gathering filesystem data with devices mounted more than once" do
346
- before(:each) do
347
- # there's a few different examples one can run into in this output:
348
- # 1. A device physically mounted in more than one place: /home and /home2
349
- # 2. A bind-mounted directory, which shows up as the same device in a
350
- # subdir: / and /var/chroot
351
- # 3. tmpfs in multiple places.
352
- @dfstdout = <<-DF
353
- Filesystem 1024-blocks Used Available Capacity Mounted on
354
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
355
- tmpfs 2030944 0 2030944 0% /lib/init/rw
356
- udev 2025576 228 2025348 1% /dev
357
- tmpfs 2030944 2960 2027984 1% /dev/shm
358
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
359
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home2
360
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /var/chroot
361
- DF
362
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
363
-
364
- @inode_stdout = <<-DFi
365
- Filesystem Inodes IUsed IFree IUse% Mounted on
366
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
367
- tmpfs 126922 273 126649 1% /lib/init/rw
368
- none 126922 1 126921 1% /dev/shm
369
- udev 126922 1 126921 1% /dev
370
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
371
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home2
372
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /var/chroot
373
- DFi
374
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
375
-
376
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
377
- @stdout = <<-BLKID_TYPE
378
- NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
379
- NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
380
- BLKID_TYPE
381
- allow(plugin).to receive(:shell_out).
382
- with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
383
- and_return(mock_shell_out(0, @stdout, ""))
384
- end
385
-
386
- it "should provide a devices view with all mountpoints" do
387
- plugin.run
388
- expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"])
389
- expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"])
390
- expect(plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"])
391
- end
392
- end
393
-
394
- describe "when gathering filesystem data with double-mounts" do
395
- before(:each) do
396
- @dfstdout = <<-DF
397
- Filesystem 1024-blocks Used Available Capacity Mounted on
398
- /dev/mapper/sys.vg-root.lv 4805760 378716 4182924 9% /
399
- tmpfs 2030944 0 2030944 0% /lib/init/rw
400
- udev 2025576 228 2025348 1% /dev
401
- tmpfs 2030944 2960 2027984 1% /dev/shm
402
- /dev/mapper/sys.vg-home.lv 97605056 53563252 44041804 55% /home
403
- /dev/sdb1 97605056 53563252 44041804 55% /mnt
404
- /dev/sdc1 4805760 378716 4182924 9% /mnt
405
- DF
406
- allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @dfstdout, ""))
407
-
408
- @inode_stdout = <<-DFi
409
- Filesystem Inodes IUsed IFree IUse% Mounted on
410
- /dev/mapper/sys.vg-root.lv 1310720 107407 1203313 9% /
411
- tmpfs 126922 273 126649 1% /lib/init/rw
412
- none 126922 1 126921 1% /dev/shm
413
- udev 126922 1 126921 1% /dev
414
- /dev/mapper/sys.vg-home.lv 60891136 4696030 56195106 8% /home
415
- /dev/sdb1 60891136 4696030 56195106 8% /mnt
416
- /dev/sdc1 1310720 107407 1203313 9% /mnt
417
- DFi
418
- allow(plugin).to receive(:shell_out).with("df -iP").and_return(mock_shell_out(0, @inode_stdout, ""))
419
-
420
- allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true)
421
- @stdout = <<-BLKID_TYPE
422
- NAME=\"/dev/mapper/sys.vg-root.lv\" UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" LABEL=\"/\" FSTYPE=\"ext4\"
423
- NAME=\"/dev/sdb1\" UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
424
- NAME=\"/dev/sdc1\" UUID=\"7f1e51bf-3608-4351-b7cd-379e39cff36a\" LABEL=\"/mnt\" FSTYPE=\"ext4\"
425
- NAME=\"/dev/mapper/sys.vg-home.lv\" UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" LABEL=\"/home\" FSTYPE=\"xfs\"
426
- BLKID_TYPE
427
- allow(plugin).to receive(:shell_out).
428
- with("lsblk -n -P -o NAME,UUID,LABEL,FSTYPE").
429
- and_return(mock_shell_out(0, @stdout, ""))
430
- end
431
-
432
- it "should provide a mounts view with all devices" do
433
- plugin.run
434
- expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"])
435
- end
436
- end
437
- end
@@ -1,133 +0,0 @@
1
- #
2
- # Author:: Phil Dibowitz <phil@ipom.com>
3
- # Copyright:: Copyright (c) 2017 Facebook, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require_relative "../../../spec_helper.rb"
20
-
21
- describe Ohai::System, "Linux lspci plugin" do
22
- let (:plugin) { get_plugin("linux/lspci") }
23
-
24
- before(:each) do
25
- @stdout = <<LSPCI
26
- Device: 00:1f.3
27
- Class: Audio device [0403]
28
- Vendor: Intel Corporation [8086]
29
- Device: Sunrise Point-LP HD Audio [9d71]
30
- SVendor: Lenovo [17aa]
31
- SDevice: Sunrise Point-LP HD Audio [224e]
32
- Rev: 21
33
- Driver: snd_hda_intel
34
- Module: snd_hda_intel
35
- Module: snd_soc_skl
36
-
37
- Device: 00:1f.4
38
- Class: SMBus [0c05]
39
- Vendor: Intel Corporation [8086]
40
- Device: Sunrise Point-LP SMBus [9d23]
41
- SVendor: Lenovo [17aa]
42
- SDevice: Sunrise Point-LP SMBus [224e]
43
- Rev: 21
44
- Driver: i801_smbus
45
- Module: i2c_i801
46
-
47
- Device: 00:1f.6
48
- Class: Ethernet controller [0200]
49
- Vendor: Intel Corporation [8086]
50
- Device: Ethernet Connection (4) I219-LM [15d7]
51
- SVendor: Lenovo [17aa]
52
- SDevice: Ethernet Connection (4) I219-LM [224e]
53
- Rev: 21
54
- Driver: e1000e
55
- Module: e1000e
56
-
57
- Device: 02:00.0
58
- Class: Unassigned class [ff00]
59
- Vendor: Realtek Semiconductor Co., Ltd. [10ec]
60
- Device: RTS525A PCI Express Card Reader [525a]
61
- SVendor: Lenovo [17aa]
62
- SDevice: RTS525A PCI Express Card Reader [224e]
63
- Rev: 01
64
- Driver: rtsx_pci
65
- Module: rtsx_pci
66
-
67
- Device: 04:00.0
68
- Class: Network controller [0280]
69
- Vendor: Intel Corporation [8086]
70
- Device: Wireless 8265 / 8275 [24fd]
71
- SVendor: Intel Corporation [8086]
72
- SDevice: Wireless 8265 / 8275 [0130]
73
- Rev: 88
74
- Driver: iwlwifi
75
- Module: iwlwifi
76
-
77
- Device: 05:00.0
78
- Class: Non-Volatile memory controller [0108]
79
- Vendor: Toshiba America Info Systems [1179]
80
- Device: Device [0115]
81
- SVendor: Toshiba America Info Systems [1179]
82
- SDevice: Device [0001]
83
- Rev: 01
84
- ProgIf: 02
85
- Driver: nvme
86
- Module: nvme
87
- NUMANode: 0
88
- LSPCI
89
- allow(plugin).to receive(:shell_out).with("lspci -vnnmk").and_return(
90
- mock_shell_out(0, @stdout, ""))
91
-
92
- allow(plugin).to receive(:collect_os).and_return(:linux)
93
- end
94
-
95
- describe "when gathering data from lspci" do
96
- it "lists all devices" do
97
- plugin.run
98
- expect(plugin[:pci].keys).to eq(
99
- ["00:1f.3", "00:1f.4", "00:1f.6", "02:00.0", "04:00.0", "05:00.0"]
100
- )
101
- end
102
-
103
- it "parses out device name vs id" do
104
- plugin.run
105
- expect(plugin[:pci]["04:00.0"]["device_name"]).to eq("Wireless 8265 / 8275")
106
- expect(plugin[:pci]["04:00.0"]["device_id"]).to eq("24fd")
107
- end
108
-
109
- it "parses out sdevice name vs id" do
110
- plugin.run
111
- expect(plugin[:pci]["04:00.0"]["sdevice_name"]).to eq("Wireless 8265 / 8275")
112
- expect(plugin[:pci]["04:00.0"]["sdevice_id"]).to eq("0130")
113
- end
114
-
115
- it "parses out class name vs id" do
116
- plugin.run
117
- expect(plugin[:pci]["04:00.0"]["class_name"]).to eq("Network controller")
118
- expect(plugin[:pci]["04:00.0"]["class_id"]).to eq("0280")
119
- end
120
-
121
- it "parses out vendor name vs id" do
122
- plugin.run
123
- expect(plugin[:pci]["04:00.0"]["vendor_name"]).to eq("Intel Corporation")
124
- expect(plugin[:pci]["04:00.0"]["vendor_id"]).to eq("8086")
125
- end
126
-
127
- it "provides drivers and modules" do
128
- plugin.run
129
- expect(plugin[:pci]["04:00.0"]["driver"]).to eq(["iwlwifi"])
130
- expect(plugin[:pci]["04:00.0"]["module"]).to eq(["iwlwifi"])
131
- end
132
- end
133
- end