ohai 16.7.18 → 16.7.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/dsl/plugin.rb +1 -1
  4. data/lib/ohai/dsl/plugin/versionvii.rb +0 -2
  5. data/lib/ohai/mixin/azure_metadata.rb +2 -2
  6. data/lib/ohai/mixin/ec2_metadata.rb +6 -6
  7. data/lib/ohai/mixin/gce_metadata.rb +1 -1
  8. data/lib/ohai/plugins/aix/kernel.rb +6 -4
  9. data/lib/ohai/plugins/aix/memory.rb +3 -3
  10. data/lib/ohai/plugins/aix/network.rb +50 -58
  11. data/lib/ohai/plugins/aix/platform.rb +2 -2
  12. data/lib/ohai/plugins/aix/virtualization.rb +6 -6
  13. data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
  14. data/lib/ohai/plugins/c.rb +3 -3
  15. data/lib/ohai/plugins/cloud.rb +1 -1
  16. data/lib/ohai/plugins/cpu.rb +25 -25
  17. data/lib/ohai/plugins/darwin/network.rb +7 -9
  18. data/lib/ohai/plugins/digital_ocean.rb +2 -1
  19. data/lib/ohai/plugins/dmi.rb +4 -4
  20. data/lib/ohai/plugins/docker.rb +1 -1
  21. data/lib/ohai/plugins/dragonflybsd/memory.rb +8 -8
  22. data/lib/ohai/plugins/dragonflybsd/platform.rb +2 -2
  23. data/lib/ohai/plugins/freebsd/memory.rb +8 -8
  24. data/lib/ohai/plugins/freebsd/platform.rb +2 -2
  25. data/lib/ohai/plugins/hostname.rb +1 -2
  26. data/lib/ohai/plugins/kernel.rb +5 -7
  27. data/lib/ohai/plugins/libvirt.rb +3 -3
  28. data/lib/ohai/plugins/linode.rb +1 -1
  29. data/lib/ohai/plugins/linux/network.rb +2 -2
  30. data/lib/ohai/plugins/netbsd/platform.rb +2 -2
  31. data/lib/ohai/plugins/network.rb +1 -1
  32. data/lib/ohai/plugins/openbsd/platform.rb +2 -2
  33. data/lib/ohai/plugins/os.rb +1 -1
  34. data/lib/ohai/plugins/packages.rb +1 -1
  35. data/lib/ohai/plugins/passwd.rb +1 -1
  36. data/lib/ohai/plugins/rackspace.rb +2 -2
  37. data/lib/ohai/plugins/scaleway.rb +1 -1
  38. data/lib/ohai/plugins/solaris2/network.rb +1 -1
  39. data/lib/ohai/plugins/solaris2/virtualization.rb +1 -2
  40. data/lib/ohai/plugins/train.rb +0 -1
  41. data/lib/ohai/plugins/uptime.rb +1 -1
  42. data/lib/ohai/plugins/virtualbox.rb +1 -1
  43. data/lib/ohai/plugins/vmware.rb +1 -2
  44. data/lib/ohai/plugins/zpools.rb +0 -1
  45. data/lib/ohai/util/ip_helper.rb +1 -1
  46. data/lib/ohai/version.rb +1 -1
  47. data/ohai.gemspec +1 -1
  48. metadata +12 -13
  49. data/lib/ohai/plugins/joyent.rb +0 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57f034c4995360aa8eb45d92d95ddee35d307411506e57be5a55b9a5e58b52f3
4
- data.tar.gz: dcffcadad6b0a1038b1715397ec2e9ee54000d42ac7cf3f2229e7bbe42e69395
3
+ metadata.gz: 39d6064d1c93ab4dac377f1883213fad35872ee08ac0c2b97801b5d96da1a1df
4
+ data.tar.gz: 5837422d08995fd7057e84d496d85b11514bd51b6b0d391b282fb3612fb083bc
5
5
  SHA512:
6
- metadata.gz: 9198da99387e9dfcc99350cba0a7e1e95f2a1e1de7fecf4ecf76b311d38352214b1f76179aa20bcd42f0017f7a8c5d9e73f251c016eb9e8c83d4e0be234da0a8
7
- data.tar.gz: bbd44815894afe658ab51d54088589f4c66d62a5099a81c93c48801a8aa454f9c8af38498b667a2fe51088889145a5b05cf376860459c4889453a088c066f9f5
6
+ metadata.gz: d58037d84d3f6066b86561940dffe8b812d89ef6e75a7a0a8a843affccb7b6fc98e29795d2bd62ce48b396eefc71901423e198274d5474c95e1fb189101f4992
7
+ data.tar.gz: cc8c6cbd38084685fe8cb8dccdc3f5c469829b0798c562fb8803dc37d0c3aacf2a844781689ef0f3a5796929f43951d59b083531fea4ed08a46a07395bb8a06d
data/Gemfile CHANGED
@@ -16,7 +16,7 @@ group :development do
16
16
  gem "rspec-core", "~> 3.0"
17
17
  gem "rspec-expectations", "~> 3.0"
18
18
  gem "rspec-mocks", "~> 3.0"
19
- gem "rubocop-performance", "1.8.1"
19
+ gem "rubocop-performance", "1.9.0"
20
20
  gem "rubocop-rspec"
21
21
  end
22
22
 
@@ -218,7 +218,7 @@ module Ohai
218
218
  def safe_get_attribute(*keys)
219
219
  keys.inject(@data) do |attrs, key|
220
220
  unless attrs.nil? || attrs.is_a?(Array) || attrs.is_a?(Hash)
221
- raise TypeError.new("Expected Hash but got #{attrs.class}.")
221
+ raise TypeError, "Expected Hash but got #{attrs.class}."
222
222
  end
223
223
 
224
224
  attrs[key]
@@ -195,8 +195,6 @@ module Ohai
195
195
  # key? to avoid falsely instantiating a configuration hash.
196
196
  if Ohai.config[:plugin].key?(snake_case_name)
197
197
  Ohai.config[:plugin][snake_case_name]
198
- else
199
- nil
200
198
  end
201
199
  end
202
200
  end
@@ -36,8 +36,8 @@ module Ohai
36
36
 
37
37
  # it's important that the newer versions are at the end of this array so we can skip sorting it
38
38
  AZURE_SUPPORTED_VERSIONS ||= %w{ 2017-04-02 2017-08-01 2017-12-01 2018-02-01 2018-04-02
39
- 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
40
- 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
39
+ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
40
+ 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
41
41
 
42
42
  def best_api_version
43
43
  @api_version ||= begin
@@ -42,8 +42,8 @@ module Ohai
42
42
 
43
43
  EC2_METADATA_ADDR ||= "169.254.169.254"
44
44
  EC2_SUPPORTED_VERSIONS ||= %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
45
- 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
46
- 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze
45
+ 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
46
+ 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze
47
47
  EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze
48
48
  EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze
49
49
  EC2_JSON_DIR ||= %w{iam}.freeze
@@ -58,7 +58,7 @@ module Ohai
58
58
  elsif response.code != "200"
59
59
  raise "Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)"
60
60
  end
61
- # Note: Sorting the list of versions may have unintended consequences in
61
+ # NOTE: Sorting the list of versions may have unintended consequences in
62
62
  # non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12.
63
63
  versions = response.body.split("\n").sort
64
64
  until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)
@@ -119,7 +119,7 @@ module Ohai
119
119
  else
120
120
  metadata_get(key, best_api_version)
121
121
  end
122
- elsif (not key.eql?(id)) && (not key.eql?("/"))
122
+ elsif (!key.eql?(id)) && (!key.eql?("/"))
123
123
  name = key[0..-2]
124
124
  sym = metadata_key(name)
125
125
  if EC2_ARRAY_DIR.include?(name)
@@ -144,7 +144,7 @@ module Ohai
144
144
  if key[-1..-1] != "/"
145
145
  retr_meta = metadata_get("#{id}#{key}", api_version)
146
146
  metadata[metadata_key(key)] = retr_meta || ""
147
- elsif not key.eql?("/")
147
+ elsif !key.eql?("/")
148
148
  metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version)
149
149
  end
150
150
  end
@@ -164,7 +164,7 @@ module Ohai
164
164
  json = String(data)
165
165
  parser = FFI_Yajl::Parser.new
166
166
  metadata[metadata_key(key)] = parser.parse(json)
167
- elsif not key.eql?("/")
167
+ elsif !key.eql?("/")
168
168
  metadata[key[0..-2]] = fetch_json_dir_metadata("#{id}#{key}", api_version)
169
169
  end
170
170
  end
@@ -72,7 +72,7 @@ module Ohai
72
72
  #
73
73
  # @return [Boolean] is there a trailing /?
74
74
  def has_trailing_slash?(data)
75
- !! ( data =~ %r{/$} )
75
+ !!( data =~ %r{/$} )
76
76
  end
77
77
 
78
78
  def sanitize_key(key)
@@ -24,10 +24,12 @@ Ohai.plugin(:Kernel) do
24
24
  collect_data(:aix) do
25
25
  kernel Mash.new
26
26
 
27
- kernel[:name] = shell_out("uname -s").stdout.split($/)[0].downcase
28
- kernel[:release] = shell_out("uname -r").stdout.split($/)[0]
29
- kernel[:version] = shell_out("uname -v").stdout.split($/)[0]
30
- kernel[:machine] = shell_out("uname -p").stdout.split($/)[0]
27
+ uname_so = shell_out("uname -rvp").stdout.split
28
+
29
+ kernel[:name] = "aix" # this is here for historical reasons, but it's always aix
30
+ kernel[:release] = uname_so[0]
31
+ kernel[:version] = uname_so[1]
32
+ kernel[:machine] = uname_so[2]
31
33
  kernel[:bits] = shell_out("getconf KERNEL_BITMODE").stdout.strip
32
34
 
33
35
  modules = Mash.new
@@ -25,10 +25,10 @@ Ohai.plugin(:Memory) do
25
25
  memory Mash.new
26
26
  memory[:swap] = Mash.new
27
27
 
28
- meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout
28
+ meminfo = shell_out("svmon -G -O unit=KB,summary=longreal | grep '[0-9]'").stdout
29
29
  total_in_mb, _u, free_in_mb = meminfo.split
30
- memory[:total] = "#{total_in_mb.to_i * 1024}kB"
31
- memory[:free] = "#{free_in_mb.to_i * 1024}kB"
30
+ memory[:total] = "#{total_in_mb.to_i}kB"
31
+ memory[:free] = "#{free_in_mb.to_i}kB"
32
32
 
33
33
  swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
34
34
  memory[:swap]["total"] = "#{swap_info[2].to_i * 4}kB"
@@ -22,7 +22,7 @@
22
22
  Ohai.plugin(:Network) do
23
23
  require_relative "../../mixin/network_helper"
24
24
 
25
- provides "network", "counters/network", "macaddress"
25
+ provides "network", "network/interfaces", "counters/network", "macaddress"
26
26
 
27
27
  include Ohai::Mixin::NetworkHelper
28
28
 
@@ -38,46 +38,44 @@ Ohai.plugin(:Network) do
38
38
  # => state up/down (ifconfig/lsattr)
39
39
  # => arp (arp -an)
40
40
 
41
- iface = Mash.new
41
+ ifaces = Mash.new
42
42
 
43
43
  network Mash.new unless network
44
- network[:interfaces] ||= Mash.new
45
44
 
46
45
  # We unfortunately have to do things a bit different here, if ohai is running
47
46
  # within a WPAR. For instance, the WPAR isn't aware of some of its own networking
48
- # minutia such as default gateway/route.
47
+ # minutia such as default gateway/route. lpars return 0 here. wpars return > 0
49
48
  unless shell_out("uname -W").stdout.to_i > 0
50
49
  # :default_interface, :default_gateway - route -n get 0
51
- so = shell_out("netstat -rn |grep default")
52
- so.stdout.lines.each do |line|
53
- items = line.split(" ")
54
- if items[0] == "default"
55
- network[:default_gateway] = items[1]
56
- network[:default_interface] = items[5]
57
- end
58
- end
50
+ default_line = shell_out("netstat -rn")
51
+ .stdout
52
+ .each_line
53
+ .detect { |l| l.start_with?("default") }
54
+ .split
55
+ network[:default_gateway] = default_line[1]
56
+ network[:default_interface] = default_line[5]
59
57
  end
60
58
 
61
- # Splits the ifconfig output to 1 line per interface
62
- if_so = shell_out("ifconfig -a")
63
- if_so.stdout.gsub(/\n(\w+\d+)/, '___\1').split("___").each do |intraface|
64
- splat = intraface.split(":")
65
- interface = splat[0]
66
- line = splat[1..-1][0]
67
- iface[interface] = Mash.new
68
- iface[interface][:state] = (line.include?("<UP,") ? "up" : "down")
69
-
70
- intraface.lines.each do |lin|
71
- case lin
59
+ # Splits the ifconfig output into arrays of interface strings
60
+ shell_out("ifconfig -a").stdout.split(/\n(?=\w)/).each do |int_lines|
61
+ int_name, int_data = int_lines.split(":", 2)
62
+
63
+ ifaces[int_name] = Mash.new
64
+ ifaces[int_name][:addresses] ||= Mash.new
65
+ ifaces[int_name][:state] = (int_data.include?("<UP,") ? "up" : "down")
66
+
67
+ int_data.each_line do |line|
68
+ case line
72
69
  when /flags=\S+<(\S+)>/
73
- iface[interface][:flags] = $1.split(",")
74
- iface[interface][:metric] = $1 if lin =~ /metric\s(\S+)/
70
+ ifaces[int_name][:flags] = $1.split(",")
71
+ ifaces[int_name][:metric] = $1 if line =~ /metric\s(\S+)/
75
72
  else
76
73
  # We have key value pairs.
77
- if lin =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
78
- tmp_addr, tmp_prefix = $1, $3
74
+ if line =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
75
+ tmp_addr = $1
76
+ tmp_prefix = $3
79
77
  if tmp_prefix.nil?
80
- netmask = hex_to_dec_netmask($1) if lin =~ /netmask\s0x(\S+)\s/
78
+ netmask = hex_to_dec_netmask($1) if line =~ /netmask\s0x(\S+)\s/
81
79
  unless netmask
82
80
  tmp_prefix ||= "32"
83
81
  netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
@@ -86,57 +84,51 @@ Ohai.plugin(:Network) do
86
84
  netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
87
85
  end
88
86
 
89
- iface[interface][:addresses] ||= Mash.new
90
- iface[interface][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
91
- iface[interface][:addresses][tmp_addr][:netmask] = netmask
87
+ ifaces[int_name][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
88
+ ifaces[int_name][:addresses][tmp_addr][:netmask] = netmask
92
89
 
93
- if lin =~ /broadcast\s(\S+)\s/
94
- iface[interface][:addresses][tmp_addr][:broadcast] = $1
90
+ if line =~ /broadcast\s(\S+)\s/
91
+ ifaces[int_name][:addresses][tmp_addr][:broadcast] = $1
95
92
  end
96
- elsif lin =~ %r{inet6 ([a-f0-9\:]+)%?(\d*)/?(\d*)?}
97
- # TODO do we have more properties on inet6 in aix? broadcast
98
- iface[interface][:addresses] ||= Mash.new
99
- iface[interface][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
93
+ elsif line =~ %r{inet6 ([a-f0-9\:]+)%?(\d*)/?(\d*)?}
94
+ # TODO: do we have more properties on inet6 in aix? broadcast
95
+ ifaces[int_name][:addresses] ||= Mash.new
96
+ ifaces[int_name][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
100
97
  else
101
- # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
102
- properties = lin.split
103
- n = properties.length / 2 - 1
104
- (0..n).each do |i|
105
- iface[interface][properties[i * 2]] = properties[(i * 2 + 1)]
98
+ # add all key value data into the interface mash
99
+ # for example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
100
+ # has keys tcp_sendspace, tcp_recvspace, and rfc1323
101
+ line.split.each_slice(2) do |key, value|
102
+ ifaces[int_name][key] = value
106
103
  end
107
104
  end
108
105
  end
109
106
  end
110
107
 
111
108
  # Query macaddress
112
- e_so = shell_out("entstat -d #{interface} | grep \"Hardware Address\"")
113
- iface[interface][:addresses] ||= Mash.new
114
- e_so.stdout.lines.each do |l|
115
- if l =~ /Hardware Address: (\S+)/
116
- iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" }
117
- macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
118
- end
109
+ shell_out("entstat -d #{int_name}").stdout =~ /Hardware Address: (\S+)/
110
+ if $1
111
+ ifaces[int_name][:addresses][$1.upcase] = { "family" => "lladdr" }
112
+ macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
119
113
  end
120
114
  end # ifconfig stdout
121
115
 
122
116
  # Query routes information
123
117
  %w{inet inet6}.each do |family|
124
- so_n = shell_out("netstat -nrf #{family}")
125
- so_n.stdout.lines.each do |line|
118
+ shell_out("netstat -nrf #{family}").stdout.each_line do |line|
126
119
  if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
127
120
  interface = $6
128
- iface[interface][:routes] = [] unless iface[interface][:routes]
129
- iface[interface][:routes] << Mash.new( destination: $1, family: family,
130
- via: $2, flags: $3)
121
+ ifaces[interface][:routes] ||= []
122
+ ifaces[interface][:routes] << Mash.new( destination: $1, family: family,
123
+ via: $2, flags: $3)
131
124
  end
132
125
  end
133
126
  end
134
127
 
135
128
  # List the arp entries in system.
136
- so = shell_out("arp -an")
137
129
  count = 0
138
- so.stdout.lines.each do |line|
139
- network[:arp] ||= Mash.new
130
+ network[:arp] ||= Mash.new
131
+ shell_out("arp -an").stdout.each_line do |line|
140
132
  if line =~ /\s*(\S+) \((\S+)\) at ([a-fA-F0-9\:]+) \[(\w+)\] stored in bucket/
141
133
  network[:arp][count] ||= Mash.new
142
134
  network[:arp][count][:remote_host] = $1
@@ -145,6 +137,6 @@ Ohai.plugin(:Network) do
145
137
  count += 1
146
138
  end
147
139
  end
148
- network["interfaces"] = iface
140
+ network["interfaces"] = ifaces
149
141
  end
150
142
  end
@@ -23,8 +23,8 @@ Ohai.plugin(:Platform) do
23
23
  depends "kernel"
24
24
 
25
25
  collect_data(:aix) do
26
- platform kernel[:name]
26
+ platform "aix"
27
+ platform_family "aix"
27
28
  platform_version [kernel[:version], kernel[:release]].join(".")
28
- platform_family platform
29
29
  end
30
30
  end
@@ -23,17 +23,14 @@ Ohai.plugin(:Virtualization) do
23
23
  collect_data(:aix) do
24
24
  virtualization Mash.new
25
25
 
26
- so = shell_out("uname -L")
27
- lpar_no = so.stdout.split($/)[0].split(/\s/)[0]
28
- lpar_name = so.stdout.split($/)[0].split(/\s/)[1]
26
+ lpar_no, lpar_name = shell_out("uname -L").stdout.split(nil, 2)
29
27
 
30
28
  unless lpar_no.to_i == -1 || (lpar_no.to_i == 1 && lpar_name == "NULL")
31
29
  virtualization[:lpar_no] = lpar_no
32
30
  virtualization[:lpar_name] = lpar_name
33
31
  end
34
32
 
35
- so = shell_out("uname -W")
36
- wpar_no = so.stdout.split($/)[0]
33
+ wpar_no = shell_out("uname -W").stdout.strip
37
34
  if wpar_no.to_i > 0
38
35
  virtualization[:wpar_no] = wpar_no
39
36
  else
@@ -41,8 +38,11 @@ Ohai.plugin(:Virtualization) do
41
38
  so = shell_out("lswpar -L").stdout.scan(/={65}.*?(?:EXPORTED\n\n)+/m)
42
39
  wpars = Mash.new
43
40
  so.each do |wpar|
44
- wpar_name = wpar.lines[1].split[0]
41
+ wpar_heading = wpar.lines[1].split
42
+ wpar_name = wpar_heading[0]
43
+
45
44
  wpars[wpar_name] = Mash.new
45
+ wpars[wpar_name][:state] = wpar_heading[2].downcase
46
46
 
47
47
  wpar.scan(/^[A-Z]{4,}.*?[A-Z\:0-9]$.*?\n\n/m).each do |section|
48
48
 
@@ -31,7 +31,7 @@ Ohai.plugin(:Virtualization) do
31
31
 
32
32
  # detect when in a jail or when a jail is actively running (not in stopped state)
33
33
  so = shell_out("sysctl -n security.jail.jailed")
34
- if so.stdout.split($/)[0].to_i == 1
34
+ if so.stdout.strip.to_i == 1
35
35
  virtualization[:system] = "jail"
36
36
  virtualization[:role] = "guest"
37
37
  virtualization[:systems][:jail] = "guest"
@@ -123,12 +123,12 @@ Ohai.plugin(:C) do
123
123
  end
124
124
 
125
125
  def collect_xlc
126
- # ibm xlc
127
-
126
+ # IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
127
+ # Version: 13.01.0003.0000
128
128
  so = shell_out("xlc -qversion")
129
129
  if so.exitstatus == 0 || (so.exitstatus >> 8) == 249
130
130
  description = so.stdout.split($/).first
131
- if description =~ /V(\d+\.\d+)/
131
+ if description =~ /V(\d+\.\d+(.\d+)?)/
132
132
  @c[:xlc] = Mash.new
133
133
  @c[:xlc][:version] = $1
134
134
  @c[:xlc][:description] = description.strip
@@ -110,7 +110,7 @@ Ohai.plugin(:Cloud) do
110
110
  ipaddr = ""
111
111
  begin
112
112
  ipaddr = IPAddr.new(ip)
113
- raise ArgumentError, "not valid #{address_family} address" unless (address_family == :ipv4) ? ipaddr.ipv4? : ipaddr.ipv6?
113
+ raise ArgumentError, "not valid #{address_family} address" unless address_family == :ipv4 ? ipaddr.ipv4? : ipaddr.ipv6?
114
114
  rescue ArgumentError => e
115
115
  raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
116
116
  end
@@ -85,15 +85,15 @@ Ohai.plugin(:CPU) do
85
85
  when /cache size\s+:\s(.+)/
86
86
  cpuinfo[current_cpu]["cache_size"] = $1
87
87
  when /flags\s+:\s(.+)/
88
- cpuinfo[current_cpu]["flags"] = $1.split(" ")
88
+ cpuinfo[current_cpu]["flags"] = $1.split
89
89
  when /BogoMIPS\s+:\s(.+)/
90
90
  cpuinfo[current_cpu]["bogomips"] = $1
91
91
  when /Features\s+:\s(.+)/
92
- cpuinfo[current_cpu]["features"] = $1.split(" ")
92
+ cpuinfo[current_cpu]["features"] = $1.split
93
93
  when /bogomips per cpu:\s(.+)/
94
94
  cpuinfo["bogomips_per_cpu"] = $1
95
95
  when /features\s+:\s(.+)/
96
- cpuinfo["features"] = $1.split(" ")
96
+ cpuinfo["features"] = $1.split
97
97
  when /processor\s(\d):\s(.+)/
98
98
  current_cpu = $1
99
99
  cpu_number += 1
@@ -200,7 +200,7 @@ Ohai.plugin(:CPU) do
200
200
  end
201
201
 
202
202
  so = shell_out("sysctl -n hw.ncpu")
203
- info[:total] = so.stdout.split($/)[0].to_i
203
+ info[:total] = so.stdout.strip.to_i
204
204
  cpu info
205
205
  end
206
206
 
@@ -220,7 +220,7 @@ Ohai.plugin(:CPU) do
220
220
 
221
221
  [["hw.model", :model_name], ["hw.ncpu", :total], ["hw.cpuspeed", :mhz]].each do |param, node|
222
222
  so = shell_out("sysctl -n #{param}")
223
- cpuinfo[node] = so.stdout.split($/)[0]
223
+ cpuinfo[node] = so.stdout.strip
224
224
  end
225
225
 
226
226
  cpu cpuinfo
@@ -278,7 +278,7 @@ Ohai.plugin(:CPU) do
278
278
  when /^machdep.cpu.stepping: (.*)$/
279
279
  cpu[:stepping] = Regexp.last_match[1].to_i
280
280
  when /^machdep.cpu.features: (.*)$/
281
- cpu[:flags] = Regexp.last_match[1].downcase.split(" ")
281
+ cpu[:flags] = Regexp.last_match[1].downcase.split
282
282
  end
283
283
  end
284
284
  end
@@ -348,25 +348,25 @@ Ohai.plugin(:CPU) do
348
348
  key = kv.shift
349
349
  value = kv.join(" ").chomp
350
350
  case key
351
- when /chip_id/
352
- cpu[instance]["socket"] = value
353
- cpusockets.push(value) if cpusockets.index(value).nil?
354
- when /cpu_type/
355
- cpu[instance]["arch"] = value
356
- when /clock_MHz/
357
- cpu[instance]["mhz"] = value
358
- when /brand/
359
- cpu[instance]["model_name"] = value.sub(/\s+/, " ")
360
- when /^state$/
361
- cpu[instance]["state"] = value
362
- cpu["cpustates"][value] ||= 0
363
- cpu["cpustates"][value] += 1
364
- when /core_id/
365
- cpu[instance]["core_id"] = value
366
- # Detect hyperthreading/multithreading
367
- cpucores.push(value) if cpucores.index(value).nil?
368
- when /family|fpu_type|model|stepping|vendor_id/
369
- cpu[instance][key] = value
351
+ when /chip_id/
352
+ cpu[instance]["socket"] = value
353
+ cpusockets.push(value) if cpusockets.index(value).nil?
354
+ when /cpu_type/
355
+ cpu[instance]["arch"] = value
356
+ when /clock_MHz/
357
+ cpu[instance]["mhz"] = value
358
+ when /brand/
359
+ cpu[instance]["model_name"] = value.sub(/\s+/, " ")
360
+ when /^state$/
361
+ cpu[instance]["state"] = value
362
+ cpu["cpustates"][value] ||= 0
363
+ cpu["cpustates"][value] += 1
364
+ when /core_id/
365
+ cpu[instance]["core_id"] = value
366
+ # Detect hyperthreading/multithreading
367
+ cpucores.push(value) if cpucores.index(value).nil?
368
+ when /family|fpu_type|model|stepping|vendor_id/
369
+ cpu[instance][key] = value
370
370
  end
371
371
  end
372
372
  cpu["cores"] = cpucores.size
@@ -27,7 +27,7 @@ Ohai.plugin(:Network) do
27
27
 
28
28
  def parse_media(media_string)
29
29
  media = {}
30
- line_array = media_string.split(" ")
30
+ line_array = media_string.split
31
31
 
32
32
  0.upto(line_array.length - 1) do |i|
33
33
  unless line_array[i].eql?("none")
@@ -41,11 +41,9 @@ Ohai.plugin(:Network) do
41
41
  else
42
42
  media[line_array[i]]["options"] = $1.split(",")
43
43
  end
44
- else
45
- if line_array[i].eql?("autoselect")
46
- media["autoselect"] = {} unless media.key?("autoselect")
47
- media["autoselect"]["options"] = []
48
- end
44
+ elsif line_array[i].eql?("autoselect")
45
+ media["autoselect"] = {} unless media.key?("autoselect")
46
+ media["autoselect"]["options"] = []
49
47
  end
50
48
  else
51
49
  media["none"] = { "options" => [] }
@@ -145,15 +143,15 @@ Ohai.plugin(:Network) do
145
143
  end
146
144
  if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
147
145
  iface[cint][:addresses] ||= Mash.new
148
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) , "broadcast" => $4 }
146
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
149
147
  end
150
148
  if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*/
151
149
  iface[cint][:addresses] ||= Mash.new
152
- iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
150
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4, "scope" => scope_lookup($1) }
153
151
  end
154
152
  if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
155
153
  iface[cint][:addresses] ||= Mash.new
156
- iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
154
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4, "scope" => scope_lookup($1) }
157
155
  end
158
156
  if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
159
157
  iface[cint][:media] ||= Mash.new
@@ -49,7 +49,8 @@ Ohai.plugin(:DigitalOcean) do
49
49
  false
50
50
  end
51
51
 
52
- collect_data do
52
+ # linux and freebsd is all digitalocean supports
53
+ collect_data(:linux, :freebsd) do
53
54
  if looks_like_digital_ocean?
54
55
  logger.trace("Plugin Digitalocean: looks_like_digital_ocean? == true")
55
56
  digital_ocean Mash.new
@@ -93,14 +93,14 @@ Ohai.plugin(:DMI) do
93
93
  field = nil
94
94
 
95
95
  elsif ( type = type_line.match(line) )
96
- if dmi_record .nil?
96
+ if dmi_record.nil?
97
97
  logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
98
98
  next
99
99
  end
100
100
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = type[1]
101
101
 
102
102
  elsif ( data = data_line.match(line) )
103
- if dmi_record .nil?
103
+ if dmi_record.nil?
104
104
  logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
105
105
  next
106
106
  end
@@ -108,11 +108,11 @@ Ohai.plugin(:DMI) do
108
108
  field = data[1]
109
109
 
110
110
  elsif ( extended_data = extended_data_line.match(line) )
111
- if dmi_record .nil?
111
+ if dmi_record.nil?
112
112
  logger.trace("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
113
113
  next
114
114
  end
115
- if field .nil?
115
+ if field.nil?
116
116
  logger.trace("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
117
117
  next
118
118
  end
@@ -48,7 +48,7 @@ Ohai.plugin(:Docker) do
48
48
  docker[:swarm] = shellout_data["Swarm"]
49
49
  end
50
50
 
51
- collect_data do
51
+ collect_data(:linux, :windows, :darwin) do
52
52
  require "json" unless defined?(JSON)
53
53
 
54
54
  if virtualization[:systems][:docker]
@@ -26,22 +26,22 @@ Ohai.plugin(:Memory) do
26
26
 
27
27
  # /usr/src/sys/sys/vmmeter.h
28
28
  so = shell_out("sysctl -n vm.stats.vm.v_page_size")
29
- memory[:page_size] = so.stdout.split($/)[0]
29
+ memory[:page_size] = so.stdout.strip
30
30
  so = shell_out("sysctl -n vm.stats.vm.v_page_count")
31
- memory[:page_count] = so.stdout.split($/)[0]
31
+ memory[:page_count] = so.stdout.strip
32
32
  memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
33
33
  so = shell_out("sysctl -n vm.stats.vm.v_free_count")
34
- memory[:free] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
34
+ memory[:free] = memory[:page_size].to_i * so.stdout.strip.to_i
35
35
  so = shell_out("sysctl -n vm.status.vm.v_active_count")
36
- memory[:active] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
36
+ memory[:active] = memory[:page_size].to_i * so.stdout.strip.to_i
37
37
  so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
38
- memory[:inactive] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
38
+ memory[:inactive] = memory[:page_size].to_i * so.stdout.strip.to_i
39
39
  so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
40
- memory[:cache] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
40
+ memory[:cache] = memory[:page_size].to_i * so.stdout.strip.to_i
41
41
  so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
42
- memory[:wired] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
42
+ memory[:wired] = memory[:page_size].to_i * so.stdout.strip.to_i
43
43
  so = shell_out("sysctl -n vfs.bufspace")
44
- memory[:buffers] = so.stdout.split($/)[0]
44
+ memory[:buffers] = so.stdout.strip
45
45
 
46
46
  so = shell_out("swapinfo")
47
47
  so.stdout.lines do |line|
@@ -21,8 +21,8 @@ Ohai.plugin(:Platform) do
21
21
  provides "platform", "platform_version", "platform_family"
22
22
 
23
23
  collect_data(:dragonflybsd) do
24
- platform shell_out("uname -s").stdout.split($/)[0].downcase
25
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
26
26
  platform_family "dragonflybsd"
27
27
  end
28
28
  end
@@ -26,22 +26,22 @@ Ohai.plugin(:Memory) do
26
26
 
27
27
  # /usr/src/sys/sys/vmmeter.h
28
28
  so = shell_out("sysctl -n vm.stats.vm.v_page_size")
29
- memory[:page_size] = so.stdout.split($/)[0]
29
+ memory[:page_size] = so.stdout.strip
30
30
  so = shell_out("sysctl -n vm.stats.vm.v_page_count")
31
- memory[:page_count] = so.stdout.split($/)[0]
31
+ memory[:page_count] = so.stdout.strip
32
32
  memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
33
33
  so = shell_out("sysctl -n vm.stats.vm.v_free_count")
34
- memory[:free] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
34
+ memory[:free] = memory[:page_size].to_i * so.stdout.strip.to_i
35
35
  so = shell_out("sysctl -n vm.status.vm.v_active_count")
36
- memory[:active] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
36
+ memory[:active] = memory[:page_size].to_i * so.stdout.strip.to_i
37
37
  so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
38
- memory[:inactive] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
38
+ memory[:inactive] = memory[:page_size].to_i * so.stdout.strip.to_i
39
39
  so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
40
- memory[:cache] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
40
+ memory[:cache] = memory[:page_size].to_i * so.stdout.strip.to_i
41
41
  so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
42
- memory[:wired] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
42
+ memory[:wired] = memory[:page_size].to_i * so.stdout.strip.to_i
43
43
  so = shell_out("sysctl -n vfs.bufspace")
44
- memory[:buffers] = so.stdout.split($/)[0]
44
+ memory[:buffers] = so.stdout.strip
45
45
 
46
46
  so = shell_out("swapinfo")
47
47
  so.stdout.lines do |line|
@@ -21,8 +21,8 @@ Ohai.plugin(:Platform) do
21
21
  provides "platform", "platform_version", "platform_family"
22
22
 
23
23
  collect_data(:freebsd) do
24
- platform shell_out("uname -s").stdout.split($/)[0].downcase
25
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
26
26
  platform_family "freebsd"
27
27
  end
28
28
  end
@@ -38,8 +38,7 @@ Ohai.plugin(:Hostname) do
38
38
  # fqdn and domain may be broken if DNS is broken on the host
39
39
 
40
40
  def from_cmd(cmd)
41
- so = shell_out(cmd)
42
- so.stdout.split($/)[0]
41
+ shell_out(cmd).stdout.strip
43
42
  end
44
43
 
45
44
  # forward and reverse lookup to canonicalize FQDN (hostname -f equivalent)
@@ -34,7 +34,7 @@ Ohai.plugin(:Kernel) do
34
34
  ["uname -v", :version], ["uname -m", :machine],
35
35
  ["uname -p", :processor]].each do |cmd, property|
36
36
  so = shell_out(cmd)
37
- kernel[property] = so.stdout.split($/)[0]
37
+ kernel[property] = so.stdout.strip
38
38
  end
39
39
  kernel
40
40
  end
@@ -115,7 +115,6 @@ Ohai.plugin(:Kernel) do
115
115
  when 16 then "WIN95"
116
116
  when 17 then "WIN98"
117
117
  when 19 then "WINCE"
118
- else nil
119
118
  end
120
119
  end
121
120
 
@@ -134,7 +133,6 @@ Ohai.plugin(:Kernel) do
134
133
  when 6 then "Appliance PC"
135
134
  when 7 then "Performance Server"
136
135
  when 8 then "Maximum"
137
- else nil
138
136
  end
139
137
  end
140
138
 
@@ -170,7 +168,7 @@ Ohai.plugin(:Kernel) do
170
168
  kernel[:os] = kernel[:name]
171
169
 
172
170
  so = shell_out("sysctl -n hw.optional.x86_64")
173
- if so.stdout.split($/)[0].to_i == 1
171
+ if so.stdout.strip.to_i == 1
174
172
  kernel[:machine] = "x86_64"
175
173
  end
176
174
 
@@ -190,7 +188,7 @@ Ohai.plugin(:Kernel) do
190
188
  kernel[:os] = kernel[:name]
191
189
 
192
190
  so = shell_out("uname -i")
193
- kernel[:ident] = so.stdout.split($/)[0]
191
+ kernel[:ident] = so.stdout.strip
194
192
  so = shell_out("sysctl kern.securelevel")
195
193
  kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
196
194
 
@@ -201,7 +199,7 @@ Ohai.plugin(:Kernel) do
201
199
  kernel init_kernel
202
200
 
203
201
  so = shell_out("uname -o")
204
- kernel[:os] = so.stdout.split($/)[0]
202
+ kernel[:os] = so.stdout.strip
205
203
 
206
204
  modules = Mash.new
207
205
  so = shell_out("env lsmod")
@@ -233,7 +231,7 @@ Ohai.plugin(:Kernel) do
233
231
  kernel init_kernel
234
232
 
235
233
  so = shell_out("uname -s")
236
- kernel[:os] = so.stdout.split($/)[0]
234
+ kernel[:os] = so.stdout.strip
237
235
 
238
236
  so = file_open("/etc/release", &:gets)
239
237
  md = /(?<update>\d.*\d)/.match(so)
@@ -17,11 +17,11 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- # Note: This plugin requires libvirt-bin/libvirt-dev as well as the ruby-libvirt
20
+ # NOTE: This plugin requires libvirt-bin/libvirt-dev as well as the ruby-libvirt
21
21
  # gem to be installed before it will properly parse data
22
22
 
23
23
  Ohai.plugin(:Libvirt) do
24
- %w{ uri capabilities nodeinfo domains networks storage }.each do |info|
24
+ %w{uri capabilities nodeinfo domains networks storage}.each do |info|
25
25
  provides "libvirt/#{info}"
26
26
  depends "virtualization"
27
27
  end
@@ -89,7 +89,7 @@ Ohai.plugin(:Libvirt) do
89
89
  storage_data
90
90
  end
91
91
 
92
- collect_data do
92
+ collect_data(:linux) do
93
93
  if virtualization[:role].eql?("host")
94
94
  load_libvirt
95
95
  begin
@@ -51,7 +51,7 @@ Ohai.plugin(:Linode) do
51
51
  end
52
52
  end
53
53
 
54
- collect_data do
54
+ collect_data(:linux) do
55
55
  # Setup linode mash if it is a linode system
56
56
  if looks_like_linode?
57
57
  logger.trace("Plugin Linode: looks_like_linode? == true")
@@ -154,7 +154,7 @@ Ohai.plugin(:Network) do
154
154
  def ethernet_layer_one(iface)
155
155
  return iface unless ethtool_binary_path
156
156
 
157
- keys = %w{ Speed Duplex Port Transceiver Auto-negotiation MDI-X }
157
+ keys = %w{Speed Duplex Port Transceiver Auto-negotiation MDI-X}
158
158
  iface.each_key do |tmp_int|
159
159
  next unless iface[tmp_int][:encapsulation] == "Ethernet"
160
160
 
@@ -466,7 +466,7 @@ Ohai.plugin(:Network) do
466
466
  iface[cint][:addresses] ||= Mash.new
467
467
  tmp_addr = $1
468
468
  tags = $4 || ""
469
- tags = tags.split(" ")
469
+ tags = tags.split
470
470
 
471
471
  iface[cint][:addresses][tmp_addr] = {
472
472
  "family" => "inet6",
@@ -21,8 +21,8 @@ Ohai.plugin(:Platform) do
21
21
  provides "platform", "platform_version", "platform_family"
22
22
 
23
23
  collect_data(:netbsd) do
24
- platform shell_out("uname -s").stdout.split($/)[0].downcase
25
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
26
26
  platform_family "netbsd"
27
27
  end
28
28
  end
@@ -39,7 +39,7 @@ Ohai.plugin(:NetworkAddresses) do
39
39
  next if iface_v.nil? || !iface_v.key?("addresses")
40
40
 
41
41
  iface_v["addresses"].each do |addr, addr_v|
42
- next if addr_v.nil? || (not addr_v.key? "family") || addr_v["family"] != family
42
+ next if addr_v.nil? || (!addr_v.key? "family") || addr_v["family"] != family
43
43
 
44
44
  ipaddresses << {
45
45
  ipaddress: addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
@@ -21,8 +21,8 @@ Ohai.plugin(:Platform) do
21
21
  provides "platform", "platform_version", "platform_family"
22
22
 
23
23
  collect_data(:openbsd) do
24
- platform shell_out("uname -s").stdout.split($/)[0].downcase
25
- platform_version shell_out("uname -r").stdout.split($/)[0]
24
+ platform shell_out("uname -s").stdout.strip.downcase
25
+ platform_version shell_out("uname -r").stdout.strip
26
26
  platform_family "openbsd"
27
27
  end
28
28
  end
@@ -35,7 +35,7 @@ Ohai.plugin(:OS) do
35
35
 
36
36
  # This is __DragonFly_version / __FreeBSD_version. See sys/param.h or
37
37
  # http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
38
- os_version shell_out("sysctl -n kern.osreldate").stdout.split($/)[0]
38
+ os_version shell_out("sysctl -n kern.osreldate").stdout.strip
39
39
  end
40
40
 
41
41
  collect_data(:target) do
@@ -164,7 +164,7 @@ Ohai.plugin(:Packages) do
164
164
  # Output format is
165
165
  # name version
166
166
  so.stdout.lines do |pkg|
167
- name, version = pkg.split(" ")
167
+ name, version = pkg.split
168
168
  packages[name] = { "version" => version }
169
169
  end
170
170
  end
@@ -91,7 +91,7 @@ Ohai.plugin(:Passwd) do
91
91
  if info.keys.any? { |x| x.match?("Win32_UserAccount") }
92
92
  mi["type"] = :user
93
93
  else
94
- # Note: the type here is actually Win32_SystemAccount, because,
94
+ # NOTE: the type here is actually Win32_SystemAccount, because,
95
95
  # that's what groups are in the Windows universe.
96
96
  mi["type"] = :group
97
97
  end
@@ -161,10 +161,10 @@ Ohai.plugin(:Rackspace) do
161
161
  get_global_ipv6_address(:public_ipv6, :eth0)
162
162
  unless rackspace[:public_ip].nil?
163
163
  rackspace[:public_hostname] = begin
164
- Resolv.getname(rackspace[:public_ip])
164
+ Resolv.getname(rackspace[:public_ip])
165
165
  rescue Resolv::ResolvError, Resolv::ResolvTimeout
166
166
  rackspace[:public_ip]
167
- end
167
+ end
168
168
  end
169
169
  rackspace[:local_ipv4] = rackspace[:private_ip]
170
170
  get_global_ipv6_address(:local_ipv6, :eth1)
@@ -44,7 +44,7 @@ Ohai.plugin(:Scaleway) do
44
44
  false
45
45
  end
46
46
 
47
- collect_data do
47
+ collect_data(:linux) do
48
48
  if looks_like_scaleway?
49
49
  logger.trace("Plugin Scaleway: looks_like_scaleway? == true")
50
50
  scaleway Mash.new
@@ -127,7 +127,7 @@ Ohai.plugin(:Network) do
127
127
  end
128
128
  if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
129
129
  iface[cint][:addresses] ||= Mash.new
130
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) , "broadcast" => $4 }
130
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
131
131
  end
132
132
  if line =~ %r{\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)/(\d+)\s*$}
133
133
  iface[cint][:addresses] ||= Mash.new
@@ -69,12 +69,11 @@ Ohai.plugin(:Virtualization) do
69
69
 
70
70
  if zones.length == 1
71
71
  first_zone = zones.keys[0]
72
+ virtualization[:system] = "zone"
72
73
  if first_zone == "global"
73
- virtualization[:system] = "zone"
74
74
  virtualization[:role] = "host"
75
75
  virtualization[:systems][:zone] = "host"
76
76
  else
77
- virtualization[:system] = "zone"
78
77
  virtualization[:role] = "guest"
79
78
  virtualization[:systems][:zone] = "guest"
80
79
  virtualization[:guest_uuid] = zones[first_zone]["uuid"]
@@ -29,7 +29,6 @@ Ohai.plugin(:Train) do
29
29
  if transport_connection.respond_to?(:uri)
30
30
  train["scheme"] = URI.parse(transport_connection.uri).scheme
31
31
  train["uri"] = transport_connection.uri
32
- else
33
32
  end
34
33
  end
35
34
  end
@@ -55,7 +55,7 @@ Ohai.plugin(:Uptime) do
55
55
  end
56
56
 
57
57
  collect_data(:linux) do
58
- uptime, idletime = file_open("/proc/uptime").gets.split(" ")
58
+ uptime, idletime = file_open("/proc/uptime").gets.split
59
59
  uptime_seconds uptime.to_i
60
60
  uptime seconds_to_human(uptime.to_i)
61
61
  idletime_seconds idletime.to_i
@@ -128,7 +128,7 @@ Ohai.plugin(:Virtualbox) do
128
128
  logger.trace("Plugin VboxHost: Could not run '#{so_cmd}'. Skipping data")
129
129
  end
130
130
 
131
- collect_data(:default) do
131
+ collect_data(:windows, :linux, :solaris2, :darwin) do
132
132
  case virtualization.dig("systems", "vbox")
133
133
  when "guest"
134
134
  logger.trace("Plugin Virtualbox: Node detected as vbox guest. Collecting guest data.")
@@ -37,8 +37,7 @@ Ohai.plugin(:VMware) do
37
37
  depends "virtualization"
38
38
 
39
39
  def from_cmd(cmd)
40
- so = shell_out(cmd)
41
- so.stdout.split($/)[0]
40
+ shell_out(cmd).stdout.strip
42
41
  end
43
42
 
44
43
  def get_vm_attributes(vmtools_path)
@@ -46,7 +46,6 @@ Ohai.plugin(:Zpools) do
46
46
  pools[$1][:zpool_version] = sanitize_value($8)
47
47
  end
48
48
  end
49
-
50
49
  rescue Ohai::Exceptions::Exec
51
50
  Ohai::Log.debug('Plugin Zpools: Could not shell_out "zpool list -H -o name,size,alloc,free,cap,dedup,health,version". Skipping plugin.')
52
51
  end
@@ -33,7 +33,7 @@ module Ohai
33
33
  IPV6_LINK_LOCAL_UNICAST_BLOCK.include?(ip) || IPV6_PRIVATE_ADDRESS_BLOCK.include?(ip)
34
34
  end
35
35
  end
36
- alias :unique_local_address? :private_address?
36
+ alias unique_local_address? private_address?
37
37
 
38
38
  def public_address?(addr)
39
39
  !private_address?(addr)
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "16.7.18"
22
+ VERSION = "16.7.37"
23
23
  end
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "mixlib-log", ">= 2.0.1", "< 4.0"
25
25
  s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
26
26
  s.add_dependency "plist", "~> 3.1"
27
- s.add_dependency "wmi-lite", "~> 1.0"
28
27
  s.add_dependency "train-core"
28
+ s.add_dependency "wmi-lite", "~> 1.0"
29
29
  # Note for ohai developers: If chef-config causes you grief, try:
30
30
  # bundle install --with development
31
31
  # this should work as long as chef is a development dependency in Gemfile.
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: 16.7.18
4
+ version: 16.7.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-07 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -181,33 +181,33 @@ dependencies:
181
181
  - !ruby/object:Gem::Version
182
182
  version: '3.1'
183
183
  - !ruby/object:Gem::Dependency
184
- name: wmi-lite
184
+ name: train-core
185
185
  requirement: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - "~>"
187
+ - - ">="
188
188
  - !ruby/object:Gem::Version
189
- version: '1.0'
189
+ version: '0'
190
190
  type: :runtime
191
191
  prerelease: false
192
192
  version_requirements: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - "~>"
194
+ - - ">="
195
195
  - !ruby/object:Gem::Version
196
- version: '1.0'
196
+ version: '0'
197
197
  - !ruby/object:Gem::Dependency
198
- name: train-core
198
+ name: wmi-lite
199
199
  requirement: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - ">="
201
+ - - "~>"
202
202
  - !ruby/object:Gem::Version
203
- version: '0'
203
+ version: '1.0'
204
204
  type: :runtime
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ">="
208
+ - - "~>"
209
209
  - !ruby/object:Gem::Version
210
- version: '0'
210
+ version: '1.0'
211
211
  description: Ohai profiles your system and emits JSON
212
212
  email: adam@chef.io
213
213
  executables:
@@ -289,7 +289,6 @@ files:
289
289
  - lib/ohai/plugins/hostname.rb
290
290
  - lib/ohai/plugins/init_package.rb
291
291
  - lib/ohai/plugins/java.rb
292
- - lib/ohai/plugins/joyent.rb
293
292
  - lib/ohai/plugins/kernel.rb
294
293
  - lib/ohai/plugins/keys.rb
295
294
  - lib/ohai/plugins/languages.rb
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author: sawanoboriyu@higanworks.com
4
- # Copyright (C) 2014 HiganWorks LLC
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
-
21
- # Reference from: sm-summary command
22
-
23
- Ohai.plugin(:Joyent) do
24
- provides "joyent"
25
- provides "virtualization/guest_id"
26
- depends "os", "platform", "virtualization"
27
-
28
- def collect_product_file
29
- data = file_read("/etc/product") rescue nil
30
- if data
31
- data.strip.split("\n")
32
- else
33
- []
34
- end
35
- end
36
-
37
- def collect_pkgsrc
38
- data = file_read("/opt/local/etc/pkg_install.conf") rescue nil
39
- if data
40
- /PKG_PATH=(.*)/.match(data)[1] rescue nil
41
- end
42
- end
43
-
44
- def is_smartos?
45
- platform == "smartos"
46
- end
47
-
48
- collect_data do
49
- if is_smartos?
50
- joyent Mash.new
51
-
52
- # copy uuid
53
- joyent[:sm_uuid] = virtualization[:guest_uuid]
54
-
55
- # get zone id unless globalzone
56
- unless joyent[:sm_uuid] == "global"
57
- joyent[:sm_id] = virtualization[:guest_id]
58
- end
59
-
60
- # retrieve image name and pkgsrc
61
- collect_product_file.each do |line|
62
- case line
63
- when /^Image/
64
- sm_image = line.split(" ")
65
- joyent[:sm_image_id] = sm_image[1]
66
- joyent[:sm_image_ver] = sm_image[2]
67
- when /^Base Image/
68
- sm_baseimage = line.split(" ")
69
- joyent[:sm_baseimage_id] = sm_baseimage[2]
70
- joyent[:sm_baseimage_ver] = sm_baseimage[3]
71
- end
72
- end
73
-
74
- ## retrieve pkgsrc
75
- joyent[:sm_pkgsrc] = collect_pkgsrc
76
- end
77
- end
78
- end