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
@@ -52,7 +52,7 @@ Ohai.plugin(:Rackspace) do
52
52
  require "wmi-lite/wmi"
53
53
  wmi = WmiLite::Wmi.new
54
54
  if wmi.first_of("Win32_ComputerSystem")["PrimaryOwnerName"] == "Rackspace"
55
- Ohai::Log.debug("Plugin Rackspace: has_rackspace_manufacturer? == true")
55
+ logger.trace("Plugin Rackspace: has_rackspace_manufacturer? == true")
56
56
  return true
57
57
  end
58
58
  end
@@ -105,7 +105,7 @@ Ohai.plugin(:Rackspace) do
105
105
  end
106
106
  end
107
107
  rescue Ohai::Exceptions::Exec
108
- Ohai::Log.debug("Plugin Rackspace: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
108
+ logger.trace("Plugin Rackspace: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
109
109
  nil
110
110
  end
111
111
 
@@ -117,7 +117,7 @@ Ohai.plugin(:Rackspace) do
117
117
  rackspace[:instance_id] = so.stdout.gsub(/instance-/, "")
118
118
  end
119
119
  rescue Ohai::Exceptions::Exec
120
- Ohai::Log.debug("Plugin Rackspace: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
120
+ logger.trace("Plugin Rackspace: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
121
121
  nil
122
122
  end
123
123
 
@@ -132,7 +132,7 @@ Ohai.plugin(:Rackspace) do
132
132
  if so.exitstatus == 0
133
133
  networks.push(FFI_Yajl::Parser.new.parse(so.stdout))
134
134
  else
135
- Ohai::Log.debug("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud")
135
+ logger.trace("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud")
136
136
  return false
137
137
  end
138
138
  end
@@ -141,7 +141,7 @@ Ohai.plugin(:Rackspace) do
141
141
  networks.delete_if { |hash| hash["label"] == "public" }
142
142
  end
143
143
  rescue Ohai::Exceptions::Exec
144
- Ohai::Log.debug("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud")
144
+ logger.trace("Plugin Rackspace: Unable to capture custom private networking information for Rackspace cloud")
145
145
  nil
146
146
  end
147
147
 
@@ -18,15 +18,12 @@
18
18
  Ohai.plugin(:RootGroup) do
19
19
  provides "root_group"
20
20
 
21
- require "ohai/util/win32/group_helper" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
21
+ collect_data(:windows) do
22
+ require "ohai/util/win32/group_helper"
23
+ root_group Ohai::Util::Win32::GroupHelper.windows_root_group_name
24
+ end
22
25
 
23
- collect_data do
24
- case ::RbConfig::CONFIG["host_os"]
25
- when /mswin|mingw32|windows/
26
- group = Ohai::Util::Win32::GroupHelper.windows_root_group_name
27
- root_group group
28
- else
29
- root_group Etc.getgrgid(Etc.getpwnam("root").gid).name
30
- end
26
+ collect_data(:default) do
27
+ root_group Etc.getgrgid(Etc.getpwnam("root").gid).name
31
28
  end
32
29
  end
@@ -47,7 +47,7 @@ Ohai.plugin(:Ruby) do
47
47
 
48
48
  # Create a query string from above hash
49
49
  env_string = ""
50
- values.keys.each do |v|
50
+ values.each_key do |v|
51
51
  env_string << "#{v}=\#{#{values[v]}},"
52
52
  end
53
53
 
@@ -67,7 +67,7 @@ Ohai.plugin(:Ruby) do
67
67
  run_ruby("require 'rubygems'; puts ::Gem.default_exec_format % 'gem'"),
68
68
  "gem",
69
69
  ].map { |bin| ::File.join(bin_dir, bin) }
70
- gem_binary = gem_binaries.find { |bin| ::File.exists? bin }
70
+ gem_binary = gem_binaries.find { |bin| ::File.exist? bin }
71
71
  if gem_binary
72
72
  languages[:ruby][:gems_dir] = run_ruby "puts %x{#{ruby_bin} #{gem_binary} env gemdir}.chomp!"
73
73
  languages[:ruby][:gem_bin] = gem_binary
@@ -28,7 +28,7 @@ Ohai.plugin(:Rust) do
28
28
  languages[:rust] = rust if rust[:version]
29
29
  end
30
30
  rescue Ohai::Exceptions::Exec
31
- Ohai::Log.debug('Plugin Rust: Could not shell_out "rustc --version". Skipping plugin')
31
+ logger.trace('Plugin Rust: Could not shell_out "rustc --version". Skipping plugin')
32
32
  end
33
33
  end
34
34
  end
@@ -29,7 +29,7 @@ Ohai.plugin(:Scala) do
29
29
  scala[:version] = so.stderr.match(/.*version (\S*)/)[1]
30
30
  end
31
31
  rescue Ohai::Exceptions::Exec
32
- Ohai::Log.debug('Plugin Scala: Could not shell_out "scala -version". Skipping data')
32
+ logger.trace('Plugin Scala: Could not shell_out "scala -version". Skipping data')
33
33
  end
34
34
 
35
35
  languages[:scala] = scala unless scala.empty?
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Jonathan Amiez (<jonathan.amiez@gmail.com>)
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ Ohai.plugin(:Scaleway) do
18
+ require "ohai/mixin/scaleway_metadata"
19
+ require "ohai/mixin/http_helper"
20
+
21
+ include Ohai::Mixin::ScalewayMetadata
22
+ include Ohai::Mixin::HttpHelper
23
+
24
+ provides "scaleway"
25
+
26
+ # looks for `scaleway` keyword in kernel command line
27
+ # @return [Boolean] do we have the keyword or not?
28
+ def has_scaleway_cmdline?
29
+ if ::File.read("/proc/cmdline") =~ /scaleway/
30
+ logger.trace("Plugin Scaleway: has_scaleway_cmdline? == true")
31
+ return true
32
+ end
33
+ logger.trace("Plugin Scaleway: has_scaleway_cmdline? == false")
34
+ false
35
+ end
36
+
37
+ # a single check that combines all the various detection methods for Scaleway
38
+ # @return [Boolean] Does the system appear to be on Scaleway
39
+ def looks_like_scaleway?
40
+ return true if hint?("scaleway")
41
+ return true if has_scaleway_cmdline? && can_socket_connect?(Ohai::Mixin::ScalewayMetadata::SCALEWAY_METADATA_ADDR, 80)
42
+ false
43
+ end
44
+
45
+ collect_data do
46
+ if looks_like_scaleway?
47
+ logger.trace("Plugin Scaleway: looks_like_scaleway? == true")
48
+ scaleway Mash.new
49
+ fetch_metadata.each do |k, v|
50
+ scaleway[k] = v
51
+ end
52
+ else
53
+ logger.trace("Plugin Scaleway: No hints present for and doesn't look like scaleway")
54
+ end
55
+ end
56
+ end
@@ -20,6 +20,7 @@ Ohai.plugin(:ShardSeed) do
20
20
  require "digest/md5"
21
21
  depends "hostname", "dmi", "machine_id", "machinename"
22
22
  provides "shard_seed"
23
+ optional true
23
24
 
24
25
  def get_dmi_property(dmi, thing)
25
26
  %w{system base_board chassis}.each do |section|
@@ -36,12 +36,12 @@ Ohai.plugin(:Softlayer) do
36
36
  collect_data do
37
37
  # Adds softlayer Mash
38
38
  if looks_like_softlayer?
39
- Ohai::Log.debug("Plugin Softlayer: looks_like_softlayer? == true")
39
+ logger.trace("Plugin Softlayer: looks_like_softlayer? == true")
40
40
  metadata = fetch_metadata
41
41
  softlayer Mash.new
42
42
  metadata.each { |k, v| softlayer[k] = v } if metadata
43
43
  else
44
- Ohai::Log.debug("Plugin Softlayer: looks_like_softlayer? == false")
44
+ logger.trace("Plugin Softlayer: looks_like_softlayer? == false")
45
45
  end
46
46
  end
47
47
  end
@@ -31,7 +31,7 @@ Ohai.plugin(:CPU) do
31
31
  cpucores = Array.new
32
32
  cpusockets = Array.new
33
33
  processor_info.each_with_index do |processor, i|
34
- desc, instance, record, keyvalue = processor.split(":")
34
+ _desc, instance, _record, keyvalue = processor.split(":")
35
35
  cpu[instance] ||= Mash.new
36
36
  if currentcpu != instance
37
37
  cpu["total"] += 1
@@ -25,7 +25,7 @@ Ohai.plugin(:DMI) do
25
25
  # if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios
26
26
  # note that a single key just means dmidecode exited with its version
27
27
  if (dmi.class.to_s == "Mash") && (dmi.keys.length > 1)
28
- Ohai::Log.debug("Plugin DMI: skipping smbios output, since DMI information has already been provided")
28
+ logger.trace("Plugin DMI: skipping smbios output, since DMI information has already been provided")
29
29
  return
30
30
  end
31
31
 
@@ -118,10 +118,10 @@ Ohai.plugin(:DMI) do
118
118
  # remove/replace any characters that don't fall inside permissible ASCII range, or whitespace
119
119
  line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, ".")
120
120
  if line != raw_line
121
- Ohai::Log.debug("Plugin DMI: converted characters from line:\n#{raw_line}")
121
+ logger.trace("Plugin DMI: converted characters from line:\n#{raw_line}")
122
122
  end
123
123
 
124
- if header_information = header_information_line.match(line)
124
+ if ( header_information = header_information_line.match(line) )
125
125
  dmi_record = {}
126
126
 
127
127
  # look up SMB ID
@@ -129,7 +129,7 @@ Ohai.plugin(:DMI) do
129
129
  id = smb_to_id[header_information[3]]
130
130
 
131
131
  # Don't overcapture for now (OHAI-260)
132
- unless Ohai::Common::DMI.whitelisted_ids.include?(id)
132
+ unless Ohai::Common::DMI::ID_TO_CAPTURE.include?(id)
133
133
  dmi_record = nil
134
134
  next
135
135
  end
@@ -137,7 +137,7 @@ Ohai.plugin(:DMI) do
137
137
  dmi_record[:type] = Ohai::Common::DMI.id_lookup(id)
138
138
 
139
139
  else
140
- Ohai::Log.debug("Plugin DMI: unrecognized header type; skipping")
140
+ logger.trace("Plugin DMI: unrecognized header type; skipping")
141
141
  dmi_record = nil
142
142
  next
143
143
  end
@@ -151,29 +151,29 @@ Ohai.plugin(:DMI) do
151
151
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = header_information[4]
152
152
  field = nil
153
153
 
154
- elsif data = data_key_value_line.match(line)
154
+ elsif ( data = data_key_value_line.match(line) )
155
155
  if dmi_record.nil?
156
- Ohai::Log.debug("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
156
+ logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
157
157
  next
158
158
  end
159
159
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = data[2]
160
160
  field = data[1]
161
161
 
162
- elsif data = data_key_only_line.match(line)
162
+ elsif ( data = data_key_only_line.match(line) )
163
163
  if dmi_record.nil?
164
- Ohai::Log.debug("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
164
+ logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
165
165
  next
166
166
  end
167
167
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = ""
168
168
  field = data[1]
169
169
 
170
- elsif extended_data = extended_data_line.match(line)
170
+ elsif ( extended_data = extended_data_line.match(line) )
171
171
  if dmi_record.nil?
172
- Ohai::Log.debug("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
172
+ logger.trace("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
173
173
  next
174
174
  end
175
175
  if field.nil?
176
- Ohai::Log.debug("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
176
+ logger.trace("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
177
177
  next
178
178
  end
179
179
  # overwrite "raw" value with a new Mash
@@ -181,7 +181,7 @@ Ohai.plugin(:DMI) do
181
181
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = extended_data[2]
182
182
 
183
183
  else
184
- Ohai::Log.debug("Plugin DMI: unrecognized output line; discarding:\n#{line}")
184
+ logger.trace("Plugin DMI: unrecognized output line; discarding:\n#{line}")
185
185
 
186
186
  end
187
187
  end
@@ -74,7 +74,7 @@ Ohai.plugin(:Network) do
74
74
  end
75
75
 
76
76
  def arpname_to_ifname(iface, arpname)
77
- iface.keys.each do |ifn|
77
+ iface.each_key do |ifn|
78
78
  return ifn if ifn.split(":")[0].eql?(arpname)
79
79
  end
80
80
 
@@ -146,17 +146,17 @@ Ohai.plugin(:Network) do
146
146
  end
147
147
  end
148
148
 
149
- iface.keys.each do |ifn|
149
+ iface.each_key do |ifn|
150
150
  iaddr = nil
151
151
  if iface[ifn][:encapsulation].eql?("Ethernet")
152
- iface[ifn][:addresses].keys.each do |addr|
152
+ iface[ifn][:addresses].each_key do |addr|
153
153
  if iface[ifn][:addresses][addr]["family"].eql?("inet")
154
154
  iaddr = addr
155
155
  break
156
156
  end
157
157
  end
158
158
  if iface[ifn][:arp]
159
- iface[ifn][:arp].keys.each do |addr|
159
+ iface[ifn][:arp].each_key do |addr|
160
160
  if addr.eql?(iaddr)
161
161
  iface[ifn][:addresses][iface[ifn][:arp][iaddr]] = { "family" => "lladdr" }
162
162
  break
@@ -181,11 +181,11 @@ Ohai.plugin(:Network) do
181
181
  else
182
182
  matches[:name]
183
183
  end
184
- Ohai::Log.debug("Plugin Network: found interface device: #{network[:default_interface]} #{matches[:name]}")
184
+ logger.trace("Plugin Network: found interface device: #{network[:default_interface]} #{matches[:name]}")
185
185
  end
186
186
  matches = /gateway: (\S+)/.match(line)
187
187
  if matches
188
- Ohai::Log.debug("Plugin Network: found gateway: #{matches[1]}")
188
+ logger.trace("Plugin Network: found gateway: #{matches[1]}")
189
189
  network[:default_gateway] = matches[1]
190
190
  end
191
191
  end
@@ -20,7 +20,7 @@ Ohai.plugin(:Platform) do
20
20
  provides "platform", "platform_version", "platform_build", "platform_family"
21
21
 
22
22
  collect_data(:solaris2) do
23
- if File.exists?("/sbin/uname")
23
+ if File.exist?("/sbin/uname")
24
24
  uname_exec = "/sbin/uname"
25
25
  else
26
26
  uname_exec = "uname"
@@ -37,7 +37,7 @@ Ohai.plugin(:Platform) do
37
37
  end
38
38
 
39
39
  File.open("/etc/release") do |file|
40
- while line = file.gets
40
+ while ( line = file.gets )
41
41
  case line
42
42
  when /^.*(SmartOS).*$/
43
43
  platform "smartos"
@@ -38,13 +38,13 @@ Ohai.plugin(:SSHHostKey) do
38
38
  collect_data do
39
39
  keys[:ssh] = Mash.new
40
40
 
41
- sshd_config = if File.exists?("/etc/ssh/sshd_config")
41
+ sshd_config = if File.exist?("/etc/ssh/sshd_config")
42
42
  "/etc/ssh/sshd_config"
43
- elsif File.exists?("/etc/sshd_config")
43
+ elsif File.exist?("/etc/sshd_config")
44
44
  # Darwin
45
45
  "/etc/sshd_config"
46
46
  else
47
- Ohai::Log.debug("Plugin SSHHostKey: Failed to find sshd configuration file")
47
+ logger.trace("Plugin SSHHostKey: Failed to find sshd configuration file")
48
48
  nil
49
49
  end
50
50
 
@@ -62,21 +62,21 @@ Ohai.plugin(:SSHHostKey) do
62
62
  end
63
63
  end
64
64
 
65
- if keys[:ssh][:host_dsa_public].nil? && File.exists?("/etc/ssh/ssh_host_dsa_key.pub")
65
+ if keys[:ssh][:host_dsa_public].nil? && File.exist?("/etc/ssh/ssh_host_dsa_key.pub")
66
66
  keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
67
67
  end
68
68
 
69
- if keys[:ssh][:host_rsa_public].nil? && File.exists?("/etc/ssh/ssh_host_rsa_key.pub")
69
+ if keys[:ssh][:host_rsa_public].nil? && File.exist?("/etc/ssh/ssh_host_rsa_key.pub")
70
70
  keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
71
71
  end
72
72
 
73
- if keys[:ssh][:host_ecdsa_public].nil? && File.exists?("/etc/ssh/ssh_host_ecdsa_key.pub")
73
+ if keys[:ssh][:host_ecdsa_public].nil? && File.exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
74
74
  content = IO.read("/etc/ssh/ssh_host_ecdsa_key.pub")
75
75
  keys[:ssh][:host_ecdsa_public] = content.split[1]
76
76
  keys[:ssh][:host_ecdsa_type] = content.split[0]
77
77
  end
78
78
 
79
- if keys[:ssh][:host_ed25519_public].nil? && File.exists?("/etc/ssh/ssh_host_ed25519_key.pub")
79
+ if keys[:ssh][:host_ed25519_public].nil? && File.exist?("/etc/ssh/ssh_host_ed25519_key.pub")
80
80
  keys[:ssh][:host_ed25519_public] = IO.read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
81
81
  end
82
82
  end
@@ -28,7 +28,6 @@ Ohai.plugin(:Uptime) do
28
28
  require "ohai/mixin/seconds_to_human"
29
29
  provides "uptime", "uptime_seconds"
30
30
  provides "idletime", "idletime_seconds" # linux only
31
- depends "platform_version"
32
31
 
33
32
  def collect_uptime(path)
34
33
  # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
@@ -87,12 +86,8 @@ Ohai.plugin(:Uptime) do
87
86
  collect_data(:windows) do
88
87
  require "wmi-lite/wmi"
89
88
  wmi = WmiLite::Wmi.new
90
- if platform_version.to_f >= 6.0 ## for newer version of Windows starting from Windows Server 2008 ##
91
- last_boot_up_time = wmi.first_of("Win32_OperatingSystem")["lastbootuptime"]
92
- uptime_seconds Time.new.to_i - Time.parse(last_boot_up_time).to_i
93
- else ## for older version of Windows starting from Windows Server 2003 ##
94
- uptime_seconds wmi.first_of("Win32_PerfFormattedData_PerfOS_System")["systemuptime"].to_i
95
- end
89
+ last_boot_up_time = wmi.first_of("Win32_OperatingSystem")["lastbootuptime"]
90
+ uptime_seconds Time.new.to_i - Time.parse(last_boot_up_time).to_i
96
91
  uptime seconds_to_human(uptime_seconds)
97
92
  end
98
93
 
@@ -43,7 +43,7 @@ Ohai.plugin(:Virtualbox) do
43
43
  end
44
44
  end
45
45
  rescue Ohai::Exceptions::Exec
46
- Ohai::Log.debug('Plugin Virtualbox: Could not execute "VBoxControl guestproperty enumerate". Skipping data')
46
+ logger.trace('Plugin Virtualbox: Could not execute "VBoxControl guestproperty enumerate". Skipping data')
47
47
  end
48
48
  end
49
49
  end
@@ -42,7 +42,7 @@ Ohai.plugin(:VMware) do
42
42
 
43
43
  def get_vm_attributes(vmtools_path)
44
44
  if !File.exist?(vmtools_path)
45
- Ohai::Log.debug("Plugin VMware: #{vmtools_path} not found")
45
+ logger.trace("Plugin VMware: #{vmtools_path} not found")
46
46
  else
47
47
  vmware Mash.new
48
48
  begin
@@ -62,7 +62,7 @@ Ohai.plugin(:VMware) do
62
62
  vmware[param] = from_cmd("#{vmtools_path} #{param} status")
63
63
  end
64
64
  rescue
65
- Ohai::Log.debug("Plugin VMware: Error while collecting VMware guest attributes")
65
+ logger.trace("Plugin VMware: Error while collecting VMware guest attributes")
66
66
  end
67
67
  end
68
68
  end
@@ -32,23 +32,9 @@ Ohai.plugin(:CPU) do
32
32
  processors.each_with_index do |processor, index|
33
33
  current_cpu = index.to_s
34
34
  cpu[current_cpu] = Mash.new
35
- #
36
- # On Windows Server 2003 R2 (i.e. 5.2.*), numberofcores property
37
- # doesn't exist on the Win32_Processor class unless the user has
38
- # patched their system with:
39
- # http://support.microsoft.com/kb/932370
40
- #
41
- # We're returning nil for cpu["cores"]
42
- # when we don't see numberofcores property
43
- #
44
35
 
45
- begin
46
- cpu[current_cpu]["cores"] = processor["numberofcores"]
47
- cores += processor["numberofcores"]
48
- rescue NoMethodError => e
49
- Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370")
50
- cpu[current_cpu]["cores"] = nil
51
- end
36
+ cpu[current_cpu]["cores"] = processor["numberofcores"]
37
+ cores += processor["numberofcores"]
52
38
 
53
39
  logical_processors += processor["numberoflogicalprocessors"]
54
40
  cpu[current_cpu]["vendor_id"] = processor["manufacturer"]