ohai 16.7.18 → 16.10.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  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 +35 -10
  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/ec2.rb +3 -0
  24. data/lib/ohai/plugins/eucalyptus.rb +1 -1
  25. data/lib/ohai/plugins/freebsd/memory.rb +8 -8
  26. data/lib/ohai/plugins/freebsd/platform.rb +2 -2
  27. data/lib/ohai/plugins/grub2.rb +40 -0
  28. data/lib/ohai/plugins/hostname.rb +1 -2
  29. data/lib/ohai/plugins/kernel.rb +5 -7
  30. data/lib/ohai/plugins/libvirt.rb +3 -3
  31. data/lib/ohai/plugins/linode.rb +21 -14
  32. data/lib/ohai/plugins/linux/lspci.rb +0 -1
  33. data/lib/ohai/plugins/linux/network.rb +29 -4
  34. data/lib/ohai/plugins/linux/platform.rb +4 -1
  35. data/lib/ohai/plugins/netbsd/platform.rb +2 -2
  36. data/lib/ohai/plugins/network.rb +1 -1
  37. data/lib/ohai/plugins/openbsd/platform.rb +2 -2
  38. data/lib/ohai/plugins/os.rb +1 -1
  39. data/lib/ohai/plugins/packages.rb +1 -1
  40. data/lib/ohai/plugins/passwd.rb +1 -1
  41. data/lib/ohai/plugins/rackspace.rb +4 -4
  42. data/lib/ohai/plugins/scaleway.rb +1 -1
  43. data/lib/ohai/plugins/scsi.rb +0 -1
  44. data/lib/ohai/plugins/solaris2/network.rb +1 -1
  45. data/lib/ohai/plugins/solaris2/virtualization.rb +1 -2
  46. data/lib/ohai/plugins/train.rb +0 -1
  47. data/lib/ohai/plugins/uptime.rb +1 -1
  48. data/lib/ohai/plugins/virtualbox.rb +1 -1
  49. data/lib/ohai/plugins/vmware.rb +1 -2
  50. data/lib/ohai/plugins/zpools.rb +0 -1
  51. data/lib/ohai/util/ip_helper.rb +1 -1
  52. data/lib/ohai/version.rb +1 -1
  53. data/ohai.gemspec +1 -1
  54. metadata +14 -14
  55. 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: c661e4c6ab76f9c2e8e8fb2ae7d287caa31d81c1b3149f689c8d00853d392488
4
+ data.tar.gz: e48961c413eafcbb0af751b34b9fb7dd805ae2e7d0650dcecbf1cf2b8adbe691
5
5
  SHA512:
6
- metadata.gz: 9198da99387e9dfcc99350cba0a7e1e95f2a1e1de7fecf4ecf76b311d38352214b1f76179aa20bcd42f0017f7a8c5d9e73f251c016eb9e8c83d4e0be234da0a8
7
- data.tar.gz: bbd44815894afe658ab51d54088589f4c66d62a5099a81c93c48801a8aa454f9c8af38498b667a2fe51088889145a5b05cf376860459c4889453a088c066f9f5
6
+ metadata.gz: 72849d5d2c327b4994aa073d85556bbd3b2a0ef200646593a2f62cc283c39ee435b99a81c87f56b31583dbf99e174a365d08c634ee91863d0a19b1c0d261f40e
7
+ data.tar.gz: c5104a84a7067fff9dde9d5e456107e300bd5e6f42dd3d42684ac491cdbaf511fb9c31741cf4763c0dbfeacc08008dc9f517568c31d1873ea7228b32bf33bcde
data/Gemfile CHANGED
@@ -4,19 +4,19 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  # pull these gems from master of chef/chef so that we're testing against what we will release
7
- gem "chef-config", git: "https://github.com/chef/chef", glob: "chef-config/chef-config.gemspec"
8
- gem "chef-utils", git: "https://github.com/chef/chef", glob: "chef-utils/chef-utils.gemspec"
7
+ gem "chef-config", git: "https://github.com/chef/chef", branch: "chef-16", glob: "chef-config/chef-config.gemspec"
8
+ gem "chef-utils", git: "https://github.com/chef/chef", branch: "chef-16", glob: "chef-utils/chef-utils.gemspec"
9
9
 
10
10
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
11
11
  group :development do
12
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
12
+ gem "chefstyle", "1.6.2"
13
13
  gem "ipaddr_extensions"
14
14
  gem "rake", ">= 10.1.0"
15
15
  gem "rspec-collection_matchers", "~> 1.0"
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.2"
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,23 +42,31 @@ 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
47
+ 2016-11-30 2018-08-17 2018-11-29 2019-10-01 2020-08-24 2020-11-01 }.freeze
47
48
  EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze
48
49
  EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze
49
50
  EC2_JSON_DIR ||= %w{iam}.freeze
50
51
 
52
+ #
53
+ # The latest metadata version in EC2_SUPPORTED_VERSIONS that this instance supports
54
+ # in AWS supported metadata versions are determined at instance start so we need to be
55
+ # cautious here in case an instance has been running for a long time
56
+ #
57
+ # @return [String] the version
58
+ #
51
59
  def best_api_version
52
60
  @api_version ||= begin
53
61
  logger.trace("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release")
54
- response = http_client.get("/")
62
+ response = http_client.get("/", { 'X-aws-ec2-metadata-token': v2_token })
55
63
  if response.code == "404"
56
64
  logger.trace("Mixin EC2: Received HTTP 404 from metadata server while determining API version, assuming 'latest'")
57
65
  return "latest"
58
66
  elsif response.code != "200"
59
67
  raise "Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)"
60
68
  end
61
- # Note: Sorting the list of versions may have unintended consequences in
69
+ # NOTE: Sorting the list of versions may have unintended consequences in
62
70
  # non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12.
63
71
  versions = response.body.split("\n").sort
64
72
  until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)
@@ -84,6 +92,23 @@ module Ohai
84
92
  end
85
93
  end
86
94
 
95
+ #
96
+ # Fetch an API token for use querying AWS IMDSv2 or return nil if no token if found
97
+ # AWS like systems (think OpenStack) will not respond with a token here
98
+ #
99
+ # @return [NilClass, String] API token or nil
100
+ #
101
+ def v2_token
102
+ @v2_token ||= begin
103
+ request = http_client.put("/latest/api/token", nil, { 'X-aws-ec2-metadata-token-ttl-seconds': "60" })
104
+ if request.code == "404" # not on AWS
105
+ nil
106
+ else
107
+ request.body
108
+ end
109
+ end
110
+ end
111
+
87
112
  # Get metadata for a given path and API version
88
113
  #
89
114
  # Typically, a 200 response is expected for valid metadata.
@@ -93,7 +118,7 @@ module Ohai
93
118
  def metadata_get(id, api_version)
94
119
  path = "/#{api_version}/meta-data/#{id}"
95
120
  logger.trace("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}#{path}")
96
- response = http_client.get(path)
121
+ response = http_client.get(path, { 'X-aws-ec2-metadata-token': v2_token })
97
122
  case response.code
98
123
  when "200"
99
124
  response.body
@@ -119,7 +144,7 @@ module Ohai
119
144
  else
120
145
  metadata_get(key, best_api_version)
121
146
  end
122
- elsif (not key.eql?(id)) && (not key.eql?("/"))
147
+ elsif (!key.eql?(id)) && (!key.eql?("/"))
123
148
  name = key[0..-2]
124
149
  sym = metadata_key(name)
125
150
  if EC2_ARRAY_DIR.include?(name)
@@ -144,7 +169,7 @@ module Ohai
144
169
  if key[-1..-1] != "/"
145
170
  retr_meta = metadata_get("#{id}#{key}", api_version)
146
171
  metadata[metadata_key(key)] = retr_meta || ""
147
- elsif not key.eql?("/")
172
+ elsif !key.eql?("/")
148
173
  metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version)
149
174
  end
150
175
  end
@@ -164,7 +189,7 @@ module Ohai
164
189
  json = String(data)
165
190
  parser = FFI_Yajl::Parser.new
166
191
  metadata[metadata_key(key)] = parser.parse(json)
167
- elsif not key.eql?("/")
192
+ elsif !key.eql?("/")
168
193
  metadata[key[0..-2]] = fetch_json_dir_metadata("#{id}#{key}", api_version)
169
194
  end
170
195
  end
@@ -174,13 +199,13 @@ module Ohai
174
199
 
175
200
  def fetch_userdata
176
201
  logger.trace("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/#{best_api_version}/user-data/")
177
- response = http_client.get("/#{best_api_version}/user-data/")
202
+ response = http_client.get("/#{best_api_version}/user-data/", { 'X-aws-ec2-metadata-token': v2_token })
178
203
  response.code == "200" ? response.body : nil
179
204
  end
180
205
 
181
206
  def fetch_dynamic_data
182
207
  @fetch_dynamic_data ||= begin
183
- response = http_client.get("/#{best_api_version}/dynamic/instance-identity/document/")
208
+ response = http_client.get("/#{best_api_version}/dynamic/instance-identity/document/", { 'X-aws-ec2-metadata-token': v2_token })
184
209
 
185
210
  if json?(response.body) && response.code == "200"
186
211
  FFI_Yajl::Parser.parse(response.body)
@@ -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