ohai 16.6.5 → 16.10.6

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 +6 -11
  3. data/bin/ohai +1 -0
  4. data/lib/ohai.rb +1 -0
  5. data/lib/ohai/application.rb +1 -0
  6. data/lib/ohai/common/dmi.rb +1 -0
  7. data/lib/ohai/config.rb +1 -0
  8. data/lib/ohai/dsl.rb +1 -0
  9. data/lib/ohai/dsl/plugin.rb +2 -1
  10. data/lib/ohai/dsl/plugin/versionvii.rb +1 -2
  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 +1 -0
  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 +37 -11
  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 +1 -0
  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 +1 -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 +1 -0
  41. data/lib/ohai/plugins/bsd/virtualization.rb +2 -1
  42. data/lib/ohai/plugins/c.rb +4 -3
  43. data/lib/ohai/plugins/chef.rb +1 -0
  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 +27 -28
  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 +1 -0
  52. data/lib/ohai/plugins/digital_ocean.rb +3 -1
  53. data/lib/ohai/plugins/dmi.rb +5 -4
  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 +4 -0
  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 +1 -1
  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 +1 -0
  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 +1 -0
  74. data/lib/ohai/plugins/java.rb +1 -0
  75. data/lib/ohai/plugins/kernel.rb +7 -8
  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 +1 -0
  81. data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
  82. data/lib/ohai/plugins/linux/interrupts.rb +1 -0
  83. data/lib/ohai/plugins/linux/ipc.rb +1 -0
  84. data/lib/ohai/plugins/linux/lsb.rb +6 -19
  85. data/lib/ohai/plugins/linux/lspci.rb +1 -1
  86. data/lib/ohai/plugins/linux/machineid.rb +1 -0
  87. data/lib/ohai/plugins/linux/mdadm.rb +1 -0
  88. data/lib/ohai/plugins/linux/memory.rb +37 -36
  89. data/lib/ohai/plugins/linux/network.rb +30 -4
  90. data/lib/ohai/plugins/linux/platform.rb +6 -2
  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 +1 -0
  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 +1 -0
  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 +2 -1
  110. data/lib/ohai/plugins/packages.rb +2 -1
  111. data/lib/ohai/plugins/passwd.rb +2 -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 +2 -1
  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 +1 -0
  127. data/lib/ohai/plugins/softlayer.rb +1 -0
  128. data/lib/ohai/plugins/solaris2/dmi.rb +1 -0
  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 +6 -12
  132. data/lib/ohai/plugins/solaris2/virtualization.rb +3 -3
  133. data/lib/ohai/plugins/ssh_host_key.rb +1 -0
  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 +1 -1
  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 +2 -2
  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 +3 -4
  150. data/lib/ohai/system.rb +1 -0
  151. data/lib/ohai/train_transport.rb +1 -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 +2 -1
  157. metadata +14 -14
  158. data/lib/ohai/plugins/joyent.rb +0 -77
@@ -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>)
@@ -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
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Copyright:: Copyright (c) Chef Software Inc.
3
4
  # License:: Apache License, Version 2.0
@@ -47,7 +48,7 @@ Ohai.plugin(:Docker) do
47
48
  docker[:swarm] = shellout_data["Swarm"]
48
49
  end
49
50
 
50
- collect_data do
51
+ collect_data(:linux, :windows, :darwin) do
51
52
  require "json" unless defined?(JSON)
52
53
 
53
54
  if virtualization[:systems][:docker]
@@ -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
@@ -25,22 +26,22 @@ Ohai.plugin(:Memory) do
25
26
 
26
27
  # /usr/src/sys/sys/vmmeter.h
27
28
  so = shell_out("sysctl -n vm.stats.vm.v_page_size")
28
- memory[:page_size] = so.stdout.split($/)[0]
29
+ memory[:page_size] = so.stdout.strip
29
30
  so = shell_out("sysctl -n vm.stats.vm.v_page_count")
30
- memory[:page_count] = so.stdout.split($/)[0]
31
+ memory[:page_count] = so.stdout.strip
31
32
  memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
32
33
  so = shell_out("sysctl -n vm.stats.vm.v_free_count")
33
- 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
34
35
  so = shell_out("sysctl -n vm.status.vm.v_active_count")
35
- 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
36
37
  so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
37
- 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
38
39
  so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
39
- 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
40
41
  so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
41
- 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
42
43
  so = shell_out("sysctl -n vfs.bufspace")
43
- memory[:buffers] = so.stdout.split($/)[0]
44
+ memory[:buffers] = so.stdout.strip
44
45
 
45
46
  so = shell_out("swapinfo")
46
47
  so.stdout.lines do |line|
@@ -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
@@ -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
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
20
21
  provides "platform", "platform_version", "platform_family"
21
22
 
22
23
  collect_data(:dragonflybsd) do
23
- platform shell_out("uname -s").stdout.split($/)[0].downcase
24
- 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
25
26
  platform_family "dragonflybsd"
26
27
  end
27
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tim Dysinger (<tim@dysinger.net>)
3
4
  # Author:: Benjamin Black (<bb@chef.io>)
@@ -120,6 +121,9 @@ Ohai.plugin(:EC2) do
120
121
  logger.trace("Plugin EC2: looks_like_ec2? == true")
121
122
  ec2 Mash.new
122
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
+
123
127
  # fetch_metadata returns IAM security credentials, including the IAM user's
124
128
  # secret access key. We'd rather not have ohai send this information
125
129
  # to the server. If the instance is associated with an IAM role we grab
@@ -15,7 +15,7 @@
15
15
 
16
16
  Ohai.plugin(:Elixir) do
17
17
  provides "languages/elixir"
18
- depends "languages"
18
+ depends "languages".freeze
19
19
 
20
20
  collect_data do
21
21
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Joe Williams (<joe@joetify.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tim Dysinger (<tim@dysinger.net>)
3
4
  # Author:: Benjamin Black (<bb@chef.io>)
@@ -28,6 +29,8 @@ Ohai.plugin(:Eucalyptus) do
28
29
  provides "eucalyptus"
29
30
  depends "network/interfaces"
30
31
 
32
+ MAC_MATCH = /^[dD]0:0[dD]:/.freeze
33
+
31
34
  # returns the mac address from the collection of all address types
32
35
  def get_mac_address(addresses)
33
36
  detected_addresses = addresses.detect { |address, keypair| keypair == { "family" => "lladdr" } }
@@ -42,7 +45,7 @@ Ohai.plugin(:Eucalyptus) do
42
45
  def has_euca_mac?
43
46
  network[:interfaces].each_value do |iface|
44
47
  mac = get_mac_address(iface[:addresses])
45
- if /^[dD]0:0[dD]:/.match?(mac)
48
+ if MAC_MATCH.match?(mac)
46
49
  logger.trace("Plugin Eucalyptus: has_euca_mac? == true (#{mac})")
47
50
  return true
48
51
  end
@@ -24,7 +24,7 @@
24
24
  #
25
25
 
26
26
  Ohai.plugin(:Filesystem) do
27
- provides "filesystem"
27
+ provides "filesystem".freeze
28
28
 
29
29
  def find_device(name)
30
30
  %w{/dev /dev/mapper}.each do |dir|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Matt Wrock (<matt@mattwrock.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -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
@@ -25,22 +26,22 @@ Ohai.plugin(:Memory) do
25
26
 
26
27
  # /usr/src/sys/sys/vmmeter.h
27
28
  so = shell_out("sysctl -n vm.stats.vm.v_page_size")
28
- memory[:page_size] = so.stdout.split($/)[0]
29
+ memory[:page_size] = so.stdout.strip
29
30
  so = shell_out("sysctl -n vm.stats.vm.v_page_count")
30
- memory[:page_count] = so.stdout.split($/)[0]
31
+ memory[:page_count] = so.stdout.strip
31
32
  memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
32
33
  so = shell_out("sysctl -n vm.stats.vm.v_free_count")
33
- 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
34
35
  so = shell_out("sysctl -n vm.status.vm.v_active_count")
35
- 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
36
37
  so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
37
- 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
38
39
  so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
39
- 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
40
41
  so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
41
- 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
42
43
  so = shell_out("sysctl -n vfs.bufspace")
43
- memory[:buffers] = so.stdout.split($/)[0]
44
+ memory[:buffers] = so.stdout.strip
44
45
 
45
46
  so = shell_out("swapinfo")
46
47
  so.stdout.lines do |line|
@@ -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
@@ -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
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
20
21
  provides "platform", "platform_version", "platform_family"
21
22
 
22
23
  collect_data(:freebsd) do
23
- platform shell_out("uname -s").stdout.split($/)[0].downcase
24
- 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
25
26
  platform_family "freebsd"
26
27
  end
27
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Ranjib Dey (<dey.ranjib@google.com>)
3
4
  # License:: Apache License, Version 2.0
@@ -15,7 +15,7 @@
15
15
 
16
16
  Ohai.plugin(:Go) do
17
17
  provides "languages/go"
18
- depends "languages"
18
+ depends "languages".freeze
19
19
 
20
20
  collect_data do
21
21
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Groovy) do
20
20
  provides "languages/groovy"
21
- depends "languages"
21
+ depends "languages".freeze
22
22
 
23
23
  collect_data do
24
24
 
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: Chris Dituri (<csdituri@gmail.com>)
2
3
  # Copyright:: Copyright (c) 2016 Chris Dituri
3
4
  # License:: Apache License, Version 2.0
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Benjamin Black (<nostromo@gmail.com>)
@@ -37,8 +38,7 @@ Ohai.plugin(:Hostname) do
37
38
  # fqdn and domain may be broken if DNS is broken on the host
38
39
 
39
40
  def from_cmd(cmd)
40
- so = shell_out(cmd)
41
- so.stdout.split($/)[0]
41
+ shell_out(cmd).stdout.strip
42
42
  end
43
43
 
44
44
  # forward and reverse lookup to canonicalize FQDN (hostname -f equivalent)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Caleb Tennis (<caleb.tennis@gmail.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -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.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Benjamin Black (<nostromo@gmail.com>)
@@ -33,7 +34,7 @@ Ohai.plugin(:Kernel) do
33
34
  ["uname -v", :version], ["uname -m", :machine],
34
35
  ["uname -p", :processor]].each do |cmd, property|
35
36
  so = shell_out(cmd)
36
- kernel[property] = so.stdout.split($/)[0]
37
+ kernel[property] = so.stdout.strip
37
38
  end
38
39
  kernel
39
40
  end
@@ -114,7 +115,6 @@ Ohai.plugin(:Kernel) do
114
115
  when 16 then "WIN95"
115
116
  when 17 then "WIN98"
116
117
  when 19 then "WINCE"
117
- else nil
118
118
  end
119
119
  end
120
120
 
@@ -133,7 +133,6 @@ Ohai.plugin(:Kernel) do
133
133
  when 6 then "Appliance PC"
134
134
  when 7 then "Performance Server"
135
135
  when 8 then "Maximum"
136
- else nil
137
136
  end
138
137
  end
139
138
 
@@ -169,7 +168,7 @@ Ohai.plugin(:Kernel) do
169
168
  kernel[:os] = kernel[:name]
170
169
 
171
170
  so = shell_out("sysctl -n hw.optional.x86_64")
172
- if so.stdout.split($/)[0].to_i == 1
171
+ if so.stdout.strip.to_i == 1
173
172
  kernel[:machine] = "x86_64"
174
173
  end
175
174
 
@@ -189,7 +188,7 @@ Ohai.plugin(:Kernel) do
189
188
  kernel[:os] = kernel[:name]
190
189
 
191
190
  so = shell_out("uname -i")
192
- kernel[:ident] = so.stdout.split($/)[0]
191
+ kernel[:ident] = so.stdout.strip
193
192
  so = shell_out("sysctl kern.securelevel")
194
193
  kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
195
194
 
@@ -200,7 +199,7 @@ Ohai.plugin(:Kernel) do
200
199
  kernel init_kernel
201
200
 
202
201
  so = shell_out("uname -o")
203
- kernel[:os] = so.stdout.split($/)[0]
202
+ kernel[:os] = so.stdout.strip
204
203
 
205
204
  modules = Mash.new
206
205
  so = shell_out("env lsmod")
@@ -232,7 +231,7 @@ Ohai.plugin(:Kernel) do
232
231
  kernel init_kernel
233
232
 
234
233
  so = shell_out("uname -s")
235
- kernel[:os] = so.stdout.split($/)[0]
234
+ kernel[:os] = so.stdout.strip
236
235
 
237
236
  so = file_open("/etc/release", &:gets)
238
237
  md = /(?<update>\d.*\d)/.match(so)
@@ -244,7 +243,7 @@ Ohai.plugin(:Kernel) do
244
243
  # EXAMPLE:
245
244
  # Id Loadaddr Size Info Rev Module Name
246
245
  # 6 1180000 4623 1 1 specfs (filesystem for specfs)
247
- module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/
246
+ module_description = /\s*(\d+)\s+([a-f\d]+)\s+([a-f\d]+)\s+(?:[\-\d]+)\s+(?:\d+)\s+(\S+)\s+\((.+)\)$/
248
247
  so.stdout.lines do |line|
249
248
  if ( mod = module_description.match(line) )
250
249
  modules[mod[4]] = { id: mod[1].to_i, loadaddr: mod[2], size: mod[3].to_i(16), description: mod[5] }