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
@@ -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
@@ -121,6 +121,9 @@ Ohai.plugin(:EC2) do
121
121
  logger.trace("Plugin EC2: looks_like_ec2? == true")
122
122
  ec2 Mash.new
123
123
  fetch_metadata.each do |k, v|
124
+ # this includes sensitive data we don't want to store on the node
125
+ next if k == "identity_credentials_ec2_security_credentials_ec2_instance"
126
+
124
127
  # fetch_metadata returns IAM security credentials, including the IAM user's
125
128
  # secret access key. We'd rather not have ohai send this information
126
129
  # to the server. If the instance is associated with an IAM role we grab
@@ -29,7 +29,7 @@ Ohai.plugin(:Eucalyptus) do
29
29
  provides "eucalyptus"
30
30
  depends "network/interfaces"
31
31
 
32
- MAC_MATCH = /^[dD]0:0[dD]:/.freeze
32
+ MAC_MATCH = /^[dD]0:0[dD]:/.freeze unless defined?(MAC_MATCH)
33
33
 
34
34
  # returns the mac address from the collection of all address types
35
35
  def get_mac_address(addresses)
@@ -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
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Author:: Davide Cavalca <dcavalca@fb.com>
4
+ # Copyright:: Copyright (c) 2020 Facebook
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
+ Ohai.plugin(:Grub2) do
21
+ provides "grub2/environment"
22
+ optional true
23
+
24
+ collect_data(:dragonflybsd, :freebsd, :linux, :netbsd) do
25
+ editenv_path = which("grub2-editenv")
26
+ if editenv_path
27
+ editenv_out = shell_out("#{editenv_path} list")
28
+
29
+ grub2 Mash.new unless grub2
30
+ grub2[:environment] ||= Mash.new
31
+
32
+ editenv_out.stdout.each_line do |line|
33
+ key, val = line.split("=", 2)
34
+ grub2[:environment][key] = val.strip
35
+ end
36
+ else
37
+ logger.trace("Plugin Grub2: Could not find grub2-editenv. Skipping plugin.")
38
+ end
39
+ end
40
+ 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
@@ -18,31 +18,38 @@
18
18
  Ohai.plugin(:Linode) do
19
19
  provides "linode"
20
20
 
21
- depends "kernel"
21
+ depends "domain"
22
22
  depends "network/interfaces"
23
23
 
24
- # Checks for matching linode kernel name
24
+ # Checks to see if the node is in the members.linode.com domain
25
25
  #
26
- # Returns true or false
27
- def has_linode_kernel?
28
- if ( kernel_data = kernel )
29
- kernel_data[:release].split("-").last.include?("linode")
30
- end
26
+ # @return [Boolean]
27
+ #
28
+ def has_linode_domain?
29
+ domain&.include?("linode")
30
+ end
31
+
32
+ # Checks for linode mirrors in the apt sources.list file
33
+ #
34
+ # @return [Boolean]
35
+ #
36
+ def has_linode_apt_repos?
37
+ file_exist?("/etc/apt/sources.list") && file_read("/etc/apt/sources.list").include?("linode")
31
38
  end
32
39
 
33
40
  # Identifies the linode cloud by preferring the hint, then
34
41
  #
35
- # Returns true or false
42
+ # @return [Boolean]
43
+ #
36
44
  def looks_like_linode?
37
- hint?("linode") || has_linode_kernel?
45
+ hint?("linode") || has_linode_domain? || has_linode_apt_repos?
38
46
  end
39
47
 
40
- # Names linode ip address
48
+ # Alters linode mash with new interface based on name parameter
41
49
  #
42
- # name - symbol of ohai name (e.g. :public_ip)
43
- # eth - Interface name (e.g. :eth0)
50
+ # @param [Symbol] name Ohai name (e.g. :public_ip)
51
+ # @param [Symbol] eth Interface name (e.g. :eth0)
44
52
  #
45
- # Alters linode mash with new interface based on name parameter
46
53
  def get_ip_address(name, eth)
47
54
  if ( eth_iface = network[:interfaces][eth] )
48
55
  eth_iface[:addresses].each do |key, info|
@@ -51,7 +58,7 @@ Ohai.plugin(:Linode) do
51
58
  end
52
59
  end
53
60
 
54
- collect_data do
61
+ collect_data(:linux) do
55
62
  # Setup linode mash if it is a linode system
56
63
  if looks_like_linode?
57
64
  logger.trace("Plugin Linode: looks_like_linode? == true")