ohai 14.5.4 → 14.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ohai/application.rb +19 -0
  3. data/lib/ohai/exception.rb +1 -0
  4. data/lib/ohai/hints.rb +5 -0
  5. data/lib/ohai/log.rb +2 -0
  6. data/lib/ohai/plugins/cpu.rb +416 -0
  7. data/lib/ohai/plugins/darwin/hardware.rb +1 -7
  8. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  9. data/lib/ohai/plugins/filesystem.rb +326 -115
  10. data/lib/ohai/plugins/linux/platform.rb +1 -1
  11. data/lib/ohai/plugins/os.rb +16 -0
  12. data/lib/ohai/system.rb +12 -2
  13. data/lib/ohai/version.rb +1 -1
  14. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  15. data/spec/unit/plugins/aix/filesystem_spec.rb +23 -1
  16. data/spec/unit/plugins/darwin/cpu_spec.rb +3 -3
  17. data/spec/unit/plugins/freebsd/cpu_spec.rb +2 -2
  18. data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
  19. data/spec/unit/plugins/linux/platform_spec.rb +2 -1
  20. data/spec/unit/plugins/os_spec.rb +33 -0
  21. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  22. data/spec/unit/plugins/solaris2/filesystem.rb +355 -32
  23. data/spec/unit/plugins/windows/cpu_spec.rb +1 -1
  24. metadata +3 -18
  25. data/lib/ohai/plugins/aix/cpu.rb +0 -64
  26. data/lib/ohai/plugins/aix/filesystem.rb +0 -90
  27. data/lib/ohai/plugins/aix/os.rb +0 -30
  28. data/lib/ohai/plugins/darwin/cpu.rb +0 -50
  29. data/lib/ohai/plugins/dragonflybsd/cpu.rb +0 -58
  30. data/lib/ohai/plugins/dragonflybsd/os.rb +0 -31
  31. data/lib/ohai/plugins/freebsd/cpu.rb +0 -70
  32. data/lib/ohai/plugins/freebsd/os.rb +0 -32
  33. data/lib/ohai/plugins/linux/cpu.rb +0 -120
  34. data/lib/ohai/plugins/netbsd/cpu.rb +0 -50
  35. data/lib/ohai/plugins/openbsd/cpu.rb +0 -43
  36. data/lib/ohai/plugins/solaris2/cpu.rb +0 -70
  37. data/lib/ohai/plugins/solaris2/filesystem.rb +0 -106
  38. data/lib/ohai/plugins/windows/cpu.rb +0 -59
  39. data/spec/unit/plugins/aix/os_spec.rb +0 -35
  40. data/spec/unit/plugins/freebsd/os_spec.rb +0 -32
@@ -62,7 +62,7 @@ end
62
62
 
63
63
  describe Ohai::System, "Windows cpu plugin" do
64
64
  before(:each) do
65
- @plugin = get_plugin("windows/cpu")
65
+ @plugin = get_plugin("cpu")
66
66
  allow(@plugin).to receive(:collect_os).and_return(:windows)
67
67
 
68
68
  @double_wmi = double(WmiLite::Wmi)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.5.4
4
+ version: 14.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-17 00:00:00.000000000 Z
11
+ date: 2018-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -215,12 +215,9 @@ files:
215
215
  - lib/ohai/mixin/softlayer_metadata.rb
216
216
  - lib/ohai/mixin/string.rb
217
217
  - lib/ohai/plugin_config.rb
218
- - lib/ohai/plugins/aix/cpu.rb
219
- - lib/ohai/plugins/aix/filesystem.rb
220
218
  - lib/ohai/plugins/aix/kernel.rb
221
219
  - lib/ohai/plugins/aix/memory.rb
222
220
  - lib/ohai/plugins/aix/network.rb
223
- - lib/ohai/plugins/aix/os.rb
224
221
  - lib/ohai/plugins/aix/platform.rb
225
222
  - lib/ohai/plugins/aix/uptime.rb
226
223
  - lib/ohai/plugins/aix/virtualization.rb
@@ -230,7 +227,7 @@ files:
230
227
  - lib/ohai/plugins/chef.rb
231
228
  - lib/ohai/plugins/cloud.rb
232
229
  - lib/ohai/plugins/command.rb
233
- - lib/ohai/plugins/darwin/cpu.rb
230
+ - lib/ohai/plugins/cpu.rb
234
231
  - lib/ohai/plugins/darwin/hardware.rb
235
232
  - lib/ohai/plugins/darwin/memory.rb
236
233
  - lib/ohai/plugins/darwin/network.rb
@@ -240,20 +237,16 @@ files:
240
237
  - lib/ohai/plugins/digital_ocean.rb
241
238
  - lib/ohai/plugins/dmi.rb
242
239
  - lib/ohai/plugins/docker.rb
243
- - lib/ohai/plugins/dragonflybsd/cpu.rb
244
240
  - lib/ohai/plugins/dragonflybsd/memory.rb
245
241
  - lib/ohai/plugins/dragonflybsd/network.rb
246
- - lib/ohai/plugins/dragonflybsd/os.rb
247
242
  - lib/ohai/plugins/dragonflybsd/platform.rb
248
243
  - lib/ohai/plugins/ec2.rb
249
244
  - lib/ohai/plugins/elixir.rb
250
245
  - lib/ohai/plugins/erlang.rb
251
246
  - lib/ohai/plugins/eucalyptus.rb
252
247
  - lib/ohai/plugins/filesystem.rb
253
- - lib/ohai/plugins/freebsd/cpu.rb
254
248
  - lib/ohai/plugins/freebsd/memory.rb
255
249
  - lib/ohai/plugins/freebsd/network.rb
256
- - lib/ohai/plugins/freebsd/os.rb
257
250
  - lib/ohai/plugins/freebsd/platform.rb
258
251
  - lib/ohai/plugins/gce.rb
259
252
  - lib/ohai/plugins/go.rb
@@ -269,7 +262,6 @@ files:
269
262
  - lib/ohai/plugins/libvirt.rb
270
263
  - lib/ohai/plugins/linode.rb
271
264
  - lib/ohai/plugins/linux/block_device.rb
272
- - lib/ohai/plugins/linux/cpu.rb
273
265
  - lib/ohai/plugins/linux/fips.rb
274
266
  - lib/ohai/plugins/linux/hostnamectl.rb
275
267
  - lib/ohai/plugins/linux/lsb.rb
@@ -284,7 +276,6 @@ files:
284
276
  - lib/ohai/plugins/linux/virtualization.rb
285
277
  - lib/ohai/plugins/lua.rb
286
278
  - lib/ohai/plugins/mono.rb
287
- - lib/ohai/plugins/netbsd/cpu.rb
288
279
  - lib/ohai/plugins/netbsd/memory.rb
289
280
  - lib/ohai/plugins/netbsd/network.rb
290
281
  - lib/ohai/plugins/netbsd/platform.rb
@@ -292,7 +283,6 @@ files:
292
283
  - lib/ohai/plugins/nodejs.rb
293
284
  - lib/ohai/plugins/ohai.rb
294
285
  - lib/ohai/plugins/ohai_time.rb
295
- - lib/ohai/plugins/openbsd/cpu.rb
296
286
  - lib/ohai/plugins/openbsd/memory.rb
297
287
  - lib/ohai/plugins/openbsd/network.rb
298
288
  - lib/ohai/plugins/openbsd/platform.rb
@@ -316,9 +306,7 @@ files:
316
306
  - lib/ohai/plugins/shard.rb
317
307
  - lib/ohai/plugins/shells.rb
318
308
  - lib/ohai/plugins/softlayer.rb
319
- - lib/ohai/plugins/solaris2/cpu.rb
320
309
  - lib/ohai/plugins/solaris2/dmi.rb
321
- - lib/ohai/plugins/solaris2/filesystem.rb
322
310
  - lib/ohai/plugins/solaris2/memory.rb
323
311
  - lib/ohai/plugins/solaris2/network.rb
324
312
  - lib/ohai/plugins/solaris2/platform.rb
@@ -329,7 +317,6 @@ files:
329
317
  - lib/ohai/plugins/uptime.rb
330
318
  - lib/ohai/plugins/virtualbox.rb
331
319
  - lib/ohai/plugins/vmware.rb
332
- - lib/ohai/plugins/windows/cpu.rb
333
320
  - lib/ohai/plugins/windows/drivers.rb
334
321
  - lib/ohai/plugins/windows/filesystem.rb
335
322
  - lib/ohai/plugins/windows/fips.rb
@@ -402,7 +389,6 @@ files:
402
389
  - spec/unit/plugins/aix/kernel_spec.rb
403
390
  - spec/unit/plugins/aix/memory_spec.rb
404
391
  - spec/unit/plugins/aix/network_spec.rb
405
- - spec/unit/plugins/aix/os_spec.rb
406
392
  - spec/unit/plugins/aix/platform_spec.rb
407
393
  - spec/unit/plugins/aix/uptime_spec.rb
408
394
  - spec/unit/plugins/aix/virtualization_spec.rb
@@ -435,7 +421,6 @@ files:
435
421
  - spec/unit/plugins/freebsd/cpu_spec.rb
436
422
  - spec/unit/plugins/freebsd/hostname_spec.rb
437
423
  - spec/unit/plugins/freebsd/kernel_spec.rb
438
- - spec/unit/plugins/freebsd/os_spec.rb
439
424
  - spec/unit/plugins/freebsd/platform_spec.rb
440
425
  - spec/unit/plugins/gce_spec.rb
441
426
  - spec/unit/plugins/go_spec.rb
@@ -1,64 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman <joshua@chef.io>
3
- # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
4
- # Author:: Isa Farnik (<isa@chef.io>)
5
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- Ohai.plugin(:CPU) do
22
- provides "cpu"
23
-
24
- collect_data(:aix) do
25
- cpu Mash.new
26
-
27
- cpu[:total] = shell_out("pmcycles -m").stdout.lines.length
28
-
29
- # The below is only relevent on an LPAR
30
- if shell_out("uname -W").stdout.strip == "0"
31
-
32
- # At least one CPU will be available, but we'll wait to increment this later.
33
- cpu[:available] = 0
34
-
35
- cpudevs = shell_out("lsdev -Cc processor").stdout.lines
36
- # from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
37
- # on AIX number of cores and processors are considered same
38
- cpu[:real] = cpu[:cores] = cpudevs.length
39
- cpudevs.each.with_index do |c, i|
40
- name, status, location = c.split
41
- index = i.to_s
42
- cpu[index] = Mash.new
43
- cpu[index][:status] = status
44
- cpu[index][:location] = location
45
- if status =~ /Available/
46
- cpu[:available] += 1
47
- lsattr = shell_out("lsattr -El #{name}").stdout.lines
48
- lsattr.each do |attribute|
49
- attrib, value = attribute.split
50
- if attrib == "type"
51
- cpu[index][:model_name] = value
52
- elsif attrib == "frequency"
53
- cpu[index][:mhz] = value.to_i / (1000 * 1000) # convert from hz to MHz
54
- else
55
- cpu[index][attrib] = value
56
- end
57
- end
58
- # IBM is the only maker of CPUs for AIX systems.
59
- cpu[index][:vendor_id] = "IBM"
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,90 +0,0 @@
1
- #
2
- # Author:: Deepali Jagtap (<deepali.jagtap@clogeny.com>)
3
- # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
4
- # Author:: Isa Farnik (<isa@chef.io>)
5
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
- # implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
-
22
- Ohai.plugin(:Filesystem) do
23
- provides "filesystem"
24
-
25
- def parse_df_or_mount(shell_out)
26
- oldie = Mash.new
27
-
28
- shell_out.lines.each do |line|
29
- fields = line.split
30
- case line
31
- # headers and horizontal rules to skip
32
- when /^\s*(node|---|^Filesystem\s+1024-blocks)/
33
- next
34
- # strictly a df entry
35
- when /^(.+?)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+\%*)\s+(.+)$/
36
- if $1 == "Global"
37
- key = "#{$1}:#{$6}"
38
- else
39
- key = $1
40
- end
41
- oldie[key] ||= Mash.new
42
- oldie[key][:kb_size] = $2
43
- oldie[key][:kb_used] = $3
44
- oldie[key][:kb_available] = $4
45
- oldie[key][:percent_used] = $5
46
- oldie[key][:mount] = $6
47
- # an entry starting with 'G' or / (E.G. /tmp or /var)
48
- when /^\s*(G.*?|\/\w)/
49
- if fields[0] == "Global"
50
- key = fields[0] + ":" + fields[1]
51
- else
52
- key = fields[0]
53
- end
54
- oldie[key] ||= Mash.new
55
- oldie[key][:mount] = fields[1]
56
- oldie[key][:fs_type] = fields[2]
57
- oldie[key][:mount_options] = fields[6].split(",")
58
- # entries occupying the 'Node' column parsed here
59
- else
60
- key = fields[0] + ":" + fields[1]
61
- oldie[key] ||= Mash.new
62
- oldie[key][:mount] = fields[2]
63
- oldie[key][:fs_type] = fields[3]
64
- oldie[key][:mount_options] = fields[7].split(",")
65
- end
66
- end
67
- oldie
68
- end
69
-
70
- def collect_old_version(shell_outs)
71
- mount_hash = parse_df_or_mount shell_outs[:mount]
72
- df_hash = parse_df_or_mount shell_outs[:df_Pk]
73
-
74
- mount_hash.each do |key, hash|
75
- df_hash[key].merge!(hash) if df_hash.key?(key)
76
- end
77
-
78
- mount_hash.merge(df_hash)
79
- end
80
-
81
- collect_data(:aix) do
82
-
83
- # Cache the command output
84
- shell_outs = Mash.new
85
- shell_outs[:mount] = shell_out("mount").stdout
86
- shell_outs[:df_Pk] = shell_out("df -Pk").stdout
87
-
88
- filesystem collect_old_version(shell_outs)
89
- end
90
- end
@@ -1,30 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Author:: Isa Farnik (<isa@chef.io>)
4
- # Copyright:: Copyright (c) 2013-2016 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 "ohai/mixin/os"
21
-
22
- Ohai.plugin(:OS) do
23
- provides "os", "os_version"
24
- depends "kernel"
25
-
26
- collect_data(:aix) do
27
- os collect_os
28
- os_version shell_out("oslevel -s").stdout.strip
29
- end
30
- end
@@ -1,50 +0,0 @@
1
- #
2
- # Author:: Nathan L Smith (<nlloyds@gmail.com>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2013-2016 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
- Ohai.plugin(:CPU) do
21
- provides "cpu"
22
-
23
- collect_data(:darwin) do
24
- cpu Mash.new
25
- shell_out("sysctl -a").stdout.lines.each do |line|
26
- case line
27
- when /^hw.packages: (.*)$/
28
- cpu[:real] = Regexp.last_match[1].to_i
29
- when /^hw.physicalcpu: (.*)$/
30
- cpu[:cores] = Regexp.last_match[1].to_i
31
- when /^hw.logicalcpu: (.*)$/
32
- cpu[:total] = Regexp.last_match[1].to_i
33
- when /^hw.cpufrequency: (.*)$/
34
- cpu[:mhz] = Regexp.last_match[1].to_i / 1000000
35
- when /^machdep.cpu.vendor: (.*)$/
36
- cpu[:vendor_id] = Regexp.last_match[1].chomp
37
- when /^machdep.cpu.brand_string: (.*)$/
38
- cpu[:model_name] = Regexp.last_match[1].chomp
39
- when /^machdep.cpu.model: (.*)$/
40
- cpu[:model] = Regexp.last_match[1].to_i
41
- when /^machdep.cpu.family: (.*)$/
42
- cpu[:family] = Regexp.last_match[1].to_i
43
- when /^machdep.cpu.stepping: (.*)$/
44
- cpu[:stepping] = Regexp.last_match[1].to_i
45
- when /^machdep.cpu.features: (.*)$/
46
- cpu[:flags] = Regexp.last_match[1].downcase.split(" ")
47
- end
48
- end
49
- end
50
- end
@@ -1,58 +0,0 @@
1
- #
2
- # Author:: Bryan McLellan (btm@loftninjas.org)
3
- # Copyright:: Copyright (c) 2008 Bryan McLellan
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
- Ohai.plugin(:CPU) do
20
- provides "cpu"
21
-
22
- collect_data(:dragonflybsd) do
23
- # all dmesg output for smp I can find only provides info about a single processor
24
- # identical processors is probably a hardware requirement so we'll duplicate data for each cpu
25
- # old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
26
- cpuinfo = Mash.new
27
- cpuinfo["flags"] = []
28
-
29
- # /var/run/dmesg.boot
30
- # CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)
31
- # Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9
32
- # Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>
33
- # Features2=0x209<SSE3,MON,SSSE3>
34
- # AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
35
- # AMD Features2=0x1<LAHF>
36
-
37
- File.open("/var/run/dmesg.boot").each do |line|
38
- case line
39
- when /CPU:\s+(.+) \(([\d.]+).+\)/
40
- cpuinfo["model_name"] = $1
41
- cpuinfo["mhz"] = $2
42
- when /Origin = "(.+)"\s+Id = (.+)\s+Stepping = (.+)/
43
- cpuinfo["vendor_id"] = $1
44
- cpuinfo["stepping"] = $3
45
- # These _should_ match /AMD Features2?/ lines as well
46
- when /Features=.+<(.+)>/
47
- cpuinfo["flags"].concat($1.downcase.split(","))
48
- # Features2=0x80000001<SSE3,<b31>>
49
- when /Features2=[a-f\dx]+<(.+)>/
50
- cpuinfo["flags"].concat($1.downcase.split(","))
51
- end
52
- end
53
-
54
- cpu cpuinfo
55
- so = shell_out("sysctl -n hw.ncpu")
56
- cpu[:total] = so.stdout.split($/)[0].to_i
57
- end
58
- end
@@ -1,31 +0,0 @@
1
- #
2
- # Authors:: Adam Jacob (<adam@chef.io>)
3
- # Richard Manyanza (<liseki@nyikacraftsmen.com>)
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
5
- # Copyright:: Copyright (c) 2014 Richard Manyanza.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- Ohai.plugin(:OS) do
22
- require "ohai/mixin/os"
23
- provides "os", "os_version"
24
-
25
- collect_data(:dragonflybsd) do
26
- os collect_os
27
-
28
- # This is __DragonFly_version. See sys/param.h
29
- os_version shell_out("sysctl -n kern.osreldate").stdout.split($/)[0]
30
- end
31
- end