ohai 16.2.1 → 16.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/bin/ohai +0 -2
  4. data/lib/ohai/application.rb +2 -2
  5. data/lib/ohai/dsl/plugin.rb +1 -1
  6. data/lib/ohai/loader.rb +1 -2
  7. data/lib/ohai/log.rb +1 -1
  8. data/lib/ohai/mixin/command.rb +1 -1
  9. data/lib/ohai/mixin/dmi_decode.rb +2 -2
  10. data/lib/ohai/mixin/os.rb +1 -1
  11. data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
  12. data/lib/ohai/plugins/aix/memory.rb +3 -3
  13. data/lib/ohai/plugins/aix/network.rb +2 -1
  14. data/lib/ohai/plugins/aix/uptime.rb +2 -2
  15. data/lib/ohai/plugins/aix/virtualization.rb +5 -5
  16. data/lib/ohai/plugins/azure.rb +1 -1
  17. data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
  18. data/lib/ohai/plugins/c.rb +2 -2
  19. data/lib/ohai/plugins/cloud.rb +1 -1
  20. data/lib/ohai/plugins/cpu.rb +2 -2
  21. data/lib/ohai/plugins/darwin/network.rb +3 -3
  22. data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
  23. data/lib/ohai/plugins/docker.rb +2 -2
  24. data/lib/ohai/plugins/dragonflybsd/platform.rb +2 -4
  25. data/lib/ohai/plugins/ec2.rb +8 -7
  26. data/lib/ohai/plugins/eucalyptus.rb +1 -1
  27. data/lib/ohai/plugins/filesystem.rb +11 -17
  28. data/lib/ohai/plugins/fips.rb +1 -5
  29. data/lib/ohai/plugins/freebsd/platform.rb +2 -4
  30. data/lib/ohai/plugins/gce.rb +3 -3
  31. data/lib/ohai/plugins/hostname.rb +16 -16
  32. data/lib/ohai/plugins/kernel.rb +1 -1
  33. data/lib/ohai/plugins/linux/hostnamectl.rb +1 -2
  34. data/lib/ohai/plugins/linux/interrupts.rb +1 -1
  35. data/lib/ohai/plugins/linux/lsb.rb +1 -2
  36. data/lib/ohai/plugins/linux/lspci.rb +1 -2
  37. data/lib/ohai/plugins/linux/machineid.rb +2 -2
  38. data/lib/ohai/plugins/linux/mdadm.rb +1 -1
  39. data/lib/ohai/plugins/linux/network.rb +19 -9
  40. data/lib/ohai/plugins/linux/platform.rb +22 -25
  41. data/lib/ohai/plugins/linux/virtualization.rb +12 -9
  42. data/lib/ohai/plugins/netbsd/network.rb +4 -8
  43. data/lib/ohai/plugins/netbsd/platform.rb +2 -4
  44. data/lib/ohai/plugins/network.rb +5 -4
  45. data/lib/ohai/plugins/openbsd/network.rb +4 -8
  46. data/lib/ohai/plugins/openbsd/platform.rb +2 -4
  47. data/lib/ohai/plugins/openstack.rb +3 -2
  48. data/lib/ohai/plugins/packages.rb +1 -1
  49. data/lib/ohai/plugins/passwd.rb +2 -1
  50. data/lib/ohai/plugins/rackspace.rb +5 -4
  51. data/lib/ohai/plugins/root_group.rb +1 -1
  52. data/lib/ohai/plugins/ruby.rb +4 -15
  53. data/lib/ohai/plugins/scaleway.rb +1 -1
  54. data/lib/ohai/plugins/shard.rb +1 -1
  55. data/lib/ohai/plugins/solaris2/dmi.rb +2 -3
  56. data/lib/ohai/plugins/solaris2/memory.rb +1 -2
  57. data/lib/ohai/plugins/solaris2/network.rb +2 -6
  58. data/lib/ohai/plugins/solaris2/platform.rb +1 -2
  59. data/lib/ohai/plugins/solaris2/virtualization.rb +3 -6
  60. data/lib/ohai/plugins/ssh_host_key.rb +1 -1
  61. data/lib/ohai/plugins/uptime.rb +1 -1
  62. data/lib/ohai/plugins/vmware.rb +2 -2
  63. data/lib/ohai/plugins/windows/dmi.rb +2 -2
  64. data/lib/ohai/plugins/windows/drivers.rb +1 -1
  65. data/lib/ohai/plugins/windows/memory.rb +1 -1
  66. data/lib/ohai/plugins/windows/network.rb +4 -4
  67. data/lib/ohai/plugins/windows/platform.rb +1 -1
  68. data/lib/ohai/plugins/windows/virtualization.rb +1 -1
  69. data/lib/ohai/provides_map.rb +2 -2
  70. data/lib/ohai/runner.rb +1 -1
  71. data/lib/ohai/util/ip_helper.rb +2 -2
  72. data/lib/ohai/util/win32.rb +1 -1
  73. data/lib/ohai/version.rb +1 -1
  74. data/ohai.gemspec +0 -1
  75. metadata +2 -16
@@ -26,8 +26,7 @@ Ohai.plugin(:Network) do
26
26
  counters Mash.new unless counters
27
27
  counters[:network] ||= Mash.new
28
28
 
29
- so = shell_out("route -n get default")
30
- so.stdout.lines do |line|
29
+ shell_out("route -n get default").stdout.lines do |line|
31
30
  if line =~ /(\w+): ([\w\.]+)/
32
31
  case $1
33
32
  when "gateway"
@@ -39,9 +38,8 @@ Ohai.plugin(:Network) do
39
38
  end
40
39
 
41
40
  iface = Mash.new
42
- so = shell_out("#{Ohai.abs_path( "/sbin/ifconfig" )} -a")
43
41
  cint = nil
44
- so.stdout.lines do |line|
42
+ shell_out("#{Ohai.abs_path( "/sbin/ifconfig" )} -a").stdout.lines do |line|
45
43
  if line =~ /^([0-9a-zA-Z\.]+):\s+/
46
44
  cint = $1
47
45
  iface[cint] = Mash.new
@@ -85,8 +83,7 @@ Ohai.plugin(:Network) do
85
83
  end
86
84
  end
87
85
 
88
- so = shell_out("arp -an")
89
- so.stdout.lines do |line|
86
+ shell_out("arp -an").stdout.lines do |line|
90
87
  if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
91
88
  next unless iface[$3] # this should never happen
92
89
 
@@ -102,8 +99,7 @@ Ohai.plugin(:Network) do
102
99
  # Show the state of all network interfaces or a single interface
103
100
  # which have been auto-configured (interfaces statically configured
104
101
  # into a system, but not located at boot time are not shown).
105
- so = shell_out("netstat -idn")
106
- so.stdout.lines do |line|
102
+ shell_out("netstat -idn").stdout.lines do |line|
107
103
  # Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
108
104
  # em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
109
105
  # $1 $2 $3 $4 $5 $6 $7 $8
@@ -20,10 +20,8 @@ Ohai.plugin(:Platform) do
20
20
  provides "platform", "platform_version", "platform_family"
21
21
 
22
22
  collect_data(:netbsd) do
23
- so = shell_out("uname -s")
24
- platform so.stdout.split($/)[0].downcase
25
- so = shell_out("uname -r")
26
- platform_version so.stdout.split($/)[0]
23
+ platform shell_out("uname -s").stdout.split($/)[0].downcase
24
+ platform_version shell_out("uname -r").stdout.split($/)[0]
27
25
  platform_family "netbsd"
28
26
  end
29
27
  end
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  Ohai.plugin(:NetworkAddresses) do
20
- require "ipaddress"
21
20
  require_relative "../mixin/network_helper"
22
21
  include Ohai::Mixin::NetworkHelper
23
22
 
@@ -54,7 +53,7 @@ Ohai.plugin(:NetworkAddresses) do
54
53
  ipaddresses.sort_by do |v|
55
54
  [ ( scope_prio.index(v[:scope]) || 999999 ),
56
55
  128 - v[:ipaddress].prefix.to_i,
57
- ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 ),
56
+ v[:ipaddress].to_i,
58
57
  ]
59
58
  end
60
59
  end
@@ -88,9 +87,9 @@ Ohai.plugin(:NetworkAddresses) do
88
87
  r = gw_if_ips.first
89
88
  else
90
89
  # checking network masks
91
- r = gw_if_ips.select do |v|
90
+ r = gw_if_ips.find do |v|
92
91
  network_contains_address(network[gw_attr], v[:ipaddress], v[:iface])
93
- end.first
92
+ end
94
93
  if r.nil?
95
94
  r = gw_if_ips.first
96
95
  logger.trace("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
@@ -134,6 +133,8 @@ Ohai.plugin(:NetworkAddresses) do
134
133
  # time as ipaddress. if ipaddress is set and macaddress is nil, that means
135
134
  # the interface ipaddress is bound to has the NOARP flag
136
135
  collect_data do
136
+ require "ipaddress" unless defined?(IPAddress)
137
+
137
138
  results = {}
138
139
 
139
140
  network Mash.new unless network
@@ -26,8 +26,7 @@ Ohai.plugin(:Network) do
26
26
  counters Mash.new unless counters
27
27
  counters[:network] ||= Mash.new
28
28
 
29
- so = shell_out("route -n get default")
30
- so.stdout.lines do |line|
29
+ shell_out("route -n get default").stdout.lines do |line|
31
30
  if line =~ /(\w+): ([\w\.]+)/
32
31
  case $1
33
32
  when "gateway"
@@ -39,9 +38,8 @@ Ohai.plugin(:Network) do
39
38
  end
40
39
 
41
40
  iface = Mash.new
42
- so = shell_out( "#{Ohai.abs_path( "/sbin/ifconfig" )} -a" )
43
41
  cint = nil
44
- so.stdout.lines do |line|
42
+ shell_out( "#{Ohai.abs_path( "/sbin/ifconfig" )} -a" ).stdout.lines do |line|
45
43
  if line =~ /^([0-9a-zA-Z\.]+):\s+/
46
44
  cint = $1
47
45
  iface[cint] = Mash.new
@@ -85,8 +83,7 @@ Ohai.plugin(:Network) do
85
83
  end
86
84
  end
87
85
 
88
- so = shell_out("arp -an")
89
- so.stdout.lines do |line|
86
+ shell_out("arp -an").stdout.lines do |line|
90
87
  if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
91
88
  next unless iface[$3] # this should never happen
92
89
 
@@ -102,8 +99,7 @@ Ohai.plugin(:Network) do
102
99
  # Show the state of all network interfaces or a single interface
103
100
  # which have been auto-configured (interfaces statically configured
104
101
  # into a system, but not located at boot time are not shown).
105
- so = shell_out("netstat -idn")
106
- so.stdout.lines do |line|
102
+ shell_out("netstat -idn").stdout.lines do |line|
107
103
  # Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
108
104
  # em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
109
105
  # $1 $2 $3 $4 $5 $6 $7 $8
@@ -20,10 +20,8 @@ Ohai.plugin(:Platform) do
20
20
  provides "platform", "platform_version", "platform_family"
21
21
 
22
22
  collect_data(:openbsd) do
23
- so = shell_out("uname -s")
24
- platform so.stdout.split($/)[0].downcase
25
- so = shell_out("uname -r")
26
- platform_version so.stdout.split($/)[0]
23
+ platform shell_out("uname -s").stdout.split($/)[0].downcase
24
+ platform_version shell_out("uname -r").stdout.split($/)[0]
27
25
  platform_family "openbsd"
28
26
  end
29
27
  end
@@ -19,7 +19,6 @@
19
19
  Ohai.plugin(:Openstack) do
20
20
  require_relative "../mixin/ec2_metadata"
21
21
  require_relative "../mixin/http_helper"
22
- require "etc" unless defined?(Etc)
23
22
  include Ohai::Mixin::Ec2Metadata
24
23
  include Ohai::Mixin::HttpHelper
25
24
 
@@ -49,7 +48,7 @@ Ohai.plugin(:Openstack) do
49
48
  # https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
50
49
  def openstack_provider
51
50
  # dream host doesn't support windows so bail early if we're on windows
52
- return "openstack" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
51
+ return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
53
52
 
54
53
  if Etc::Passwd.entries.map(&:name).include?("dhc-user")
55
54
  "dreamhost"
@@ -59,6 +58,8 @@ Ohai.plugin(:Openstack) do
59
58
  end
60
59
 
61
60
  collect_data do
61
+ require "etc" unless defined?(Etc)
62
+
62
63
  # fetch data if we look like openstack
63
64
  if openstack_hint? || openstack_virtualization?
64
65
  openstack Mash.new
@@ -79,7 +79,7 @@ Ohai.plugin(:Packages) do
79
79
  end
80
80
 
81
81
  when "arch"
82
- require "date"
82
+ require "date" unless defined?(DateTime)
83
83
 
84
84
  # Set LANG=C to force an easy to parse date format
85
85
  so = shell_out("LANG=C pacman -Qi")
@@ -1,6 +1,5 @@
1
1
 
2
2
  Ohai.plugin(:Passwd) do
3
- require "etc" unless defined?(Etc)
4
3
  provides "etc", "current_user"
5
4
  optional true
6
5
 
@@ -14,6 +13,8 @@ Ohai.plugin(:Passwd) do
14
13
  end
15
14
 
16
15
  collect_data do
16
+ require "etc" unless defined?(Etc)
17
+
17
18
  unless etc
18
19
  etc Mash.new
19
20
 
@@ -15,7 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  Ohai.plugin(:Rackspace) do
18
- require "resolv"
19
18
  provides "rackspace"
20
19
 
21
20
  depends "kernel", "network/interfaces"
@@ -48,9 +47,9 @@ Ohai.plugin(:Rackspace) do
48
47
  # true:: If the rackspace cloud can be identified
49
48
  # false:: Otherwise
50
49
  def has_rackspace_manufacturer?
51
- return false unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
50
+ return false unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
52
51
 
53
- require "wmi-lite/wmi"
52
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
54
53
  wmi = WmiLite::Wmi.new
55
54
  if wmi.first_of("Win32_ComputerSystem")["PrimaryOwnerName"] == "Rackspace"
56
55
  logger.trace("Plugin Rackspace: has_rackspace_manufacturer? == true")
@@ -102,7 +101,7 @@ Ohai.plugin(:Rackspace) do
102
101
  so = shell_out("xenstore-ls vm-data/provider_data")
103
102
  if so.exitstatus == 0
104
103
  so.stdout.split("\n").each do |line|
105
- rackspace[:region] = line.split[2].delete('\"') if line =~ /^region/
104
+ rackspace[:region] = line.split[2].delete('\"') if /^region/.match?(line)
106
105
  end
107
106
  end
108
107
  rescue Ohai::Exceptions::Exec
@@ -147,6 +146,8 @@ Ohai.plugin(:Rackspace) do
147
146
  end
148
147
 
149
148
  collect_data do
149
+ require "resolv"
150
+
150
151
  # Adds rackspace Mash
151
152
  if looks_like_rackspace?
152
153
  rackspace Mash.new
@@ -19,7 +19,7 @@ Ohai.plugin(:RootGroup) do
19
19
  provides "root_group"
20
20
 
21
21
  collect_data(:windows) do
22
- require "wmi-lite/wmi"
22
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
23
23
 
24
24
  wmi = WmiLite::Wmi.new
25
25
  # Per http://support.microsoft.com/kb/243330 SID: S-1-5-32-544 is the
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,6 +43,8 @@ Ohai.plugin(:Ruby) do
43
43
  host_vendor: "RbConfig::CONFIG['host_vendor']",
44
44
  bin_dir: "RbConfig::CONFIG['bindir']",
45
45
  ruby_bin: "::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])",
46
+ gem_bin: "::File.join(RbConfig::CONFIG['bindir'], ::Gem.default_exec_format % 'gem')",
47
+ gems_dir: "::Gem.dir",
46
48
  }
47
49
 
48
50
  # Create a query string from above hash
@@ -52,25 +54,12 @@ Ohai.plugin(:Ruby) do
52
54
  end
53
55
 
54
56
  # Query the system ruby
55
- result = run_ruby "puts %Q(#{env_string})"
57
+ result = run_ruby "require 'rubygems'; puts %Q(#{env_string})"
56
58
 
57
59
  # Parse results to plugin hash
58
60
  result.split(",").each do |entry|
59
61
  key, value = entry.split("=")
60
62
  languages[:ruby][key.to_sym] = value || ""
61
63
  end
62
-
63
- # Perform one more (conditional) query
64
- bin_dir = languages[:ruby][:bin_dir]
65
- ruby_bin = languages[:ruby][:ruby_bin]
66
- gem_binaries = [
67
- run_ruby("require 'rubygems'; puts ::Gem.default_exec_format % 'gem'"),
68
- "gem",
69
- ].map { |bin| ::File.join(bin_dir, bin) }
70
- gem_binary = gem_binaries.find { |bin| ::File.exist? bin }
71
- if gem_binary
72
- languages[:ruby][:gems_dir] = run_ruby "puts %x{#{ruby_bin} #{gem_binary} env gemdir}.chomp!"
73
- languages[:ruby][:gem_bin] = gem_binary
74
- end
75
64
  end
76
65
  end
@@ -26,7 +26,7 @@ Ohai.plugin(:Scaleway) do
26
26
  # looks for `scaleway` keyword in kernel command line
27
27
  # @return [Boolean] do we have the keyword or not?
28
28
  def has_scaleway_cmdline?
29
- if ::File.read("/proc/cmdline") =~ /scaleway/
29
+ if ::File.exist?("/proc/cmdline") && /scaleway/.match?(::File.read("/proc/cmdline"))
30
30
  logger.trace("Plugin Scaleway: has_scaleway_cmdline? == true")
31
31
  return true
32
32
  end
@@ -94,7 +94,7 @@ Ohai.plugin(:ShardSeed) do
94
94
  end
95
95
 
96
96
  collect_data(:windows) do
97
- require "wmi-lite/wmi"
97
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
98
98
  wmi = WmiLite::Wmi.new
99
99
 
100
100
  create_seed do |src|
@@ -86,7 +86,7 @@ Ohai.plugin(:DMI) do
86
86
  "SUN_OEM_EXT_MEMARRAY" => 144, # phys memory array extended info
87
87
  "SUN_OEM_EXT_MEMDEVICE" => 145, # memory device extended info
88
88
  "SMB_TYPE_OEM_HI" => 256, # end of OEM-specific type range
89
- }
89
+ }.freeze
90
90
 
91
91
  # all output lines should fall within one of these patterns
92
92
  header_type_line = /^ID\s+SIZE\s+TYPE/
@@ -99,7 +99,6 @@ Ohai.plugin(:DMI) do
99
99
  dmi_record = nil
100
100
  field = nil
101
101
 
102
- so = shell_out("smbios")
103
102
  # ==== EXAMPLE: ====
104
103
  # ID SIZE TYPE
105
104
  # 0 40 SMB_TYPE_BIOS (BIOS information)
@@ -111,7 +110,7 @@ Ohai.plugin(:DMI) do
111
110
  # SMB_BIOSFL_PCI (PCI is supported)
112
111
  # ... similar lines trimmed
113
112
  # note the second level of indentation is via a *tab*
114
- so.stdout.lines do |raw_line|
113
+ shell_out("smbios").stdout.lines do |raw_line|
115
114
  next if header_type_line.match(raw_line)
116
115
  next if blank_line.match(raw_line)
117
116
 
@@ -20,8 +20,7 @@ Ohai.plugin(:Memory) do
20
20
  collect_data(:solaris2) do
21
21
  memory Mash.new
22
22
  memory[:swap] = Mash.new
23
- meminfo = shell_out("prtconf | grep Memory").stdout
24
- memory[:total] = "#{meminfo.split[2].to_i * 1024}kB"
23
+ memory[:total] = "#{shell_out("prtconf | grep Memory").stdout.split[2].to_i * 1024}kB"
25
24
 
26
25
  tokens = shell_out("swap -s").stdout.strip.split
27
26
  used_swap = tokens[8][0..-1].to_i # strip k from end
@@ -54,13 +54,11 @@
54
54
  # inet6 fe80::203:baff:fe17:4444/128
55
55
 
56
56
  # Extracted from http://illumos.org/hcl/
57
- unless defined?(ETHERNET_ENCAPS)
58
- ETHERNET_ENCAPS = %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
57
+ ETHERNET_ENCAPS ||= %w{ afe amd8111s arn atge ath bfe bge bnx bnxe ce cxgbe
59
58
  dmfe e1000g efe elxl emlxs eri hermon hme hxge igb
60
59
  iprb ipw iwh iwi iwk iwp ixgb ixgbe mwl mxfe myri10ge
61
60
  nge ntxn nxge pcn platform qfe qlc ral rge rtls rtw rwd
62
61
  rwn sfe tavor vr wpi xge yge aggr}.freeze
63
- end
64
62
 
65
63
  Ohai.plugin(:Network) do
66
64
  require_relative "../../mixin/network_helper"
@@ -102,10 +100,8 @@ Ohai.plugin(:Network) do
102
100
  counters Mash.new unless counters
103
101
  counters[:network] ||= Mash.new
104
102
 
105
- so = shell_out("ifconfig -a")
106
103
  cint = nil
107
-
108
- so.stdout.lines do |line|
104
+ shell_out("ifconfig -a").stdout.lines do |line|
109
105
  # regex: https://rubular.com/r/ZiIHbsnfiWPW1p
110
106
  if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
111
107
  cint = $1
@@ -26,8 +26,7 @@ Ohai.plugin(:Platform) do
26
26
  uname_exec = "uname"
27
27
  end
28
28
 
29
- so = shell_out("#{uname_exec} -X")
30
- so.stdout.lines do |line|
29
+ shell_out("#{uname_exec} -X").stdout.lines do |line|
31
30
  case line
32
31
  when /^Release =\s+(.+)$/
33
32
  platform_version $1
@@ -25,9 +25,7 @@ Ohai.plugin(:Virtualization) do
25
25
  depends "dmi"
26
26
 
27
27
  def collect_solaris_guestid
28
- command = "/usr/sbin/zoneadm list -p"
29
- so = shell_out(command)
30
- so.stdout.split(":").first
28
+ shell_out("/usr/sbin/zoneadm list -p").stdout.split(":").first
31
29
  end
32
30
 
33
31
  collect_data(:solaris2) do
@@ -38,7 +36,7 @@ Ohai.plugin(:Virtualization) do
38
36
  psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
39
37
  if File.exist?(psrinfo_path)
40
38
  so = shell_out("#{psrinfo_path} -pv")
41
- if so.stdout =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
39
+ if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
42
40
  virtualization[:system] = "kvm"
43
41
  virtualization[:role] = "guest"
44
42
  virtualization[:systems][:kvm] = "guest"
@@ -56,8 +54,7 @@ Ohai.plugin(:Virtualization) do
56
54
 
57
55
  if File.executable?("/usr/sbin/zoneadm")
58
56
  zones = Mash.new
59
- so = shell_out("zoneadm list -pc")
60
- so.stdout.lines do |line|
57
+ shell_out("zoneadm list -pc").stdout.lines do |line|
61
58
  info = line.chomp.split(/:/)
62
59
  zones[info[1]] = {
63
60
  "id" => info[0],
@@ -51,7 +51,7 @@ Ohai.plugin(:SSHHostKey) do
51
51
  if sshd_config
52
52
  File.open(sshd_config) do |conf|
53
53
  conf.each_line do |line|
54
- if line =~ /^hostkey\s/i
54
+ if /^hostkey\s/i.match?(line)
55
55
  pub_file = "#{line.split[1]}.pub"
56
56
  content = IO.read(pub_file).split
57
57
  key_type, key_subtype = extract_keytype?(content)
@@ -84,7 +84,7 @@ Ohai.plugin(:Uptime) do
84
84
  end
85
85
 
86
86
  collect_data(:windows) do
87
- require "wmi-lite/wmi"
87
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
88
88
  wmi = WmiLite::Wmi.new
89
89
  last_boot_up_time = wmi.first_of("Win32_OperatingSystem")["lastbootuptime"]
90
90
  uptime_seconds Time.new.to_i - Time.parse(last_boot_up_time).to_i
@@ -51,12 +51,12 @@ Ohai.plugin(:VMware) do
51
51
  # to attribute "vmware[:<parameter>]"
52
52
  %w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
53
53
  vmware[param] = from_cmd("#{vmtools_path} stat #{param}")
54
- if vmware[param] =~ /UpdateInfo failed/
54
+ if /UpdateInfo failed/.match?(vmware[param])
55
55
  vmware[param] = nil
56
56
  end
57
57
  end
58
58
  # vmware-toolbox-cmd <param> status commands
59
- # Iterate through each parameter supported by the "vwware-toolbox-cmd status" command, assign value
59
+ # Iterate through each parameter supported by the "vmware-toolbox-cmd status" command, assign value
60
60
  # to attribute "vmware[:<parameter>]"
61
61
  %w{upgrade timesync}.each do |param|
62
62
  vmware[param] = from_cmd("#{vmtools_path} #{param} status")