ohai 8.26.1 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -4
  3. data/Rakefile +14 -0
  4. data/lib/ohai/application.rb +1 -0
  5. data/lib/ohai/config.rb +2 -88
  6. data/lib/ohai/dsl/plugin.rb +0 -4
  7. data/lib/ohai/exception.rb +0 -1
  8. data/lib/ohai/loader.rb +11 -2
  9. data/lib/ohai/log.rb +3 -1
  10. data/lib/ohai/mixin/command.rb +1 -318
  11. data/lib/ohai/mixin/do_metadata.rb +47 -0
  12. data/lib/ohai/mixin/ec2_metadata.rb +2 -29
  13. data/lib/ohai/mixin/gce_metadata.rb +0 -37
  14. data/lib/ohai/mixin/http_helper.rb +56 -0
  15. data/lib/ohai/mixin/network_constants.rb +0 -5
  16. data/lib/ohai/plugins/cloud.rb +144 -157
  17. data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
  18. data/lib/ohai/plugins/digital_ocean.rb +24 -42
  19. data/lib/ohai/plugins/dmi.rb +81 -77
  20. data/lib/ohai/plugins/ec2.rb +33 -60
  21. data/lib/ohai/plugins/gce.rb +3 -1
  22. data/lib/ohai/plugins/hostname.rb +1 -16
  23. data/lib/ohai/plugins/linux/filesystem.rb +130 -81
  24. data/lib/ohai/plugins/linux/mdadm.rb +3 -45
  25. data/lib/ohai/plugins/linux/network.rb +1 -26
  26. data/lib/ohai/plugins/linux/platform.rb +4 -2
  27. data/lib/ohai/plugins/linux/virtualization.rb +1 -5
  28. data/lib/ohai/plugins/scala.rb +1 -13
  29. data/lib/ohai/plugins/solaris2/network.rb +1 -2
  30. data/lib/ohai/plugins/uptime.rb +0 -9
  31. data/lib/ohai/plugins/windows/cpu.rb +2 -1
  32. data/lib/ohai/plugins/windows/network.rb +1 -1
  33. data/lib/ohai/runner.rb +0 -5
  34. data/lib/ohai/system.rb +38 -8
  35. data/lib/ohai/version.rb +2 -2
  36. data/ohai.gemspec +1 -1
  37. data/spec/functional/application_spec.rb +0 -40
  38. data/spec/functional/plugins/powershell_spec.rb +1 -1
  39. data/spec/functional/plugins/root_group_spec.rb +1 -1
  40. data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
  41. data/spec/ohai_spec.rb +1 -1
  42. data/spec/support/integration_helper.rb +17 -0
  43. data/spec/support/platform_helpers.rb +17 -0
  44. data/spec/unit/application_spec.rb +0 -1
  45. data/spec/unit/config_spec.rb +0 -111
  46. data/spec/unit/dsl/plugin_spec.rb +1 -1
  47. data/spec/unit/hints_spec.rb +1 -1
  48. data/spec/unit/loader_spec.rb +26 -1
  49. data/spec/unit/mixin/command_spec.rb +1 -69
  50. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  51. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  52. data/spec/unit/plugin_config_spec.rb +0 -1
  53. data/spec/unit/plugins/abort_spec.rb +1 -1
  54. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  55. data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
  56. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  57. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  58. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  59. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  60. data/spec/unit/plugins/aix/os_spec.rb +1 -1
  61. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  62. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  63. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  64. data/spec/unit/plugins/azure_spec.rb +1 -1
  65. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  66. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  67. data/spec/unit/plugins/c_spec.rb +1 -1
  68. data/spec/unit/plugins/chef_spec.rb +1 -2
  69. data/spec/unit/plugins/cloud_spec.rb +210 -50
  70. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
  71. data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
  72. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  73. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  74. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  75. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  76. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  77. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  78. data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
  79. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  80. data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
  81. data/spec/unit/plugins/dmi_spec.rb +1 -1
  82. data/spec/unit/plugins/ec2_spec.rb +10 -62
  83. data/spec/unit/plugins/elixir_spec.rb +1 -1
  84. data/spec/unit/plugins/erlang_spec.rb +1 -1
  85. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  86. data/spec/unit/plugins/fail_spec.rb +1 -1
  87. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  88. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  89. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  90. data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
  91. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  92. data/spec/unit/plugins/gce_spec.rb +1 -1
  93. data/spec/unit/plugins/go_spec.rb +1 -1
  94. data/spec/unit/plugins/groovy_spec.rb +1 -1
  95. data/spec/unit/plugins/haskell_spec.rb +1 -1
  96. data/spec/unit/plugins/hostname_spec.rb +16 -41
  97. data/spec/unit/plugins/init_package_spec.rb +1 -1
  98. data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
  99. data/spec/unit/plugins/java_spec.rb +1 -1
  100. data/spec/unit/plugins/joyent_spec.rb +17 -1
  101. data/spec/unit/plugins/kernel_spec.rb +1 -1
  102. data/spec/unit/plugins/linode_spec.rb +1 -1
  103. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  104. data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
  105. data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
  106. data/spec/unit/plugins/linux/fips_spec.rb +1 -1
  107. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  108. data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
  109. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
  113. data/spec/unit/plugins/linux/memory_spec.rb +1 -1
  114. data/spec/unit/plugins/linux/network_spec.rb +3 -44
  115. data/spec/unit/plugins/linux/platform_spec.rb +4 -4
  116. data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
  117. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  118. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
  119. data/spec/unit/plugins/lua_spec.rb +1 -1
  120. data/spec/unit/plugins/mono_spec.rb +1 -1
  121. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  122. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  123. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  124. data/spec/unit/plugins/network_spec.rb +1 -1
  125. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  126. data/spec/unit/plugins/ohai_spec.rb +1 -1
  127. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  128. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  129. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  130. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  131. data/spec/unit/plugins/openstack_spec.rb +2 -3
  132. data/spec/unit/plugins/os_spec.rb +1 -1
  133. data/spec/unit/plugins/packages_spec.rb +1 -1
  134. data/spec/unit/plugins/passwd_spec.rb +17 -1
  135. data/spec/unit/plugins/perl_spec.rb +1 -1
  136. data/spec/unit/plugins/php_spec.rb +1 -1
  137. data/spec/unit/plugins/platform_spec.rb +1 -1
  138. data/spec/unit/plugins/powershell_spec.rb +1 -1
  139. data/spec/unit/plugins/python_spec.rb +1 -1
  140. data/spec/unit/plugins/rackspace_spec.rb +1 -2
  141. data/spec/unit/plugins/root_group_spec.rb +2 -2
  142. data/spec/unit/plugins/ruby_spec.rb +1 -1
  143. data/spec/unit/plugins/rust_spec.rb +1 -1
  144. data/spec/unit/plugins/scala_spec.rb +3 -37
  145. data/spec/unit/plugins/shard_spec.rb +1 -1
  146. data/spec/unit/plugins/shells_spec.rb +1 -1
  147. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  148. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  149. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  150. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  151. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  152. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  153. data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
  154. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  155. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  156. data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
  157. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  158. data/spec/unit/plugins/sysconf_spec.rb +1 -1
  159. data/spec/unit/plugins/timezone_spec.rb +1 -1
  160. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  161. data/spec/unit/plugins/vmware_spec.rb +2 -1
  162. data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
  163. data/spec/unit/plugins/windows/fips_spec.rb +1 -1
  164. data/spec/unit/plugins/windows/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  166. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  167. data/spec/unit/provides_map_spec.rb +1 -1
  168. data/spec/unit/runner_spec.rb +1 -1
  169. data/spec/unit/system_spec.rb +68 -76
  170. data/spec/unit/util/file_helper_spec.rb +1 -1
  171. data/spec/unit/util/ip_helper_spec.rb +1 -1
  172. metadata +6 -20
  173. data/lib/ohai/plugins/cloud_v2.rb +0 -315
  174. data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
  175. data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
  176. data/lib/ohai/plugins/linux/lspci.rb +0 -76
  177. data/lib/ohai/plugins/network_listeners.rb +0 -60
  178. data/lib/ohai/plugins/sigar/cpu.rb +0 -44
  179. data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
  180. data/lib/ohai/plugins/sigar/memory.rb +0 -39
  181. data/lib/ohai/plugins/sigar/network.rb +0 -168
  182. data/lib/ohai/plugins/sigar/network_route.rb +0 -64
  183. data/lib/ohai/plugins/sigar/platform.rb +0 -30
  184. data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
  185. data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
  186. data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
  187. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  188. data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -15,9 +15,11 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "ohai/mixin/gce_metadata"
18
+ require "ohai/mixin/http_helper"
18
19
 
19
20
  Ohai.plugin(:GCE) do
20
21
  include Ohai::Mixin::GCEMetadata
22
+ include Ohai::Mixin::HttpHelper
21
23
 
22
24
  provides "gce"
23
25
 
@@ -27,7 +29,7 @@ Ohai.plugin(:GCE) do
27
29
  # true:: If gce metadata server found
28
30
  # false:: Otherwise
29
31
  def has_gce_metadata?
30
- can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
32
+ can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
31
33
  end
32
34
 
33
35
  # Identifies gce
@@ -76,24 +76,9 @@ Ohai.plugin(:Hostname) do
76
76
  end
77
77
  end
78
78
 
79
- def get_fqdn_from_sigar
80
- require "sigar"
81
- sigar = Sigar.new
82
- sigar.fqdn
83
- end
84
-
85
- def sigar_is_available?
86
- begin
87
- require "sigar"
88
- true
89
- rescue LoadError
90
- false
91
- end
92
- end
93
-
94
79
  collect_data(:hpux, :default) do
95
80
  machinename from_cmd("hostname")
96
- fqdn sigar_is_available? ? get_fqdn_from_sigar : resolve_fqdn
81
+ fqdn resolve_fqdn
97
82
  collect_hostname
98
83
  collect_domain
99
84
  end
@@ -1,6 +1,8 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
2
+ # Author:: Phil Dibowitz <phil@ipom.com>
3
+ # Author:: Adam Jacob <adam@chef.io>
4
+ # Copyright:: Copyright (c) 2008-2017 Chef Software, Inc.
5
+ # Copyright:: Copyright (c) 2015 Facebook, Inc.
4
6
  # License:: Apache License, Version 2.0
5
7
  #
6
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,124 +20,160 @@
18
20
 
19
21
  Ohai.plugin(:Filesystem) do
20
22
  provides "filesystem"
23
+ provides "filesystem2"
21
24
 
22
- def get_blk_cmd(attr, have_lsblk)
23
- if have_lsblk
24
- attr = "FSTYPE" if attr == "TYPE"
25
- "lsblk -P -n -o NAME,#{attr}"
26
- else
27
- "blkid -s #{attr}"
25
+ def find_device(name)
26
+ %w{/dev /dev/mapper}.each do |dir|
27
+ path = File.join(dir, name)
28
+ return path if File.exist?(path)
28
29
  end
30
+ name
29
31
  end
30
32
 
31
- def get_blk_regex(attr, have_lsblk)
33
+ def parse_line(line, have_lsblk)
32
34
  if have_lsblk
33
- attr = "FSTYPE" if attr == "TYPE"
34
- /^NAME="(\S+).*?" #{attr}="(\S+)"/
35
+ regex = /NAME="(\S+).*?" UUID="(\S*)" LABEL="(\S*)" FSTYPE="(\S*)"/
36
+ if line =~ regex
37
+ dev = $1
38
+ dev = find_device(dev) unless dev.start_with?("/")
39
+ uuid = $2
40
+ label = $3
41
+ fs_type = $4
42
+ return { :dev => dev, :uuid => uuid, :label => label, :fs_type => fs_type }
43
+ end
35
44
  else
36
- /^(\S+): #{attr}="(\S+)"/
45
+ bits = line.split
46
+ dev = bits.shift.split(":")[0]
47
+ f = { :dev => dev }
48
+ bits.each do |keyval|
49
+ if keyval =~ /(\S+)="(\S+)"/
50
+ key = $1.downcase.to_sym
51
+ key = :fs_type if key == :type
52
+ f[key] = $2
53
+ end
54
+ end
55
+ return f
37
56
  end
57
+ return nil
38
58
  end
39
59
 
40
- def find_device(name)
41
- %w{/dev /dev/mapper}.each do |dir|
42
- path = File.join(dir, name)
43
- return path if File.exist?(path)
60
+ def generate_device_view(fs)
61
+ view = {}
62
+ fs.each_value do |entry|
63
+ view[entry[:device]] = Mash.new unless view[entry[:device]]
64
+ entry.each do |key, val|
65
+ next if %w{device mount}.include?(key)
66
+ view[entry[:device]][key] = val
67
+ end
68
+ view[entry[:device]][:mounts] ||= []
69
+ if entry[:mount]
70
+ view[entry[:device]][:mounts] << entry[:mount]
71
+ end
44
72
  end
45
- name
73
+ view
74
+ end
75
+
76
+ def generate_mountpoint_view(fs)
77
+ view = {}
78
+ fs.each_value do |entry|
79
+ next unless entry[:mount]
80
+ view[entry[:mount]] = Mash.new unless view[entry[:mount]]
81
+ entry.each do |key, val|
82
+ next if %w{mount device}.include?(key)
83
+ view[entry[:mount]][key] = val
84
+ end
85
+ view[entry[:mount]][:devices] ||= []
86
+ if entry[:device]
87
+ view[entry[:mount]][:devices] << entry[:device]
88
+ end
89
+ end
90
+ view
46
91
  end
47
92
 
48
93
  collect_data(:linux) do
49
94
  fs = Mash.new
50
- have_lsblk = File.executable?("/bin/lsblk")
51
95
 
52
96
  # Grab filesystem data from df
53
97
  so = shell_out("df -P")
54
- so.stdout.lines do |line|
98
+ so.stdout.each_line do |line|
55
99
  case line
56
100
  when /^Filesystem\s+1024-blocks/
57
101
  next
58
102
  when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
59
- filesystem = $1
60
- fs[filesystem] = Mash.new
61
- fs[filesystem][:kb_size] = $2
62
- fs[filesystem][:kb_used] = $3
63
- fs[filesystem][:kb_available] = $4
64
- fs[filesystem][:percent_used] = $5
65
- fs[filesystem][:mount] = $6
103
+ key = "#{$1},#{$6}"
104
+ fs[key] = Mash.new
105
+ fs[key][:device] = $1
106
+ fs[key][:kb_size] = $2
107
+ fs[key][:kb_used] = $3
108
+ fs[key][:kb_available] = $4
109
+ fs[key][:percent_used] = $5
110
+ fs[key][:mount] = $6
66
111
  end
67
112
  end
68
113
 
69
114
  # Grab filesystem inode data from df
70
115
  so = shell_out("df -iP")
71
- so.stdout.lines do |line|
116
+ so.stdout.each_line do |line|
72
117
  case line
73
118
  when /^Filesystem\s+Inodes/
74
119
  next
75
120
  when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
76
- filesystem = $1
77
- fs[filesystem] ||= Mash.new
78
- fs[filesystem][:total_inodes] = $2
79
- fs[filesystem][:inodes_used] = $3
80
- fs[filesystem][:inodes_available] = $4
81
- fs[filesystem][:inodes_percent_used] = $5
82
- fs[filesystem][:mount] = $6
121
+ key = "#{$1},#{$6}"
122
+ fs[key] ||= Mash.new
123
+ fs[key][:device] = $1
124
+ fs[key][:total_inodes] = $2
125
+ fs[key][:inodes_used] = $3
126
+ fs[key][:inodes_available] = $4
127
+ fs[key][:inodes_percent_used] = $5
128
+ fs[key][:mount] = $6
83
129
  end
84
130
  end
85
131
 
86
132
  # Grab mount information from /bin/mount
87
133
  so = shell_out("mount")
88
- so.stdout.lines do |line|
134
+ so.stdout.each_line do |line|
89
135
  if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
90
- filesystem = $1
91
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
92
- fs[filesystem][:mount] = $2
93
- fs[filesystem][:fs_type] = $3
94
- fs[filesystem][:mount_options] = $4.split(",")
136
+ key = "#{$1},#{$2}"
137
+ fs[key] = Mash.new unless fs.has_key?(key)
138
+ fs[key][:device] = $1
139
+ fs[key][:mount] = $2
140
+ fs[key][:fs_type] = $3
141
+ fs[key][:mount_options] = $4.split(",")
95
142
  end
96
143
  end
97
144
 
98
145
  have_lsblk = File.exist?("/bin/lsblk")
146
+ if have_lsblk
147
+ cmd = "lsblk -n -P -o NAME,UUID,LABEL,FSTYPE"
148
+ else
149
+ # CentOS5 and other platforms don't have lsblk
150
+ cmd = "blkid"
151
+ end
99
152
 
100
- # Gather more filesystem types via libuuid, even devices that's aren't mounted
101
- cmd = get_blk_cmd("TYPE", have_lsblk)
102
- regex = get_blk_regex("TYPE", have_lsblk)
103
153
  so = shell_out(cmd)
104
- so.stdout.lines do |line|
105
- if line =~ regex
106
- filesystem = $1
107
- type = $2
108
- filesystem = find_device(filesystem) unless filesystem.start_with?("/")
109
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
110
- fs[filesystem][:fs_type] = type
154
+ so.stdout.each_line do |line|
155
+ parsed = parse_line(line, have_lsblk)
156
+ next if parsed.nil?
157
+ # lsblk lists each device once, so we need to update all entries
158
+ # in the hash that are related to this device
159
+ keys_to_update = []
160
+ fs.each_key do |key|
161
+ keys_to_update << key if key.start_with?("#{parsed[:dev]},")
111
162
  end
112
- end
113
163
 
114
- # Gather device UUIDs via libuuid
115
- cmd = get_blk_cmd("UUID", have_lsblk)
116
- regex = get_blk_regex("UUID", have_lsblk)
117
- so = shell_out(cmd)
118
- so.stdout.lines do |line|
119
- if line =~ regex
120
- filesystem = $1
121
- uuid = $2
122
- filesystem = find_device(filesystem) unless filesystem.start_with?("/")
123
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
124
- fs[filesystem][:uuid] = uuid
164
+ if keys_to_update.empty?
165
+ key = "#{parsed[:dev]},"
166
+ fs[key] = Mash.new
167
+ fs[key][:device] = parsed[:dev]
168
+ keys_to_update << key
125
169
  end
126
- end
127
170
 
128
- # Gather device labels via libuuid
129
- cmd = get_blk_cmd("LABEL", have_lsblk)
130
- regex = get_blk_regex("LABEL", have_lsblk)
131
- so = shell_out(cmd)
132
- so.stdout.lines do |line|
133
- if line =~ regex
134
- filesystem = $1
135
- label = $2
136
- filesystem = find_device(filesystem) unless filesystem.start_with?("/")
137
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
138
- fs[filesystem][:label] = label
171
+ keys_to_update.each do |key|
172
+ [:fs_type, :uuid, :label].each do |subkey|
173
+ if parsed[subkey] && !parsed[subkey].empty?
174
+ fs[key][subkey] = parsed[subkey]
175
+ end
176
+ end
139
177
  end
140
178
  end
141
179
 
@@ -160,17 +198,28 @@ Ohai.plugin(:Filesystem) do
160
198
  f.close
161
199
  mounts.each_line do |line|
162
200
  if line =~ /^(\S+) (\S+) (\S+) (\S+) \S+ \S+$/
163
- filesystem = $1
164
- next if fs.has_key?(filesystem)
165
- fs[filesystem] = Mash.new
166
- fs[filesystem][:mount] = $2
167
- fs[filesystem][:fs_type] = $3
168
- fs[filesystem][:mount_options] = $4.split(",")
201
+ key = "#{$1},#{$2}"
202
+ next if fs.has_key?(key)
203
+ fs[key] = Mash.new
204
+ fs[key][:device] = $1
205
+ fs[key][:mount] = $2
206
+ fs[key][:fs_type] = $3
207
+ fs[key][:mount_options] = $4.split(",")
169
208
  end
170
209
  end
171
210
  end
172
211
 
212
+ by_pair = fs
213
+ by_device = generate_device_view(fs)
214
+ by_mountpoint = generate_mountpoint_view(fs)
215
+
216
+ fs_data = Mash.new
217
+ fs_data["by_device"] = by_device
218
+ fs_data["by_mountpoint"] = by_mountpoint
219
+ fs_data["by_pair"] = by_pair
220
+
173
221
  # Set the filesystem data
174
- filesystem fs
222
+ filesystem fs_data
223
+ filesystem2 fs_data
175
224
  end
176
225
  end
@@ -1,8 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith <tsmith@limelight.com>
3
- # Author:: Phil Dibowitz <phild@ipomc.com>
4
3
  # Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
5
- # Copyright:: Copyright (c) 2017 Facebook, Inc.
6
4
  # Plugin:: mdadm
7
5
  #
8
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,52 +52,15 @@ Ohai.plugin(:Mdadm) do
54
52
  collect_data(:linux) do
55
53
  # gather a list of all raid arrays
56
54
  if File.exist?("/proc/mdstat")
57
- devices = {}
55
+ devices = []
58
56
  File.open("/proc/mdstat").each do |line|
59
- if line =~ /(md[0-9]+)/
60
- device = Regexp.last_match[1]
61
- pieces = line.split(/\s+/)
62
- # there are variable numbers of fields until you hit the raid level
63
- # everything after that is members...
64
- # unless the array is inactive, in which case you don't get a raid
65
- # level.
66
- members = pieces.drop_while { |x| !x.start_with?("raid", "inactive") }
67
- # and drop that too
68
- members.shift unless members.empty?
69
- devices[device] = {
70
- "active" => [],
71
- "spare" => [],
72
- "journal" => nil,
73
- }
74
- members.each do |member|
75
- # We want to match the device, and optionally the type
76
- # most entries will look like:
77
- # sdc1[5]
78
- # but some will look like:
79
- # sdc1[5](J)
80
- # where the format is:
81
- # <device>[<number in array>](<type>)
82
- # Type can be things like "J" for a journal device, or "S" for
83
- # a spare device.
84
- m = member.match(/(.+)\[\d+\](?:\((\w)\))?/)
85
- member_device = m[1]
86
- member_type = m[2]
87
- case member_type
88
- when "J"
89
- devices[device]["journal"] = member_device
90
- when "S"
91
- devices[device]["spare"] << member_device
92
- else
93
- devices[device]["active"] << member_device
94
- end
95
- end
96
- end
57
+ devices << Regexp.last_match[1] if line =~ /(md[0-9]+)/
97
58
  end
98
59
 
99
60
  # create the mdadm mash and gather individual information if devices are present
100
61
  unless devices.empty?
101
62
  mdadm Mash.new
102
- devices.keys.sort.each do |device|
63
+ devices.sort.each do |device|
103
64
  mdadm[device] = Mash.new
104
65
 
105
66
  # gather detailed information on the array
@@ -107,9 +68,6 @@ Ohai.plugin(:Mdadm) do
107
68
 
108
69
  # if the mdadm command was sucessful pass so.stdout to create_raid_device_mash to grab the tidbits we want
109
70
  mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
110
- mdadm[device]["members"] = devices[device]["active"]
111
- mdadm[device]["spares"] = devices[device]["spare"]
112
- mdadm[device]["journal"] = devices[device]["journal"]
113
71
  end
114
72
  end
115
73
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Chris Read <chris.read@gmail.com>
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) 2008-2017, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -215,31 +215,6 @@ Ohai.plugin(:Network) do
215
215
  net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
216
216
  end
217
217
 
218
- if line =~ /^\s+(ip6tnl|ipip)/
219
- iface[tmp_int][:tunnel_info] = {}
220
- words = line.split
221
- words.each_with_index do |word, index|
222
- case word
223
- when "external"
224
- iface[tmp_int][:tunnel_info][word] = true
225
- when "any", "ipip6", "ip6ip6"
226
- iface[tmp_int][:tunnel_info][:proto] = word
227
- when "remote",
228
- "local",
229
- "encaplimit",
230
- "hoplimit",
231
- "tclass",
232
- "flowlabel",
233
- "addrgenmode",
234
- "numtxqueues",
235
- "numrxqueues",
236
- "gso_max_size",
237
- "gso_max_segs"
238
- iface[tmp_int][:tunnel_info][word] = words[index + 1]
239
- end
240
- end
241
- end
242
-
243
218
  if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
244
219
  int = on_rx ? :rx : :tx
245
220
  net_counters[tmp_int][int] = Mash.new unless net_counters[tmp_int][int]
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -107,8 +107,10 @@ Ohai.plugin(:Platform) do
107
107
  case platform
108
108
  when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/
109
109
  "debian"
110
- when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
110
+ when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
111
111
  "rhel"
112
+ when /amazon/
113
+ "amazon"
112
114
  when /suse/
113
115
  "suse"
114
116
  when /fedora/, /pidora/, /arista_eos/