ohai 13.12.6 → 14.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/README.md +7 -12
  4. data/Rakefile +16 -23
  5. data/docs/man/man1/ohai.1 +97 -0
  6. data/lib/ohai/application.rb +9 -4
  7. data/lib/ohai/common/dmi.rb +4 -16
  8. data/lib/ohai/config.rb +5 -1
  9. data/lib/ohai/dsl.rb +0 -1
  10. data/lib/ohai/dsl/plugin.rb +12 -16
  11. data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
  12. data/lib/ohai/hints.rb +2 -2
  13. data/lib/ohai/loader.rb +21 -70
  14. data/lib/ohai/log.rb +1 -1
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -4
  16. data/lib/ohai/mixin/command.rb +3 -3
  17. data/lib/ohai/mixin/dmi_decode.rb +0 -2
  18. data/lib/ohai/mixin/do_metadata.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  20. data/lib/ohai/mixin/gce_metadata.rb +1 -5
  21. data/lib/ohai/mixin/http_helper.rb +3 -3
  22. data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
  23. data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
  24. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  25. data/lib/ohai/plugins/aix/memory.rb +1 -1
  26. data/lib/ohai/plugins/aix/network.rb +2 -2
  27. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  28. data/lib/ohai/plugins/azure.rb +5 -5
  29. data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
  30. data/lib/ohai/plugins/c.rb +8 -8
  31. data/lib/ohai/plugins/chef.rb +2 -1
  32. data/lib/ohai/plugins/cloud.rb +0 -3
  33. data/lib/ohai/plugins/darwin/cpu.rb +2 -2
  34. data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
  35. data/lib/ohai/plugins/darwin/hardware.rb +9 -3
  36. data/lib/ohai/plugins/darwin/network.rb +2 -2
  37. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  38. data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
  39. data/lib/ohai/plugins/digital_ocean.rb +4 -4
  40. data/lib/ohai/plugins/dmi.rb +15 -14
  41. data/lib/ohai/plugins/docker.rb +57 -0
  42. data/lib/ohai/plugins/ec2.rb +11 -11
  43. data/lib/ohai/plugins/elixir.rb +1 -1
  44. data/lib/ohai/plugins/erlang.rb +2 -2
  45. data/lib/ohai/plugins/eucalyptus.rb +5 -5
  46. data/lib/ohai/plugins/gce.rb +2 -2
  47. data/lib/ohai/plugins/go.rb +1 -1
  48. data/lib/ohai/plugins/groovy.rb +1 -1
  49. data/lib/ohai/plugins/haskell.rb +4 -4
  50. data/lib/ohai/plugins/hostname.rb +6 -6
  51. data/lib/ohai/plugins/init_package.rb +1 -1
  52. data/lib/ohai/plugins/java.rb +1 -1
  53. data/lib/ohai/plugins/kernel.rb +109 -40
  54. data/lib/ohai/plugins/libvirt.rb +113 -0
  55. data/lib/ohai/plugins/linode.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +4 -4
  57. data/lib/ohai/plugins/linux/cpu.rb +3 -3
  58. data/lib/ohai/plugins/linux/filesystem.rb +4 -6
  59. data/lib/ohai/plugins/linux/lsb.rb +3 -3
  60. data/lib/ohai/plugins/linux/lspci.rb +2 -1
  61. data/lib/ohai/plugins/linux/machineid.rb +4 -4
  62. data/lib/ohai/plugins/linux/network.rb +16 -16
  63. data/lib/ohai/plugins/linux/platform.rb +4 -10
  64. data/lib/ohai/plugins/linux/sessions.rb +2 -1
  65. data/lib/ohai/plugins/linux/virtualization.rb +53 -31
  66. data/lib/ohai/plugins/lua.rb +1 -1
  67. data/lib/ohai/plugins/mono.rb +2 -2
  68. data/lib/ohai/plugins/network.rb +11 -11
  69. data/lib/ohai/plugins/nodejs.rb +1 -1
  70. data/lib/ohai/plugins/ohai.rb +0 -2
  71. data/lib/ohai/plugins/openstack.rb +7 -10
  72. data/lib/ohai/plugins/packages.rb +1 -1
  73. data/lib/ohai/plugins/passwd.rb +1 -0
  74. data/lib/ohai/plugins/perl.rb +1 -1
  75. data/lib/ohai/plugins/php.rb +1 -1
  76. data/lib/ohai/plugins/powershell.rb +1 -1
  77. data/lib/ohai/plugins/python.rb +1 -1
  78. data/lib/ohai/plugins/rackspace.rb +5 -5
  79. data/lib/ohai/plugins/root_group.rb +6 -9
  80. data/lib/ohai/plugins/ruby.rb +2 -2
  81. data/lib/ohai/plugins/rust.rb +1 -1
  82. data/lib/ohai/plugins/scala.rb +1 -1
  83. data/lib/ohai/plugins/scaleway.rb +56 -0
  84. data/lib/ohai/plugins/shard.rb +1 -0
  85. data/lib/ohai/plugins/softlayer.rb +2 -2
  86. data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
  87. data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
  88. data/lib/ohai/plugins/solaris2/network.rb +6 -6
  89. data/lib/ohai/plugins/solaris2/platform.rb +2 -2
  90. data/lib/ohai/plugins/ssh_host_key.rb +7 -7
  91. data/lib/ohai/plugins/uptime.rb +2 -7
  92. data/lib/ohai/plugins/virtualbox.rb +1 -1
  93. data/lib/ohai/plugins/vmware.rb +2 -2
  94. data/lib/ohai/plugins/windows/cpu.rb +2 -16
  95. data/lib/ohai/plugins/windows/network.rb +4 -2
  96. data/lib/ohai/plugins/zpools.rb +3 -3
  97. data/lib/ohai/provides_map.rb +1 -1
  98. data/lib/ohai/runner.rb +11 -14
  99. data/lib/ohai/system.rb +8 -71
  100. data/lib/ohai/util/file_helper.rb +2 -2
  101. data/lib/ohai/util/win32/group_helper.rb +0 -2
  102. data/lib/ohai/version.rb +1 -1
  103. data/ohai.gemspec +6 -5
  104. data/spec/functional/plugins/root_group_spec.rb +2 -2
  105. data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
  106. data/spec/unit/dsl/plugin_spec.rb +14 -46
  107. data/spec/unit/loader_spec.rb +8 -70
  108. data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
  109. data/spec/unit/mixin/command_spec.rb +11 -8
  110. data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
  111. data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
  112. data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
  113. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  114. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  115. data/spec/unit/plugins/cloud_spec.rb +0 -12
  116. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  117. data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
  118. data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
  119. data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
  120. data/spec/unit/plugins/dmi_spec.rb +17 -25
  121. data/spec/unit/plugins/docker_spec.rb +100 -0
  122. data/spec/unit/plugins/fail_spec.rb +3 -58
  123. data/spec/unit/plugins/haskell_spec.rb +1 -1
  124. data/spec/unit/plugins/init_package_spec.rb +1 -1
  125. data/spec/unit/plugins/kernel_spec.rb +0 -52
  126. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  127. data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
  128. data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
  129. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  130. data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
  131. data/spec/unit/plugins/linux/network_spec.rb +16 -16
  132. data/spec/unit/plugins/linux/platform_spec.rb +1 -17
  133. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
  134. data/spec/unit/plugins/network_spec.rb +58 -58
  135. data/spec/unit/plugins/openstack_spec.rb +5 -24
  136. data/spec/unit/plugins/rackspace_spec.rb +6 -6
  137. data/spec/unit/plugins/root_group_spec.rb +1 -1
  138. data/spec/unit/plugins/ruby_spec.rb +1 -1
  139. data/spec/unit/plugins/rust_spec.rb +1 -1
  140. data/spec/unit/plugins/scala_spec.rb +1 -1
  141. data/spec/unit/plugins/scaleway_spec.rb +91 -0
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  143. data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
  144. data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
  145. data/spec/unit/plugins/sysconf_spec.rb +1 -0
  146. data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
  147. data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
  148. data/spec/unit/provides_map_spec.rb +4 -4
  149. data/spec/unit/runner_spec.rb +15 -54
  150. data/spec/unit/system_spec.rb +35 -348
  151. data/spec/unit/util/file_helper_spec.rb +2 -0
  152. metadata +28 -28
  153. data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
  154. data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
  155. data/lib/ohai/plugins/ip_scopes.rb +0 -67
  156. data/lib/ohai/plugins/virtualization.rb +0 -83
  157. data/spec/data/plugins/messages.rb +0 -8
  158. data/spec/data/plugins/v6message.rb +0 -2
  159. data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
  160. data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
@@ -114,8 +114,8 @@ Ohai.plugin(:Network) do
114
114
  # Query macaddress
115
115
  e_so = shell_out("entstat -d #{interface} | grep \"Hardware Address\"")
116
116
  iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
117
- e_so.stdout.lines.each do |line|
118
- if line =~ /Hardware Address: (\S+)/
117
+ e_so.stdout.lines.each do |l|
118
+ if l =~ /Hardware Address: (\S+)/
119
119
  iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" }
120
120
  macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
121
121
  end
@@ -140,7 +140,7 @@ Ohai.plugin(:Virtualization) do
140
140
  breadcrumb.each do |node|
141
141
  evalstr << "[\'#{node}\']"
142
142
  end
143
- wpars[wpar_name][breadcrumb[-1]] = eval evalstr
143
+ wpars[wpar_name][breadcrumb[-1]] = eval evalstr # rubocop: disable Security/Eval
144
144
  end
145
145
  end
146
146
  virtualization[:wpars] = wpars unless wpars.empty?
@@ -30,16 +30,16 @@ Ohai.plugin(:Azure) do
30
30
  # project for details
31
31
  azure_metadata_from_hints = hint?("azure")
32
32
  if azure_metadata_from_hints
33
- Ohai::Log.debug("Plugin Azure: Azure hint is present. Parsing any hint data.")
33
+ logger.trace("Plugin Azure: Azure hint is present. Parsing any hint data.")
34
34
  azure Mash.new
35
35
  azure_metadata_from_hints.each { |k, v| azure[k] = v }
36
36
  azure["metadata"] = parse_metadata
37
37
  elsif has_waagent? || has_dhcp_option_245?
38
- Ohai::Log.debug("Plugin Azure: No hints present, but system appears to be on Azure.")
38
+ logger.trace("Plugin Azure: No hints present, but system appears to be on Azure.")
39
39
  azure Mash.new
40
40
  azure["metadata"] = parse_metadata
41
41
  else
42
- Ohai::Log.debug("Plugin Azure: No hints present and doesn't appear to be on Azure.")
42
+ logger.trace("Plugin Azure: No hints present and doesn't appear to be on Azure.")
43
43
  false
44
44
  end
45
45
  end
@@ -48,7 +48,7 @@ Ohai.plugin(:Azure) do
48
48
  # http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/
49
49
  def has_waagent?
50
50
  if File.exist?("/usr/sbin/waagent") || Dir.exist?('C:\WindowsAzure')
51
- Ohai::Log.debug("Plugin Azure: Found waagent used by Azure.")
51
+ logger.trace("Plugin Azure: Found waagent used by Azure.")
52
52
  true
53
53
  end
54
54
  end
@@ -58,7 +58,7 @@ Ohai.plugin(:Azure) do
58
58
  if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
59
59
  File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
60
60
  if line =~ /unknown-245/
61
- Ohai::Log.debug("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
61
+ logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
62
62
  has_245 = true
63
63
  break
64
64
  end
@@ -34,7 +34,7 @@ Ohai.plugin(:Virtualization) do
34
34
  virtualization[:system] = "jail"
35
35
  virtualization[:role] = "guest"
36
36
  virtualization[:systems][:jail] = "guest"
37
- Ohai::Log.debug("Plugin Virtualization: Guest running in FreeBSD jail detected")
37
+ logger.trace("Plugin Virtualization: Guest running in FreeBSD jail detected")
38
38
  end
39
39
 
40
40
  # run jls to get a list of running jails
@@ -45,7 +45,7 @@ Ohai.plugin(:Virtualization) do
45
45
  virtualization[:system] = "jail"
46
46
  virtualization[:role] = "host"
47
47
  virtualization[:systems][:jail] = "host"
48
- Ohai::Log.debug("Plugin Virtualization: Host running FreeBSD jails detected")
48
+ logger.trace("Plugin Virtualization: Host running FreeBSD jails detected")
49
49
  end
50
50
 
51
51
  # detect from modules
@@ -56,12 +56,12 @@ Ohai.plugin(:Virtualization) do
56
56
  virtualization[:system] = "vbox"
57
57
  virtualization[:role] = "host"
58
58
  virtualization[:systems][:vbox] = "host"
59
- Ohai::Log.debug("Plugin Virtualization: Guest running on VirtualBox detected")
59
+ logger.trace("Plugin Virtualization: Guest running on VirtualBox detected")
60
60
  when /vboxguest/
61
61
  virtualization[:system] = "vbox"
62
62
  virtualization[:role] = "guest"
63
63
  virtualization[:systems][:vbox] = "guest"
64
- Ohai::Log.debug("Plugin Virtualization: Host running VirtualBox detected")
64
+ logger.trace("Plugin Virtualization: Host running VirtualBox detected")
65
65
  end
66
66
  end
67
67
 
@@ -70,7 +70,7 @@ Ohai.plugin(:Virtualization) do
70
70
  virtualization[:system] = "bhyve"
71
71
  virtualization[:role] = "host"
72
72
  virtualization[:systems][:bhyve] = "host"
73
- Ohai::Log.debug("Plugin Virtualization: Host running bhyve detected")
73
+ logger.trace("Plugin Virtualization: Host running bhyve detected")
74
74
  end
75
75
 
76
76
  # Detect KVM/QEMU paravirt guests from cpu, report as KVM
@@ -80,7 +80,7 @@ Ohai.plugin(:Virtualization) do
80
80
  virtualization[:system] = "kvm"
81
81
  virtualization[:role] = "guest"
82
82
  virtualization[:systems][:kvm] = "guest"
83
- Ohai::Log.debug("Plugin Virtualization: Guest running on KVM detected")
83
+ logger.trace("Plugin Virtualization: Guest running on KVM detected")
84
84
  end
85
85
 
86
86
  # gather hypervisor of guests from sysctl kern.vm_guest
@@ -92,22 +92,22 @@ Ohai.plugin(:Virtualization) do
92
92
  virtualization[:system] = "vmware"
93
93
  virtualization[:role] = "guest"
94
94
  virtualization[:systems][:vmware] = "guest"
95
- Ohai::Log.debug("Plugin Virtualization: Guest running on VMware detected")
95
+ logger.trace("Plugin Virtualization: Guest running on VMware detected")
96
96
  when /hv/
97
97
  virtualization[:system] = "hyperv"
98
98
  virtualization[:role] = "guest"
99
99
  virtualization[:systems][:hyperv] = "guest"
100
- Ohai::Log.debug("Plugin Virtualization: Guest running on Hyper-V detected")
100
+ logger.trace("Plugin Virtualization: Guest running on Hyper-V detected")
101
101
  when /xen/
102
102
  virtualization[:system] = "xen"
103
103
  virtualization[:role] = "guest"
104
104
  virtualization[:systems][:xen] = "guest"
105
- Ohai::Log.debug("Plugin Virtualization: Guest running on Xen detected")
105
+ logger.trace("Plugin Virtualization: Guest running on Xen detected")
106
106
  when /bhyve/
107
107
  virtualization[:system] = "bhyve"
108
108
  virtualization[:role] = "guest"
109
109
  virtualization[:systems][:bhyve] = "guest"
110
- Ohai::Log.debug("Plugin Virtualization: Guest running on bhyve detected")
110
+ logger.trace("Plugin Virtualization: Guest running on bhyve detected")
111
111
  end
112
112
 
113
113
  # parse dmidecode to discover various virtualization guests
@@ -117,7 +117,7 @@ Ohai.plugin(:Virtualization) do
117
117
  virtualization[:system] = guest
118
118
  virtualization[:role] = "guest"
119
119
  virtualization[:systems][guest.to_sym] = "guest"
120
- Ohai::Log.debug("Plugin Virtualization: Guest running on #{guest} detected")
120
+ logger.trace("Plugin Virtualization: Guest running on #{guest} detected")
121
121
  end
122
122
  end
123
123
  end
@@ -25,24 +25,24 @@ Ohai.plugin(:C) do
25
25
  if so.exitstatus == 0
26
26
  yield(so)
27
27
  else
28
- Ohai::Log.debug("Plugin C: '#{cmd}' failed. Skipping data.")
28
+ logger.trace("Plugin C: '#{cmd}' failed. Skipping data.")
29
29
  end
30
30
  rescue Ohai::Exceptions::Exec
31
- Ohai::Log.debug("Plugin C: '#{cmd}' binary could not be found. Skipping data.")
31
+ logger.trace("Plugin C: '#{cmd}' binary could not be found. Skipping data.")
32
32
  end
33
33
 
34
34
  def xcode_installed?
35
- Ohai::Log.debug("Plugin C: Checking for Xcode Command Line Tools.")
35
+ logger.trace("Plugin C: Checking for Xcode Command Line Tools.")
36
36
  so = shell_out("/usr/bin/xcode-select -p")
37
37
  if so.exitstatus == 0
38
- Ohai::Log.debug("Plugin C: Xcode Command Line Tools found.")
38
+ logger.trace("Plugin C: Xcode Command Line Tools found.")
39
39
  return true
40
40
  else
41
- Ohai::Log.debug("Plugin C: Xcode Command Line Tools not found.")
41
+ logger.trace("Plugin C: Xcode Command Line Tools not found.")
42
42
  return false
43
43
  end
44
44
  rescue Ohai::Exceptions::Exec
45
- Ohai::Log.debug("Plugin C: xcode-select binary could not be found. Skipping data.")
45
+ logger.trace("Plugin C: xcode-select binary could not be found. Skipping data.")
46
46
  end
47
47
 
48
48
  def collect_gcc
@@ -60,7 +60,7 @@ Ohai.plugin(:C) do
60
60
  # COLLECT_GCC=gcc
61
61
  # COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
62
62
  # Target: x86_64-linux-gnu
63
- # Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
63
+ # Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-trace --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
64
64
  # Thread model: posix
65
65
  # gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
66
66
  gcc = Mash.new
@@ -134,7 +134,7 @@ Ohai.plugin(:C) do
134
134
  end
135
135
  end
136
136
  rescue Ohai::Exceptions::Exec
137
- Ohai::Log.debug("Plugin C: 'xlc' binary could not be found. Skipping data.")
137
+ logger.trace("Plugin C: 'xlc' binary could not be found. Skipping data.")
138
138
  end
139
139
 
140
140
  def collect_sunpro
@@ -23,10 +23,11 @@ Ohai.plugin(:Chef) do
23
23
  begin
24
24
  require "chef/version"
25
25
  rescue Gem::LoadError
26
+ logger.trace("Plugin Chef: Unable to load the chef gem to determine the version")
26
27
  # this catches when you've done a major version bump of ohai, but
27
28
  # your chef gem is incompatible, so we can't load it in the same VM
28
29
  # (affects mostly internal testing)
29
- next
30
+ next # avoids us writing an empty mash
30
31
  end
31
32
 
32
33
  chef_packages Mash.new unless chef_packages
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  Ohai.plugin(:Cloud) do
18
- provides "cloud_v2"
19
18
  provides "cloud"
20
19
 
21
20
  depends "ec2"
@@ -332,8 +331,6 @@ Ohai.plugin(:Cloud) do
332
331
  get_digital_ocean_values if on_digital_ocean?
333
332
  get_softlayer_values if on_softlayer?
334
333
 
335
- # set node[:cloud] and node[:cloud_v2] hash here
336
- cloud_v2 @cloud_attr_obj.cloud_mash
337
334
  cloud @cloud_attr_obj.cloud_mash
338
335
  end
339
336
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Nathan L Smith (<nlloyds@gmail.com>)
3
3
  # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@ Ohai.plugin(:CPU) do
22
22
 
23
23
  collect_data(:darwin) do
24
24
  cpu Mash.new
25
- shell_out("sysctl hw machdep").stdout.lines.each do |line|
25
+ shell_out("sysctl -a").stdout.lines.each do |line|
26
26
  case line
27
27
  when /^hw.packages: (.*)$/
28
28
  cpu[:real] = Regexp.last_match[1].to_i
@@ -20,7 +20,6 @@
20
20
 
21
21
  Ohai.plugin(:Filesystem) do
22
22
  provides "filesystem"
23
- provides "filesystem2"
24
23
 
25
24
  def generate_device_view(fs)
26
25
  view = {}
@@ -104,6 +103,5 @@ Ohai.plugin(:Filesystem) do
104
103
  fs_data["by_pair"] = by_pair
105
104
 
106
105
  filesystem fs_data
107
- filesystem2 fs_data
108
106
  end
109
107
  end
@@ -23,18 +23,24 @@ Ohai.plugin(:Hardware) do
23
23
  sp_cmd = "system_profiler #{datatype} -xml"
24
24
  # Hardware queries
25
25
  sp_std = shell_out(sp_cmd)
26
- sp_hash = Plist.parse_xml(sp_std.stdout)
26
+ Plist.parse_xml(sp_std.stdout)
27
27
  end
28
28
 
29
29
  collect_data(:darwin) do
30
30
  unless hardware
31
31
  hardware Mash.new
32
32
  else
33
- Ohai::Log.debug("Plugin Hardware: namespace already exists")
33
+ logger.trace("Plugin Hardware: namespace already exists")
34
34
  next
35
35
  end
36
36
 
37
- require "plist"
37
+ begin
38
+ require "plist"
39
+ rescue LoadError => e
40
+ # In case the plist gem isn't present, skip this plugin.
41
+ logger.trace("Plugin Hardware: Can't load gem: #{e}. Cannot continue.")
42
+ next
43
+ end
38
44
 
39
45
  hw_hash = system_profiler("SPHardwareDataType")
40
46
  hw_hash[0]["_items"][0].delete("_name")
@@ -74,8 +74,8 @@ Ohai.plugin(:Network) do
74
74
  return ifname unless ifaces[ifname].nil?
75
75
  # oh well, time to go hunting!
76
76
  return ifname.chop if ifname =~ /\*$/
77
- ifaces.keys.each do |ifc|
78
- ifaces[ifc][:addresses].keys.each do |addr|
77
+ ifaces.each_key do |ifc|
78
+ ifaces[ifc][:addresses].each_key do |addr|
79
79
  return ifc if addr.eql? mac
80
80
  end
81
81
  end
@@ -20,12 +20,13 @@ Ohai.plugin(:SystemProfile) do
20
20
  provides "system_profile"
21
21
 
22
22
  collect_data(:darwin) do
23
- require "plist"
23
+ begin
24
+ require "plist"
24
25
 
25
- system_profile Array.new
26
- items = Array.new
27
- detail_level = {
28
- "mini" => %w{
26
+ system_profile Array.new
27
+ items = Array.new
28
+ detail_level = {
29
+ "mini" => %w{
29
30
  SPParallelATAData
30
31
  SPAudioData
31
32
  SPBluetoothData
@@ -51,22 +52,21 @@ SPThunderboltData
51
52
  SPUSBData
52
53
  SPWWANData
53
54
  SPAirPortData},
54
- "full" => [
55
- "SPHardwareDataType",
56
- ],
57
- }
55
+ "full" => [
56
+ "SPHardwareDataType",
57
+ ],
58
+ }
58
59
 
59
- detail_level.each do |level, data_types|
60
- so = shell_out("system_profiler -xml -detailLevel #{level} #{data_types.join(' ')}")
61
- Plist.parse_xml(so.stdout).each do |e|
62
- # delete some bogus timing data and then keep the rest
63
- e.delete("_SPCompletionInterval")
64
- e.delete("_SPResponseTime")
65
- e.delete("_SPCommandLineArguments")
66
- items << e
60
+ detail_level.each do |level, data_types|
61
+ so = shell_out("system_profiler -xml -detailLevel #{level} #{data_types.join(' ')}")
62
+ Plist.parse_xml(so.stdout).each do |e|
63
+ items << e
64
+ end
67
65
  end
68
- end
69
66
 
70
- system_profile ( items.sort_by { |h| h["_dataType"] } ) # rubocop: disable Lint/ParenthesesAsGroupedExpression
67
+ system_profile ( items.sort_by { |h| h["_dataType"] } ) # rubocop: disable Lint/ParenthesesAsGroupedExpression
68
+ rescue LoadError => e
69
+ logger.trace("Can't load gem: #{e})")
70
+ end
71
71
  end
72
72
  end
@@ -38,10 +38,20 @@ Ohai.plugin(:Virtualization) do
38
38
  ::File.exist?("/Applications/VMware\ Fusion.app/")
39
39
  end
40
40
 
41
+ def docker_exists?
42
+ which("docker")
43
+ end
44
+
41
45
  collect_data(:darwin) do
42
46
  virtualization Mash.new unless virtualization
43
47
  virtualization[:systems] = Mash.new unless virtualization[:systems]
44
48
 
49
+ if docker_exists?
50
+ virtualization[:system] = "docker"
51
+ virtualization[:role] = "host"
52
+ virtualization[:systems][:docker] = "host"
53
+ end
54
+
45
55
  if vboxmanage_exists?
46
56
  virtualization[:system] = "vbox"
47
57
  virtualization[:role] = "host"
@@ -31,13 +31,13 @@ Ohai.plugin(:DigitalOcean) do
31
31
  begin
32
32
  # detect a vendor of "DigitalOcean"
33
33
  if dmi[:bios][:all_records][0][:Vendor] == "DigitalOcean"
34
- Ohai::Log.debug("Plugin DigitalOcean: has_do_dmi? == true")
34
+ logger.trace("Plugin DigitalOcean: has_do_dmi? == true")
35
35
  return true
36
36
  end
37
37
  rescue NoMethodError
38
38
  # dmi[:bios][:all_records][0][:Vendor] may not exist
39
39
  end
40
- Ohai::Log.debug("Plugin DigitalOcean: has_do_dmi? == false")
40
+ logger.trace("Plugin DigitalOcean: has_do_dmi? == false")
41
41
  false
42
42
  end
43
43
 
@@ -49,14 +49,14 @@ Ohai.plugin(:DigitalOcean) do
49
49
 
50
50
  collect_data do
51
51
  if looks_like_digital_ocean?
52
- Ohai::Log.debug("Plugin Digitalocean: looks_like_digital_ocean? == true")
52
+ logger.trace("Plugin Digitalocean: looks_like_digital_ocean? == true")
53
53
  digital_ocean Mash.new
54
54
  fetch_metadata.each do |k, v|
55
55
  next if k == "vendor_data" # this may have sensitive data we shouldn't store
56
56
  digital_ocean[k] = v
57
57
  end
58
58
  else
59
- Ohai::Log.debug("Plugin Digitalocean: No hints present for and doesn't look like digitalocean")
59
+ logger.trace("Plugin Digitalocean: No hints present for and doesn't look like digitalocean")
60
60
  false
61
61
  end
62
62
  end
@@ -60,22 +60,23 @@ Ohai.plugin(:DMI) do
60
60
  next if blank_line.match(line)
61
61
  line = line.encode(line.encoding, :universal_newline => true)
62
62
 
63
- if dmidecode_version = dmidecode_version_line.match(line)
63
+ if ( dmidecode_version = dmidecode_version_line.match(line) )
64
64
  dmi[:dmidecode_version] = dmidecode_version[1]
65
65
 
66
- elsif smbios_version = smbios_version_line.match(line)
66
+ elsif ( smbios_version = smbios_version_line.match(line) )
67
67
  dmi[:smbios_version] = smbios_version[1]
68
68
 
69
- elsif structures = structures_line.match(line)
69
+ elsif ( structures = structures_line.match(line) )
70
70
  dmi[:structures] = Mash.new
71
71
  dmi[:structures][:count] = structures[1]
72
72
  dmi[:structures][:size] = structures[2]
73
73
 
74
- elsif table_location = table_location_line.match(line)
74
+ elsif ( table_location = table_location_line.match(line) )
75
75
  dmi[:table_location] = table_location[1]
76
76
 
77
77
  elsif ( handle = handle_line.match(line) )
78
- unless Ohai::Common::DMI.whitelisted_ids.include?(handle[2].to_i)
78
+ # Don't overcapture for now (OHAI-260)
79
+ unless Ohai::Common::DMI::ID_TO_CAPTURE.include?(handle[2].to_i)
79
80
  dmi_record = nil
80
81
  next
81
82
  end
@@ -90,28 +91,28 @@ Ohai.plugin(:DMI) do
90
91
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:size] = handle[2]
91
92
  field = nil
92
93
 
93
- elsif type = type_line.match(line)
94
+ elsif ( type = type_line.match(line) )
94
95
  if dmi_record .nil?
95
- Ohai::Log.debug("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
96
+ logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
96
97
  next
97
98
  end
98
99
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = type[1]
99
100
 
100
- elsif data = data_line.match(line)
101
+ elsif ( data = data_line.match(line) )
101
102
  if dmi_record .nil?
102
- Ohai::Log.debug("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
103
+ logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
103
104
  next
104
105
  end
105
106
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = data[2]
106
107
  field = data[1]
107
108
 
108
- elsif extended_data = extended_data_line.match(line)
109
+ elsif ( extended_data = extended_data_line.match(line) )
109
110
  if dmi_record .nil?
110
- Ohai::Log.debug("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
111
+ logger.trace("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
111
112
  next
112
113
  end
113
114
  if field .nil?
114
- Ohai::Log.debug("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
115
+ logger.trace("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
115
116
  next
116
117
  end
117
118
  # overwrite "raw" value with a new Mash
@@ -119,14 +120,14 @@ Ohai.plugin(:DMI) do
119
120
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = nil
120
121
 
121
122
  else
122
- Ohai::Log.debug("Plugin DMI: unrecognized output line; discarding:\n#{line}")
123
+ logger.trace("Plugin DMI: unrecognized output line; discarding:\n#{line}")
123
124
 
124
125
  end
125
126
  end
126
127
 
127
128
  Ohai::Common::DMI.convenience_keys(dmi)
128
129
  rescue Ohai::Exceptions::Exec
129
- Ohai::Log.debug('Plugin DMI: Could not shell_out "dmidecode". Skipping data')
130
+ logger.trace('Plugin DMI: Could not shell_out "dmidecode". Skipping data')
130
131
  end
131
132
  end
132
133
  end