ohai 16.5.4 → 16.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -8
  3. data/bin/ohai +1 -0
  4. data/lib/ohai.rb +1 -0
  5. data/lib/ohai/application.rb +40 -0
  6. data/lib/ohai/common/dmi.rb +8 -3
  7. data/lib/ohai/config.rb +1 -0
  8. data/lib/ohai/dsl.rb +1 -0
  9. data/lib/ohai/dsl/plugin.rb +9 -1
  10. data/lib/ohai/dsl/plugin/versionvii.rb +28 -17
  11. data/lib/ohai/exception.rb +1 -0
  12. data/lib/ohai/hints.rb +1 -0
  13. data/lib/ohai/log.rb +1 -0
  14. data/lib/ohai/mash.rb +1 -0
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -3
  16. data/lib/ohai/mixin/chef_utils_wiring.rb +14 -1
  17. data/lib/ohai/mixin/command.rb +1 -0
  18. data/lib/ohai/mixin/constant_helper.rb +1 -0
  19. data/lib/ohai/mixin/dmi_decode.rb +1 -0
  20. data/lib/ohai/mixin/do_metadata.rb +3 -2
  21. data/lib/ohai/mixin/ec2_metadata.rb +10 -9
  22. data/lib/ohai/mixin/gce_metadata.rb +4 -3
  23. data/lib/ohai/mixin/http_helper.rb +1 -0
  24. data/lib/ohai/mixin/network_helper.rb +1 -0
  25. data/lib/ohai/mixin/os.rb +67 -1
  26. data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
  27. data/lib/ohai/mixin/seconds_to_human.rb +1 -0
  28. data/lib/ohai/mixin/shell_out.rb +1 -0
  29. data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
  30. data/lib/ohai/mixin/string.rb +1 -0
  31. data/lib/ohai/mixin/train_helpers.rb +36 -0
  32. data/lib/ohai/mixin/which.rb +1 -0
  33. data/lib/ohai/plugin_config.rb +1 -0
  34. data/lib/ohai/plugins/aix/kernel.rb +7 -4
  35. data/lib/ohai/plugins/aix/memory.rb +4 -3
  36. data/lib/ohai/plugins/aix/network.rb +51 -58
  37. data/lib/ohai/plugins/aix/platform.rb +3 -2
  38. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  39. data/lib/ohai/plugins/aix/virtualization.rb +6 -6
  40. data/lib/ohai/plugins/azure.rb +25 -4
  41. data/lib/ohai/plugins/bsd/virtualization.rb +3 -2
  42. data/lib/ohai/plugins/c.rb +4 -3
  43. data/lib/ohai/plugins/chef.rb +2 -1
  44. data/lib/ohai/plugins/cloud.rb +2 -1
  45. data/lib/ohai/plugins/command.rb +1 -0
  46. data/lib/ohai/plugins/cpu.rb +31 -32
  47. data/lib/ohai/plugins/darwin/hardware.rb +1 -0
  48. data/lib/ohai/plugins/darwin/memory.rb +2 -3
  49. data/lib/ohai/plugins/darwin/network.rb +8 -9
  50. data/lib/ohai/plugins/darwin/platform.rb +1 -0
  51. data/lib/ohai/plugins/darwin/virtualization.rb +2 -1
  52. data/lib/ohai/plugins/digital_ocean.rb +3 -1
  53. data/lib/ohai/plugins/dmi.rb +6 -5
  54. data/lib/ohai/plugins/docker.rb +2 -1
  55. data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
  56. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  57. data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
  58. data/lib/ohai/plugins/ec2.rb +14 -7
  59. data/lib/ohai/plugins/elixir.rb +1 -1
  60. data/lib/ohai/plugins/erlang.rb +1 -0
  61. data/lib/ohai/plugins/eucalyptus.rb +4 -1
  62. data/lib/ohai/plugins/filesystem.rb +4 -4
  63. data/lib/ohai/plugins/fips.rb +1 -0
  64. data/lib/ohai/plugins/freebsd/memory.rb +9 -8
  65. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  66. data/lib/ohai/plugins/freebsd/platform.rb +3 -2
  67. data/lib/ohai/plugins/gce.rb +3 -2
  68. data/lib/ohai/plugins/go.rb +1 -1
  69. data/lib/ohai/plugins/groovy.rb +1 -1
  70. data/lib/ohai/plugins/grub2.rb +40 -0
  71. data/lib/ohai/plugins/haskell.rb +1 -0
  72. data/lib/ohai/plugins/hostname.rb +2 -2
  73. data/lib/ohai/plugins/init_package.rb +2 -1
  74. data/lib/ohai/plugins/java.rb +1 -0
  75. data/lib/ohai/plugins/kernel.rb +14 -11
  76. data/lib/ohai/plugins/keys.rb +1 -0
  77. data/lib/ohai/plugins/languages.rb +1 -0
  78. data/lib/ohai/plugins/libvirt.rb +4 -3
  79. data/lib/ohai/plugins/linode.rb +22 -14
  80. data/lib/ohai/plugins/linux/block_device.rb +9 -8
  81. data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
  82. data/lib/ohai/plugins/linux/interrupts.rb +4 -3
  83. data/lib/ohai/plugins/linux/ipc.rb +2 -1
  84. data/lib/ohai/plugins/linux/lsb.rb +7 -20
  85. data/lib/ohai/plugins/linux/lspci.rb +1 -1
  86. data/lib/ohai/plugins/linux/machineid.rb +5 -4
  87. data/lib/ohai/plugins/linux/mdadm.rb +3 -2
  88. data/lib/ohai/plugins/linux/memory.rb +38 -37
  89. data/lib/ohai/plugins/linux/network.rb +7 -6
  90. data/lib/ohai/plugins/linux/platform.rb +31 -30
  91. data/lib/ohai/plugins/linux/selinux.rb +1 -0
  92. data/lib/ohai/plugins/linux/sessions.rb +1 -0
  93. data/lib/ohai/plugins/linux/sysctl.rb +1 -0
  94. data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
  95. data/lib/ohai/plugins/linux/virtualization.rb +24 -23
  96. data/lib/ohai/plugins/lua.rb +1 -1
  97. data/lib/ohai/plugins/mono.rb +1 -1
  98. data/lib/ohai/plugins/netbsd/memory.rb +1 -0
  99. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  100. data/lib/ohai/plugins/netbsd/platform.rb +3 -2
  101. data/lib/ohai/plugins/network.rb +2 -1
  102. data/lib/ohai/plugins/nodejs.rb +1 -1
  103. data/lib/ohai/plugins/ohai.rb +1 -0
  104. data/lib/ohai/plugins/ohai_time.rb +2 -1
  105. data/lib/ohai/plugins/openbsd/memory.rb +1 -0
  106. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  107. data/lib/ohai/plugins/openbsd/platform.rb +3 -2
  108. data/lib/ohai/plugins/openstack.rb +1 -0
  109. data/lib/ohai/plugins/os.rb +6 -1
  110. data/lib/ohai/plugins/packages.rb +2 -1
  111. data/lib/ohai/plugins/passwd.rb +58 -1
  112. data/lib/ohai/plugins/perl.rb +1 -1
  113. data/lib/ohai/plugins/php.rb +1 -1
  114. data/lib/ohai/plugins/platform.rb +1 -0
  115. data/lib/ohai/plugins/powershell.rb +1 -1
  116. data/lib/ohai/plugins/ps.rb +1 -0
  117. data/lib/ohai/plugins/python.rb +1 -1
  118. data/lib/ohai/plugins/rackspace.rb +6 -5
  119. data/lib/ohai/plugins/root_group.rb +1 -0
  120. data/lib/ohai/plugins/ruby.rb +3 -2
  121. data/lib/ohai/plugins/rust.rb +1 -1
  122. data/lib/ohai/plugins/scala.rb +1 -0
  123. data/lib/ohai/plugins/scaleway.rb +3 -2
  124. data/lib/ohai/plugins/scsi.rb +1 -1
  125. data/lib/ohai/plugins/shard.rb +1 -1
  126. data/lib/ohai/plugins/shells.rb +3 -2
  127. data/lib/ohai/plugins/softlayer.rb +1 -0
  128. data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
  129. data/lib/ohai/plugins/solaris2/memory.rb +1 -0
  130. data/lib/ohai/plugins/solaris2/network.rb +2 -1
  131. data/lib/ohai/plugins/solaris2/platform.rb +8 -14
  132. data/lib/ohai/plugins/solaris2/virtualization.rb +4 -4
  133. data/lib/ohai/plugins/ssh_host_key.rb +13 -12
  134. data/lib/ohai/plugins/sysconf.rb +1 -0
  135. data/lib/ohai/plugins/timezone.rb +1 -0
  136. data/lib/ohai/plugins/train.rb +35 -0
  137. data/lib/ohai/plugins/uptime.rb +2 -1
  138. data/lib/ohai/plugins/virtualbox.rb +2 -1
  139. data/lib/ohai/plugins/vmware.rb +3 -3
  140. data/lib/ohai/plugins/windows/dmi.rb +1 -0
  141. data/lib/ohai/plugins/windows/drivers.rb +1 -0
  142. data/lib/ohai/plugins/windows/memory.rb +1 -0
  143. data/lib/ohai/plugins/windows/network.rb +2 -1
  144. data/lib/ohai/plugins/windows/platform.rb +1 -0
  145. data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
  146. data/lib/ohai/plugins/windows/virtualization.rb +1 -0
  147. data/lib/ohai/plugins/zpools.rb +5 -3
  148. data/lib/ohai/provides_map.rb +1 -0
  149. data/lib/ohai/runner.rb +7 -4
  150. data/lib/ohai/system.rb +33 -4
  151. data/lib/ohai/train_transport.rb +29 -0
  152. data/lib/ohai/util/file_helper.rb +1 -0
  153. data/lib/ohai/util/ip_helper.rb +2 -1
  154. data/lib/ohai/util/win32.rb +1 -0
  155. data/lib/ohai/version.rb +2 -1
  156. data/ohai.gemspec +3 -1
  157. metadata +21 -4
  158. data/lib/ohai/plugins/joyent.rb +0 -77
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
3
4
  # Author:: Isa Farnik (<isa@chef.io>)
@@ -40,9 +41,9 @@ Ohai.plugin(:Uptime) do
40
41
  when /^\d+-\d/
41
42
  (d, h, m, s) = so.split(/[-:]/)
42
43
  when /^\d+:\d+:\d/
43
- (h, m, s) = so.split(/[:]/)
44
+ (h, m, s) = so.split(":")
44
45
  else
45
- (m, s) = so.split(/[:]/)
46
+ (m, s) = so.split(":")
46
47
  end
47
48
  elapsed_seconds = ((d.to_i * 86400) + (h.to_i * 3600) + (m.to_i * 60) + s.to_i)
48
49
 
@@ -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
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Copyright:: Copyright (c) Chef Software Inc.
2
3
  # License:: Apache License, Version 2.0
3
4
  #
@@ -34,7 +35,7 @@ Ohai.plugin(:Azure) do
34
35
  azure Mash.new
35
36
  azure_metadata_from_hints.each { |k, v| azure[k] = v }
36
37
  azure["metadata"] = parse_metadata
37
- elsif has_waagent? || has_dhcp_option_245?
38
+ elsif has_waagent? || has_dhcp_option_245? || has_reddog_dhcp_domain?
38
39
  logger.trace("Plugin Azure: No hints present, but system appears to be on Azure.")
39
40
  azure Mash.new
40
41
  azure["metadata"] = parse_metadata
@@ -47,7 +48,7 @@ Ohai.plugin(:Azure) do
47
48
  # check for either the waagent or the unknown-245 DHCP option that Azure uses
48
49
  # http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/
49
50
  def has_waagent?
50
- if File.exist?("/usr/sbin/waagent") || Dir.exist?('C:\WindowsAzure')
51
+ if file_exist?("/usr/sbin/waagent") || dir_exist?('C:\WindowsAzure')
51
52
  logger.trace("Plugin Azure: Found waagent used by Azure.")
52
53
  true
53
54
  end
@@ -55,8 +56,8 @@ Ohai.plugin(:Azure) do
55
56
 
56
57
  def has_dhcp_option_245?
57
58
  has_245 = false
58
- if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
59
- File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
59
+ if file_exist?("/var/lib/dhcp/dhclient.eth0.leases")
60
+ file_open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
60
61
  if /unknown-245/.match?(line)
61
62
  logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
62
63
  has_245 = true
@@ -67,6 +68,26 @@ Ohai.plugin(:Azure) do
67
68
  has_245
68
69
  end
69
70
 
71
+ def has_reddog_dhcp_domain?
72
+ tcp_ip_dhcp_domain == "reddog.microsoft.com"
73
+ end
74
+
75
+ def tcp_ip_dhcp_domain
76
+ return unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
77
+
78
+ require "win32/registry" unless defined?(Win32::Registry)
79
+
80
+ begin
81
+ key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters")
82
+ dhcp_domain = key["DhcpDomain"]
83
+ Ohai::Log.trace("Plugin Azure: DhcpDomain registry value is #{dhcp_domain}")
84
+ rescue Win32::Registry::Error
85
+ Ohai::Log.trace("Plugin Azure: DhcpDomain registry value cannot be found")
86
+ end
87
+
88
+ dhcp_domain
89
+ end
90
+
70
91
  # create the basic structure we'll store our data in
71
92
  def initialize_metadata_mash_compute
72
93
  metadata = Mash.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan (btm@loftninjas.org)
3
4
  # Copyright:: Copyright (c) 2009 Bryan McLellan
@@ -30,7 +31,7 @@ Ohai.plugin(:Virtualization) do
30
31
 
31
32
  # detect when in a jail or when a jail is actively running (not in stopped state)
32
33
  so = shell_out("sysctl -n security.jail.jailed")
33
- if so.stdout.split($/)[0].to_i == 1
34
+ if so.stdout.strip.to_i == 1
34
35
  virtualization[:system] = "jail"
35
36
  virtualization[:role] = "guest"
36
37
  virtualization[:systems][:jail] = "guest"
@@ -66,7 +67,7 @@ Ohai.plugin(:Virtualization) do
66
67
  end
67
68
 
68
69
  # Detect bhyve by presence of /dev/vmm
69
- if File.exist?("/dev/vmm")
70
+ if file_exist?("/dev/vmm")
70
71
  virtualization[:system] = "bhyve"
71
72
  virtualization[:role] = "host"
72
73
  virtualization[:systems][:bhyve] = "host"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Doug MacEachern <dougm@vmware.com>
3
4
  # Copyright:: Copyright (c) 2010 VMware, Inc.
@@ -122,12 +123,12 @@ Ohai.plugin(:C) do
122
123
  end
123
124
 
124
125
  def collect_xlc
125
- # ibm xlc
126
-
126
+ # IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
127
+ # Version: 13.01.0003.0000
127
128
  so = shell_out("xlc -qversion")
128
129
  if so.exitstatus == 0 || (so.exitstatus >> 8) == 249
129
130
  description = so.stdout.split($/).first
130
- if description =~ /V(\d+\.\d+)/
131
+ if description =~ /V(\d+\.\d+(.\d+)?)/
131
132
  @c[:xlc] = Mash.new
132
133
  @c[:xlc][:version] = $1
133
134
  @c[:xlc][:description] = description.strip
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tollef Fog Heen <tfheen@err.no>
3
4
  # Copyright:: Copyright (c) 2010 Tollef Fog Heen
@@ -19,7 +20,7 @@
19
20
  Ohai.plugin(:Chef) do
20
21
  provides "chef_packages/chef"
21
22
 
22
- collect_data do
23
+ collect_data(:default, :target) do
23
24
  begin
24
25
  require "chef/version"
25
26
  rescue Gem::LoadError
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Cary Penniman (<cary@rightscale.com>)
3
4
  # License:: Apache License, Version 2.0
@@ -109,7 +110,7 @@ Ohai.plugin(:Cloud) do
109
110
  ipaddr = ""
110
111
  begin
111
112
  ipaddr = IPAddr.new(ip)
112
- 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?
113
114
  rescue ArgumentError => e
114
115
  raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
115
116
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Bryan McLellan (btm@loftninjas.org)
@@ -30,16 +31,14 @@ Ohai.plugin(:CPU) do
30
31
  def parse_bsd_dmesg(&block)
31
32
  cpuinfo = Mash.new
32
33
  cpuinfo["flags"] = []
33
- File.open("/var/run/dmesg.boot").each do |line|
34
+ file_open("/var/run/dmesg.boot").each do |line|
34
35
  case line
35
36
  when /CPU:\s+(.+) \(([\d.]+).+\)/
36
37
  cpuinfo["model_name"] = $1
37
38
  cpuinfo["mhz"] = $2
38
- when /Features=.+<(.+)>/
39
+ when /Features=.+<(.+)>/, /Features2=[a-f\dx]+<(.+)>/
39
40
  cpuinfo["flags"].concat($1.downcase.split(","))
40
41
  # Features2=0x80000001<SSE3,<b31>>
41
- when /Features2=[a-f\dx]+<(.+)>/
42
- cpuinfo["flags"].concat($1.downcase.split(","))
43
42
  else
44
43
  yield(cpuinfo, line)
45
44
  end
@@ -53,7 +52,7 @@ Ohai.plugin(:CPU) do
53
52
  cpu_number = 0
54
53
  current_cpu = nil
55
54
 
56
- File.open("/proc/cpuinfo").each do |line|
55
+ file_open("/proc/cpuinfo").each do |line|
57
56
  case line
58
57
  when /processor\s+:\s(.+)/
59
58
  cpuinfo[$1] = Mash.new
@@ -86,15 +85,15 @@ Ohai.plugin(:CPU) do
86
85
  when /cache size\s+:\s(.+)/
87
86
  cpuinfo[current_cpu]["cache_size"] = $1
88
87
  when /flags\s+:\s(.+)/
89
- cpuinfo[current_cpu]["flags"] = $1.split(" ")
88
+ cpuinfo[current_cpu]["flags"] = $1.split
90
89
  when /BogoMIPS\s+:\s(.+)/
91
90
  cpuinfo[current_cpu]["bogomips"] = $1
92
91
  when /Features\s+:\s(.+)/
93
- cpuinfo[current_cpu]["features"] = $1.split(" ")
92
+ cpuinfo[current_cpu]["features"] = $1.split
94
93
  when /bogomips per cpu:\s(.+)/
95
94
  cpuinfo["bogomips_per_cpu"] = $1
96
95
  when /features\s+:\s(.+)/
97
- cpuinfo["features"] = $1.split(" ")
96
+ cpuinfo["features"] = $1.split
98
97
  when /processor\s(\d):\s(.+)/
99
98
  current_cpu = $1
100
99
  cpu_number += 1
@@ -201,7 +200,7 @@ Ohai.plugin(:CPU) do
201
200
  end
202
201
 
203
202
  so = shell_out("sysctl -n hw.ncpu")
204
- info[:total] = so.stdout.split($/)[0].to_i
203
+ info[:total] = so.stdout.strip.to_i
205
204
  cpu info
206
205
  end
207
206
 
@@ -212,7 +211,7 @@ Ohai.plugin(:CPU) do
212
211
  # to scrape from dmesg.boot is the cpu feature list.
213
212
  # cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
214
213
 
215
- File.open("/var/run/dmesg.boot").each do |line|
214
+ file_open("/var/run/dmesg.boot").each do |line|
216
215
  case line
217
216
  when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
218
217
  cpuinfo["flags"] = $1.downcase.split(",")
@@ -221,7 +220,7 @@ Ohai.plugin(:CPU) do
221
220
 
222
221
  [["hw.model", :model_name], ["hw.ncpu", :total], ["hw.cpuspeed", :mhz]].each do |param, node|
223
222
  so = shell_out("sysctl -n #{param}")
224
- cpuinfo[node] = so.stdout.split($/)[0]
223
+ cpuinfo[node] = so.stdout.strip
225
224
  end
226
225
 
227
226
  cpu cpuinfo
@@ -235,7 +234,7 @@ Ohai.plugin(:CPU) do
235
234
  # available instruction set
236
235
  # cpu0 at mainbus0 apid 0: Intel 686-class, 2134MHz, id 0x6f6
237
236
 
238
- File.open("/var/run/dmesg.boot").each do |line|
237
+ file_open("/var/run/dmesg.boot").each do |line|
239
238
  case line
240
239
  when /cpu[\d\w\s]+:\s([\w\s\-]+),\s+(\w+),/
241
240
  cpuinfo[:model_name] = $1
@@ -279,7 +278,7 @@ Ohai.plugin(:CPU) do
279
278
  when /^machdep.cpu.stepping: (.*)$/
280
279
  cpu[:stepping] = Regexp.last_match[1].to_i
281
280
  when /^machdep.cpu.features: (.*)$/
282
- cpu[:flags] = Regexp.last_match[1].downcase.split(" ")
281
+ cpu[:flags] = Regexp.last_match[1].downcase.split
283
282
  end
284
283
  end
285
284
  end
@@ -349,25 +348,25 @@ Ohai.plugin(:CPU) do
349
348
  key = kv.shift
350
349
  value = kv.join(" ").chomp
351
350
  case key
352
- when /chip_id/
353
- cpu[instance]["socket"] = value
354
- cpusockets.push(value) if cpusockets.index(value).nil?
355
- when /cpu_type/
356
- cpu[instance]["arch"] = value
357
- when /clock_MHz/
358
- cpu[instance]["mhz"] = value
359
- when /brand/
360
- cpu[instance]["model_name"] = value.sub(/\s+/, " ")
361
- when /^state$/
362
- cpu[instance]["state"] = value
363
- cpu["cpustates"][value] ||= 0
364
- cpu["cpustates"][value] += 1
365
- when /core_id/
366
- cpu[instance]["core_id"] = value
367
- # Detect hyperthreading/multithreading
368
- cpucores.push(value) if cpucores.index(value).nil?
369
- when /family|fpu_type|model|stepping|vendor_id/
370
- 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
371
370
  end
372
371
  end
373
372
  cpu["cores"] = cpucores.size
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Nate Walck (<nate.walck@gmail.com>)
3
4
  # Copyright:: Copyright (c) 2016-present Facebook, Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Patrick Collins (<pat@burned.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -43,9 +44,7 @@ Ohai.plugin(:Memory) do
43
44
  megabyte_val = (pages * page_size) / 1024 / 1024.0
44
45
  total_consumed += megabyte_val
45
46
  case match
46
- when "wired down"
47
- active += megabyte_val.to_i
48
- when "active"
47
+ when "wired down", "active"
49
48
  active += megabyte_val.to_i
50
49
  when "inactive"
51
50
  inactive += megabyte_val.to_i
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Benjamin Black (<bb@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -26,7 +27,7 @@ Ohai.plugin(:Network) do
26
27
 
27
28
  def parse_media(media_string)
28
29
  media = {}
29
- line_array = media_string.split(" ")
30
+ line_array = media_string.split
30
31
 
31
32
  0.upto(line_array.length - 1) do |i|
32
33
  unless line_array[i].eql?("none")
@@ -40,11 +41,9 @@ Ohai.plugin(:Network) do
40
41
  else
41
42
  media[line_array[i]]["options"] = $1.split(",")
42
43
  end
43
- else
44
- if line_array[i].eql?("autoselect")
45
- media["autoselect"] = {} unless media.key?("autoselect")
46
- media["autoselect"]["options"] = []
47
- end
44
+ elsif line_array[i].eql?("autoselect")
45
+ media["autoselect"] = {} unless media.key?("autoselect")
46
+ media["autoselect"]["options"] = []
48
47
  end
49
48
  else
50
49
  media["none"] = { "options" => [] }
@@ -144,15 +143,15 @@ Ohai.plugin(:Network) do
144
143
  end
145
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})/
146
145
  iface[cint][:addresses] ||= Mash.new
147
- 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 }
148
147
  end
149
148
  if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*/
150
149
  iface[cint][:addresses] ||= Mash.new
151
- 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) }
152
151
  end
153
152
  if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
154
153
  iface[cint][:addresses] ||= Mash.new
155
- 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) }
156
155
  end
157
156
  if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
158
157
  iface[cint][:media] ||= Mash.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Pavel Yudin (<pyudin@parallels.com>)
3
4
  # Author:: Tim Smith (<tsmith@chef.io>)
@@ -35,7 +36,7 @@ Ohai.plugin(:Virtualization) do
35
36
  end
36
37
 
37
38
  def fusion_exists?
38
- ::File.exist?("/Applications/VMware\ Fusion.app/")
39
+ file_exist?("/Applications/VMware\ Fusion.app/")
39
40
  end
40
41
 
41
42
  def docker_exists?
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Dylan Page (<dpage@digitalocean.com>)
3
4
  # Author:: Stafford Brunk (<stafford.brunk@gmail.com>)
@@ -48,7 +49,8 @@ Ohai.plugin(:DigitalOcean) do
48
49
  false
49
50
  end
50
51
 
51
- collect_data do
52
+ # linux and freebsd is all digitalocean supports
53
+ collect_data(:linux, :freebsd) do
52
54
  if looks_like_digital_ocean?
53
55
  logger.trace("Plugin Digitalocean: looks_like_digital_ocean? == true")
54
56
  digital_ocean Mash.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Kurt Yoder (ktyopscode@yoderhome.com)
3
4
  # Copyright:: Copyright (c) 2010 Kurt Yoder
@@ -76,7 +77,7 @@ Ohai.plugin(:DMI) do
76
77
  dmi[:table_location] = table_location[1]
77
78
 
78
79
  elsif ( handle = handle_line.match(line) )
79
- unless Ohai::Common::DMI.whitelisted_ids.include?(handle[2].to_i)
80
+ unless Ohai::Common::DMI.allowlisted_ids.include?(handle[2].to_i)
80
81
  dmi_record = nil
81
82
  next
82
83
  end
@@ -92,14 +93,14 @@ Ohai.plugin(:DMI) do
92
93
  field = nil
93
94
 
94
95
  elsif ( type = type_line.match(line) )
95
- if dmi_record .nil?
96
+ if dmi_record.nil?
96
97
  logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
97
98
  next
98
99
  end
99
100
  dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = type[1]
100
101
 
101
102
  elsif ( data = data_line.match(line) )
102
- if dmi_record .nil?
103
+ if dmi_record.nil?
103
104
  logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
104
105
  next
105
106
  end
@@ -107,11 +108,11 @@ Ohai.plugin(:DMI) do
107
108
  field = data[1]
108
109
 
109
110
  elsif ( extended_data = extended_data_line.match(line) )
110
- if dmi_record .nil?
111
+ if dmi_record.nil?
111
112
  logger.trace("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
112
113
  next
113
114
  end
114
- if field .nil?
115
+ if field.nil?
115
116
  logger.trace("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
116
117
  next
117
118
  end