ohai 14.2.0 → 14.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/lib/ohai/application.rb +29 -29
- data/lib/ohai/common/dmi.rb +5 -5
- data/lib/ohai/dsl/plugin.rb +3 -3
- data/lib/ohai/dsl/plugin/versionvii.rb +3 -3
- data/lib/ohai/mixin/azure_metadata.rb +2 -2
- data/lib/ohai/mixin/do_metadata.rb +3 -3
- data/lib/ohai/mixin/ec2_metadata.rb +8 -8
- data/lib/ohai/mixin/gce_metadata.rb +2 -2
- data/lib/ohai/mixin/network_constants.rb +1 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -3
- data/lib/ohai/mixin/softlayer_metadata.rb +1 -1
- data/lib/ohai/mixin/string.rb +2 -2
- data/lib/ohai/plugins/aix/cpu.rb +3 -3
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/aix/kernel.rb +1 -1
- data/lib/ohai/plugins/aix/memory.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +3 -3
- data/lib/ohai/plugins/bsd/virtualization.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +1 -1
- data/lib/ohai/plugins/darwin/hardware.rb +1 -1
- data/lib/ohai/plugins/darwin/network.rb +5 -5
- data/lib/ohai/plugins/darwin/platform.rb +1 -1
- data/lib/ohai/plugins/dmi.rb +6 -6
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/hostname.rb +5 -5
- data/lib/ohai/plugins/kernel.rb +8 -8
- data/lib/ohai/plugins/linux/lspci.rb +4 -4
- data/lib/ohai/plugins/linux/memory.rb +4 -4
- data/lib/ohai/plugins/linux/network.rb +16 -16
- data/lib/ohai/plugins/linux/platform.rb +7 -1
- data/lib/ohai/plugins/netbsd/network.rb +1 -1
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openbsd/network.rb +1 -1
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/passwd.rb +4 -4
- data/lib/ohai/plugins/ruby.rb +13 -13
- data/lib/ohai/plugins/solaris2/dmi.rb +3 -3
- data/lib/ohai/plugins/solaris2/filesystem.rb +6 -6
- data/lib/ohai/plugins/solaris2/memory.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +36 -36
- data/lib/ohai/plugins/windows/network.rb +2 -2
- data/lib/ohai/util/win32/group_helper.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/application_spec.rb +6 -6
- data/spec/functional/loader_spec.rb +4 -4
- data/spec/functional/plugins/windows/uptime_spec.rb +1 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/unit/application_spec.rb +11 -11
- data/spec/unit/config_spec.rb +5 -5
- data/spec/unit/dsl/plugin_spec.rb +5 -5
- data/spec/unit/hints_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +41 -41
- data/spec/unit/mixin/azure_metadata_spec.rb +3 -3
- data/spec/unit/mixin/command_spec.rb +64 -64
- data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +9 -9
- data/spec/unit/plugins/abort_spec.rb +6 -6
- data/spec/unit/plugins/aix/cpu_spec.rb +16 -16
- data/spec/unit/plugins/aix/filesystem_spec.rb +57 -57
- data/spec/unit/plugins/aix/network_spec.rb +35 -35
- data/spec/unit/plugins/aix/virtualization_spec.rb +210 -210
- data/spec/unit/plugins/azure_spec.rb +49 -49
- data/spec/unit/plugins/bsd/filesystem_spec.rb +13 -13
- data/spec/unit/plugins/bsd/virtualization_spec.rb +10 -10
- data/spec/unit/plugins/c_spec.rb +54 -54
- data/spec/unit/plugins/chef_spec.rb +3 -3
- data/spec/unit/plugins/darwin/cpu_spec.rb +54 -54
- data/spec/unit/plugins/darwin/filesystem_spec.rb +34 -34
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +1070 -1070
- data/spec/unit/plugins/darwin/memory_spec.rb +16 -16
- data/spec/unit/plugins/darwin/network_spec.rb +382 -382
- data/spec/unit/plugins/digital_ocean_spec.rb +7 -7
- data/spec/unit/plugins/dmi_spec.rb +83 -83
- data/spec/unit/plugins/docker_spec.rb +2 -2
- data/spec/unit/plugins/ec2_spec.rb +156 -156
- data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
- data/spec/unit/plugins/fail_spec.rb +14 -14
- data/spec/unit/plugins/freebsd/cpu_spec.rb +18 -18
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +4 -4
- data/spec/unit/plugins/joyent_spec.rb +9 -9
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +155 -155
- data/spec/unit/plugins/linux/filesystem_spec.rb +229 -229
- data/spec/unit/plugins/linux/kernel_spec.rb +9 -9
- data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
- data/spec/unit/plugins/linux/lspci_spec.rb +58 -58
- data/spec/unit/plugins/linux/mdadm_spec.rb +54 -54
- data/spec/unit/plugins/linux/memory_spec.rb +35 -35
- data/spec/unit/plugins/linux/network_spec.rb +464 -464
- data/spec/unit/plugins/linux/platform_spec.rb +84 -68
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +40 -40
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +197 -197
- data/spec/unit/plugins/mono_spec.rb +11 -11
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +2 -2
- data/spec/unit/plugins/openstack_spec.rb +43 -43
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/passwd_spec.rb +9 -9
- data/spec/unit/plugins/php_spec.rb +22 -22
- data/spec/unit/plugins/powershell_spec.rb +13 -13
- data/spec/unit/plugins/rackspace_spec.rb +38 -38
- data/spec/unit/plugins/ruby_spec.rb +14 -14
- data/spec/unit/plugins/scaleway_spec.rb +6 -6
- data/spec/unit/plugins/scsi_spec.rb +7 -7
- data/spec/unit/plugins/solaris2/cpu_spec.rb +2594 -2594
- data/spec/unit/plugins/solaris2/dmi_spec.rb +91 -91
- data/spec/unit/plugins/solaris2/filesystem.rb +8 -8
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +92 -93
- data/spec/unit/plugins/solaris2/platform_spec.rb +24 -24
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +22 -22
- data/spec/unit/plugins/ssh_host_keys_spec.rb +12 -12
- data/spec/unit/plugins/sysconf_spec.rb +321 -321
- data/spec/unit/plugins/virtualbox_spec.rb +27 -27
- data/spec/unit/plugins/windows/cpu_spec.rb +9 -9
- data/spec/unit/plugins/windows/kernel_spec.rb +12 -12
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/zpools_spec.rb +41 -41
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/system_spec.rb +55 -55
- metadata +3 -4
- data/docs/man/man1/ohai.1 +0 -97
@@ -20,7 +20,7 @@ Ohai.plugin(:Platform) do
|
|
20
20
|
provides "platform", "platform_version", "platform_build", "platform_family"
|
21
21
|
|
22
22
|
collect_data(:darwin) do
|
23
|
-
so = shell_out(
|
23
|
+
so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s)
|
24
24
|
so.stdout.lines do |line|
|
25
25
|
case line
|
26
26
|
when /^ProductName:\s+(.+)$/
|
data/lib/ohai/plugins/dmi.rb
CHANGED
@@ -47,8 +47,8 @@ Ohai.plugin(:DMI) do
|
|
47
47
|
begin
|
48
48
|
so = shell_out("dmidecode")
|
49
49
|
# ==== EXAMPLE RECORD: ====
|
50
|
-
#Handle 0x0000, DMI type 0, 24 bytes
|
51
|
-
#BIOS Information
|
50
|
+
# Handle 0x0000, DMI type 0, 24 bytes
|
51
|
+
# BIOS Information
|
52
52
|
# Vendor: American Megatrends Inc.
|
53
53
|
# Version: 080012
|
54
54
|
# ... similar lines trimmed
|
@@ -58,7 +58,7 @@ Ohai.plugin(:DMI) do
|
|
58
58
|
# ... similar lines trimmed
|
59
59
|
so.stdout.lines do |line|
|
60
60
|
next if blank_line.match(line)
|
61
|
-
line = line.encode(line.encoding, :
|
61
|
+
line = line.encode(line.encoding, universal_newline: true)
|
62
62
|
|
63
63
|
if ( dmidecode_version = dmidecode_version_line.match(line) )
|
64
64
|
dmi[:dmidecode_version] = dmidecode_version[1]
|
@@ -80,10 +80,10 @@ Ohai.plugin(:DMI) do
|
|
80
80
|
next
|
81
81
|
end
|
82
82
|
|
83
|
-
dmi_record = { :
|
83
|
+
dmi_record = { type: Ohai::Common::DMI.id_lookup(handle[2]) }
|
84
84
|
|
85
|
-
dmi[dmi_record[:type]] = Mash.new unless dmi.
|
86
|
-
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].
|
85
|
+
dmi[dmi_record[:type]] = Mash.new unless dmi.key?(dmi_record[:type])
|
86
|
+
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].key?(:all_records)
|
87
87
|
dmi_record[:position] = dmi[dmi_record[:type]][:all_records].length
|
88
88
|
dmi[dmi_record[:type]][:all_records].push(Mash.new)
|
89
89
|
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:record_id] = handle[1]
|
@@ -39,12 +39,12 @@ Ohai.plugin(:Filesystem) do
|
|
39
39
|
uuid = $2
|
40
40
|
label = $3
|
41
41
|
fs_type = $4
|
42
|
-
return { :
|
42
|
+
return { dev: dev, uuid: uuid, label: label, fs_type: fs_type }
|
43
43
|
end
|
44
44
|
when "blkid"
|
45
45
|
bits = line.split
|
46
46
|
dev = bits.shift.split(":")[0]
|
47
|
-
f = { :
|
47
|
+
f = { dev: dev }
|
48
48
|
bits.each do |keyval|
|
49
49
|
if keyval =~ /(\S+)="(\S+)"/
|
50
50
|
key = $1.downcase.to_sym
|
@@ -151,7 +151,7 @@ Ohai.plugin(:Filesystem) do
|
|
151
151
|
so.stdout.each_line do |line|
|
152
152
|
if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
|
153
153
|
key = "#{$1},#{$2}"
|
154
|
-
fs[key] = Mash.new unless fs.
|
154
|
+
fs[key] = Mash.new unless fs.key?(key)
|
155
155
|
fs[key][:device] = $1
|
156
156
|
fs[key][:mount] = $2
|
157
157
|
fs[key][:fs_type] = $3
|
@@ -237,7 +237,7 @@ Ohai.plugin(:Filesystem) do
|
|
237
237
|
mounts.each_line do |line|
|
238
238
|
if line =~ /^(\S+) (\S+) (\S+) (\S+) \S+ \S+$/
|
239
239
|
key = "#{$1},#{$2}"
|
240
|
-
next if fs.
|
240
|
+
next if fs.key?(key)
|
241
241
|
fs[key] = Mash.new
|
242
242
|
fs[key][:device] = $1
|
243
243
|
fs[key][:mount] = $2
|
@@ -360,7 +360,7 @@ Ohai.plugin(:Filesystem) do
|
|
360
360
|
so.stdout.lines do |line|
|
361
361
|
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
362
362
|
key = "#{$1},#{$2}"
|
363
|
-
fs[key] = Mash.new unless fs.
|
363
|
+
fs[key] = Mash.new unless fs.key?(key)
|
364
364
|
fs[key][:mount] = $2
|
365
365
|
fs[key][:fs_type] = $3
|
366
366
|
fs[key][:mount_options] = $4.split(/,\s*/)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
7
7
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
8
8
|
# Author:: Isa Farnik (<isa@chef.io>)
|
9
|
-
# Copyright:: Copyright (c) 2008-
|
9
|
+
# Copyright:: Copyright (c) 2008-2018, Chef Software Inc.
|
10
10
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
11
11
|
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
12
12
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
@@ -166,15 +166,15 @@ Ohai.plugin(:Hostname) do
|
|
166
166
|
wmi = WmiLite::Wmi.new
|
167
167
|
host = wmi.first_of("Win32_ComputerSystem")
|
168
168
|
|
169
|
-
hostname
|
170
|
-
machinename
|
169
|
+
hostname host["dnshostname"].to_s
|
170
|
+
machinename host["name"].to_s
|
171
171
|
|
172
172
|
info = Socket.gethostbyname(Socket.gethostname)
|
173
173
|
if info.first =~ /.+?\.(.*)/
|
174
174
|
fqdn info.first
|
175
175
|
else
|
176
|
-
#host is not in dns. optionally use:
|
177
|
-
#C:\WINDOWS\system32\drivers\etc\hosts
|
176
|
+
# host is not in dns. optionally use:
|
177
|
+
# C:\WINDOWS\system32\drivers\etc\hosts
|
178
178
|
fqdn Socket.gethostbyaddr(info.last).first
|
179
179
|
end
|
180
180
|
domain collect_domain
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -42,11 +42,11 @@ Ohai.plugin(:Kernel) do
|
|
42
42
|
# @return [Mash]
|
43
43
|
def bsd_modules(path)
|
44
44
|
modules = Mash.new
|
45
|
-
so = shell_out(
|
45
|
+
so = shell_out((Ohai.abs_path(path)).to_s)
|
46
46
|
so.stdout.lines do |line|
|
47
47
|
# 1 7 0xc0400000 97f830 kernel
|
48
48
|
if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
|
49
|
-
modules[$5] = { :
|
49
|
+
modules[$5] = { size: $4, refcount: $2 }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
modules
|
@@ -169,7 +169,7 @@ Ohai.plugin(:Kernel) do
|
|
169
169
|
so = shell_out("kextstat -k -l")
|
170
170
|
so.stdout.lines do |line|
|
171
171
|
if line =~ /(\d+)\s+(\d+)\s+0x[0-9a-f]+\s+0x([0-9a-f]+)\s+0x[0-9a-f]+\s+([a-zA-Z0-9\.]+) \(([0-9\.]+)\)/
|
172
|
-
modules[$4] = { :
|
172
|
+
modules[$4] = { version: $5, size: $3.hex, index: $1, refcount: $2 }
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -198,7 +198,7 @@ Ohai.plugin(:Kernel) do
|
|
198
198
|
so = shell_out("env lsmod")
|
199
199
|
so.stdout.lines do |line|
|
200
200
|
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
|
201
|
-
modules[$1] = { :
|
201
|
+
modules[$1] = { size: $2, refcount: $3 }
|
202
202
|
# Making sure to get the module version that has been loaded
|
203
203
|
if File.exist?("/sys/module/#{$1}/version")
|
204
204
|
version = File.read("/sys/module/#{$1}/version").chomp.strip
|
@@ -239,7 +239,7 @@ Ohai.plugin(:Kernel) do
|
|
239
239
|
module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/
|
240
240
|
so.stdout.lines do |line|
|
241
241
|
if ( mod = module_description.match(line) )
|
242
|
-
modules[mod[4]] = { :
|
242
|
+
modules[mod[4]] = { id: mod[1].to_i, loadaddr: mod[2], size: mod[3].to_i(16), description: mod[5] }
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -263,8 +263,8 @@ Ohai.plugin(:Kernel) do
|
|
263
263
|
kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
264
264
|
end
|
265
265
|
|
266
|
-
kernel[:name] =
|
267
|
-
kernel[:release] =
|
266
|
+
kernel[:name] = (kernel[:os_info][:caption]).to_s
|
267
|
+
kernel[:release] = (kernel[:os_info][:version]).to_s
|
268
268
|
kernel[:version] = "#{kernel[:os_info][:version]} #{kernel[:os_info][:csd_version]} Build #{kernel[:os_info][:build_number]}"
|
269
269
|
kernel[:os] = os_type_decode(kernel[:os_info][:os_type]) || languages[:ruby][:host_os]
|
270
270
|
kernel[:product_type] = product_type_decode(kernel[:os_info][:product_type])
|
@@ -277,7 +277,7 @@ Ohai.plugin(:Kernel) do
|
|
277
277
|
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
278
278
|
end
|
279
279
|
|
280
|
-
kernel[:machine] = arch_lookup(
|
280
|
+
kernel[:machine] = arch_lookup((kernel[:cs_info][:system_type]).to_s)
|
281
281
|
kernel[:system_type] = pc_system_type_decode(kernel[:cs_info][:pc_system_type])
|
282
282
|
end
|
283
283
|
end
|
@@ -26,11 +26,11 @@ Ohai.plugin(:Lspci) do
|
|
26
26
|
devices = Mash.new
|
27
27
|
lspci = shell_out("lspci -vnnmk")
|
28
28
|
|
29
|
-
h = /[0-9a-fA-F]/ #any hex digit
|
30
|
-
hh = /#{h}#{h}/ #any 2 hex digits
|
31
|
-
hhhh = /#{h}#{h}#{h}#{h}/ #any 4 hex digits
|
29
|
+
h = /[0-9a-fA-F]/ # any hex digit
|
30
|
+
hh = /#{h}#{h}/ # any 2 hex digits
|
31
|
+
hhhh = /#{h}#{h}#{h}#{h}/ # any 4 hex digits
|
32
32
|
|
33
|
-
d_id = String.new #This identifies our pci devices
|
33
|
+
d_id = String.new # This identifies our pci devices
|
34
34
|
|
35
35
|
def standard_form(devices, d_id, hhhh, tag, line)
|
36
36
|
tmp = line.scan(/(.*)\s\[(#{hhhh})\]/)[0]
|
@@ -85,13 +85,13 @@ Ohai.plugin(:Memory) do
|
|
85
85
|
when /^SwapFree:\s+(\d+) (.+)$/
|
86
86
|
memory[:swap][:free] = "#{$1}#{$2}"
|
87
87
|
when /^HugePages_Total:\s+(\d+)$/
|
88
|
-
memory[:hugepages][:total] =
|
88
|
+
memory[:hugepages][:total] = $1.to_s
|
89
89
|
when /^HugePages_Free:\s+(\d+)$/
|
90
|
-
memory[:hugepages][:free] =
|
90
|
+
memory[:hugepages][:free] = $1.to_s
|
91
91
|
when /^HugePages_Rsvd:\s+(\d+)$/
|
92
|
-
memory[:hugepages][:reserved] =
|
92
|
+
memory[:hugepages][:reserved] = $1.to_s
|
93
93
|
when /^HugePages_Surp:\s+(\d+)$/
|
94
|
-
memory[:hugepages][:surplus] =
|
94
|
+
memory[:hugepages][:surplus] = $1.to_s
|
95
95
|
when /^Hugepagesize:\s+(\d+) (.+)$/
|
96
96
|
memory[:hugepage_size] = "#{$1}#{$2}"
|
97
97
|
end
|
@@ -101,8 +101,8 @@ Ohai.plugin(:Network) do
|
|
101
101
|
next
|
102
102
|
end
|
103
103
|
|
104
|
-
route_entry = Mash.new(:
|
105
|
-
:
|
104
|
+
route_entry = Mash.new(destination: route_dest,
|
105
|
+
family: family[:name])
|
106
106
|
%w{via scope metric proto src}.each do |k|
|
107
107
|
# http://rubular.com/r/pwTNp65VFf
|
108
108
|
route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
|
@@ -113,7 +113,7 @@ Ohai.plugin(:Network) do
|
|
113
113
|
# unless the interface has no addresses of this type at all
|
114
114
|
if route_entry[:src]
|
115
115
|
addr = iface[route_int][:addresses]
|
116
|
-
unless addr.nil? || addr.
|
116
|
+
unless addr.nil? || addr.key?(route_entry[:src]) ||
|
117
117
|
addr.values.all? { |a| a["family"] != family[:name] }
|
118
118
|
logger.trace("Plugin Network: Skipping route entry whose src does not match the interface IP")
|
119
119
|
next
|
@@ -140,7 +140,7 @@ Ohai.plugin(:Network) do
|
|
140
140
|
iface.collect do |i, iv|
|
141
141
|
if iv[:routes]
|
142
142
|
iv[:routes].collect do |r|
|
143
|
-
r.merge(:
|
143
|
+
r.merge(dev: i) if r[:family] == family[:name]
|
144
144
|
end.compact
|
145
145
|
end
|
146
146
|
end.compact.flatten
|
@@ -388,9 +388,9 @@ Ohai.plugin(:Network) do
|
|
388
388
|
def choose_default_route(routes)
|
389
389
|
routes.select do |r|
|
390
390
|
r[:destination] == "default"
|
391
|
-
end.
|
391
|
+
end.min do |x, y|
|
392
392
|
(x[:metric].nil? ? 0 : x[:metric].to_i) <=> (y[:metric].nil? ? 0 : y[:metric].to_i)
|
393
|
-
end
|
393
|
+
end
|
394
394
|
end
|
395
395
|
|
396
396
|
def interface_has_no_addresses_in_family?(iface, family)
|
@@ -447,7 +447,7 @@ Ohai.plugin(:Network) do
|
|
447
447
|
iface[r[:dev]][:state] == "up" &&
|
448
448
|
route_is_valid_default_route?(r, default_route)
|
449
449
|
end
|
450
|
-
end.
|
450
|
+
end.min_by do |r|
|
451
451
|
# sorting the selected routes:
|
452
452
|
# - getting default routes first
|
453
453
|
# - then sort by metric
|
@@ -463,7 +463,7 @@ Ohai.plugin(:Network) do
|
|
463
463
|
0
|
464
464
|
end,
|
465
465
|
]
|
466
|
-
end
|
466
|
+
end
|
467
467
|
end
|
468
468
|
|
469
469
|
# Both the network plugin and this plugin (linux/network) are run on linux. This plugin runs first.
|
@@ -496,18 +496,18 @@ Ohai.plugin(:Network) do
|
|
496
496
|
if which("ip")
|
497
497
|
# families to get default routes from
|
498
498
|
families = [{
|
499
|
-
:
|
500
|
-
:
|
501
|
-
:
|
502
|
-
:
|
499
|
+
name: "inet",
|
500
|
+
default_route: "0.0.0.0/0",
|
501
|
+
default_prefix: :default,
|
502
|
+
neighbour_attribute: :arp,
|
503
503
|
}]
|
504
504
|
|
505
505
|
if ipv6_enabled?
|
506
506
|
families << {
|
507
|
-
:
|
508
|
-
:
|
509
|
-
:
|
510
|
-
:
|
507
|
+
name: "inet6",
|
508
|
+
default_route: "::/0",
|
509
|
+
default_prefix: :default_inet6,
|
510
|
+
neighbour_attribute: :neighbour_inet6,
|
511
511
|
}
|
512
512
|
end
|
513
513
|
|
@@ -24,8 +24,14 @@ Ohai.plugin(:Platform) do
|
|
24
24
|
contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
|
25
25
|
end
|
26
26
|
|
27
|
+
# Amazon Linux AMI release 2013.09
|
28
|
+
# Amazon Linux 2
|
29
|
+
# Fedora release 28 (Twenty Eight)
|
30
|
+
# CentOS release 5.8 (Final)
|
31
|
+
# CentOS release 6.7 (Final)
|
32
|
+
# Red Hat Enterprise Linux Server release 7.5 (Maipo)
|
27
33
|
def get_redhatish_version(contents)
|
28
|
-
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/,
|
34
|
+
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
|
29
35
|
end
|
30
36
|
|
31
37
|
#
|
@@ -71,7 +71,7 @@ Ohai.plugin(:Network) do
|
|
71
71
|
if $4.empty?
|
72
72
|
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
|
73
73
|
else
|
74
|
-
#found a zone_id / scope
|
74
|
+
# found a zone_id / scope
|
75
75
|
iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
|
76
76
|
end
|
77
77
|
end
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -36,13 +36,13 @@ Ohai.plugin(:NetworkAddresses) do
|
|
36
36
|
# grab ipaddress, scope, and iface for sorting later
|
37
37
|
ipaddresses = []
|
38
38
|
Mash[network["interfaces"]].each do |iface, iface_v|
|
39
|
-
next if iface_v.nil? || !iface_v.
|
39
|
+
next if iface_v.nil? || !iface_v.key?("addresses")
|
40
40
|
iface_v["addresses"].each do |addr, addr_v|
|
41
|
-
next if addr_v.nil? || (not addr_v.
|
41
|
+
next if addr_v.nil? || (not addr_v.key? "family") || addr_v["family"] != family
|
42
42
|
ipaddresses << {
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
43
|
+
ipaddress: addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
|
44
|
+
scope: addr_v["scope"].nil? ? nil : addr_v["scope"].downcase,
|
45
|
+
iface: iface,
|
46
46
|
}
|
47
47
|
end
|
48
48
|
end
|
@@ -71,7 +71,7 @@ Ohai.plugin(:Network) do
|
|
71
71
|
if $4.empty?
|
72
72
|
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
|
73
73
|
else
|
74
|
-
#found a zone_id / scope
|
74
|
+
# found a zone_id / scope
|
75
75
|
iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
|
76
76
|
end
|
77
77
|
end
|
data/lib/ohai/plugins/passwd.rb
CHANGED
@@ -17,15 +17,15 @@ Ohai.plugin(:Passwd) do
|
|
17
17
|
etc[:group] = Mash.new
|
18
18
|
|
19
19
|
Etc.passwd do |entry|
|
20
|
-
user_passwd_entry = Mash.new(:
|
20
|
+
user_passwd_entry = Mash.new(dir: entry.dir, gid: entry.gid, uid: entry.uid, shell: entry.shell, gecos: entry.gecos)
|
21
21
|
user_passwd_entry.each_value { |v| fix_encoding(v) }
|
22
22
|
entry_name = fix_encoding(entry.name)
|
23
|
-
etc[:passwd][entry_name] = user_passwd_entry unless etc[:passwd].
|
23
|
+
etc[:passwd][entry_name] = user_passwd_entry unless etc[:passwd].key?(entry_name)
|
24
24
|
end
|
25
25
|
|
26
26
|
Etc.group do |entry|
|
27
|
-
group_entry = Mash.new(:
|
28
|
-
:
|
27
|
+
group_entry = Mash.new(gid: entry.gid,
|
28
|
+
members: entry.mem.map { |u| fix_encoding(u) })
|
29
29
|
|
30
30
|
etc[:group][fix_encoding(entry.name)] = group_entry
|
31
31
|
end
|
data/lib/ohai/plugins/ruby.rb
CHANGED
@@ -30,19 +30,19 @@ Ohai.plugin(:Ruby) do
|
|
30
30
|
languages[:ruby] = Mash.new
|
31
31
|
|
32
32
|
values = {
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
33
|
+
platform: "RUBY_PLATFORM",
|
34
|
+
version: "RUBY_VERSION",
|
35
|
+
release_date: "RUBY_RELEASE_DATE",
|
36
|
+
target: "RbConfig::CONFIG['target']",
|
37
|
+
target_cpu: "RbConfig::CONFIG['target_cpu']",
|
38
|
+
target_vendor: "RbConfig::CONFIG['target_vendor']",
|
39
|
+
target_os: "RbConfig::CONFIG['target_os']",
|
40
|
+
host: "RbConfig::CONFIG['host']",
|
41
|
+
host_cpu: "RbConfig::CONFIG['host_cpu']",
|
42
|
+
host_os: "RbConfig::CONFIG['host_os']",
|
43
|
+
host_vendor: "RbConfig::CONFIG['host_vendor']",
|
44
|
+
bin_dir: "RbConfig::CONFIG['bindir']",
|
45
|
+
ruby_bin: "::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])",
|
46
46
|
}
|
47
47
|
|
48
48
|
# Create a query string from above hash
|
@@ -125,7 +125,7 @@ Ohai.plugin(:DMI) do
|
|
125
125
|
dmi_record = {}
|
126
126
|
|
127
127
|
# look up SMB ID
|
128
|
-
if smb_to_id.
|
128
|
+
if smb_to_id.key?(header_information[3])
|
129
129
|
id = smb_to_id[header_information[3]]
|
130
130
|
|
131
131
|
# Don't overcapture for now (OHAI-260)
|
@@ -142,8 +142,8 @@ Ohai.plugin(:DMI) do
|
|
142
142
|
next
|
143
143
|
end
|
144
144
|
|
145
|
-
dmi[dmi_record[:type]] = Mash.new unless dmi.
|
146
|
-
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].
|
145
|
+
dmi[dmi_record[:type]] = Mash.new unless dmi.key?(dmi_record[:type])
|
146
|
+
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].key?(:all_records)
|
147
147
|
dmi_record[:position] = dmi[dmi_record[:type]][:all_records].length
|
148
148
|
dmi[dmi_record[:type]][:all_records].push(Mash.new)
|
149
149
|
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:record_id] = header_information[1]
|
@@ -55,7 +55,7 @@ Ohai.plugin(:Filesystem) do
|
|
55
55
|
so.stdout.lines do |line|
|
56
56
|
next unless line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/
|
57
57
|
filesystem = $2
|
58
|
-
fs[filesystem] = Mash.new unless fs.
|
58
|
+
fs[filesystem] = Mash.new unless fs.key?(filesystem)
|
59
59
|
fs[filesystem][:mount] = $1
|
60
60
|
fs[filesystem][:mount_time] = $4 # $4 must come before "split", else it becomes nil
|
61
61
|
fs[filesystem][:mount_options] = $3.split("/")
|
@@ -75,17 +75,17 @@ Ohai.plugin(:Filesystem) do
|
|
75
75
|
so.stdout.lines do |line|
|
76
76
|
next unless line =~ /^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)$/
|
77
77
|
filesystem = $1
|
78
|
-
zfs[filesystem] = Mash.new unless zfs.
|
79
|
-
zfs[filesystem][:values] = Mash.new unless zfs[filesystem].
|
80
|
-
zfs[filesystem][:sources] = Mash.new unless zfs[filesystem].
|
78
|
+
zfs[filesystem] = Mash.new unless zfs.key?(filesystem)
|
79
|
+
zfs[filesystem][:values] = Mash.new unless zfs[filesystem].key?("values")
|
80
|
+
zfs[filesystem][:sources] = Mash.new unless zfs[filesystem].key?("sources")
|
81
81
|
zfs[filesystem][:values][$2] = $3
|
82
82
|
zfs[filesystem][:sources][$2] = $4.chomp
|
83
83
|
end
|
84
84
|
|
85
85
|
zfs.each do |filesystem, attributes|
|
86
|
-
fs[filesystem] = Mash.new unless fs.
|
86
|
+
fs[filesystem] = Mash.new unless fs.key?(filesystem)
|
87
87
|
fs[filesystem][:fs_type] = "zfs"
|
88
|
-
fs[filesystem][:mount] = attributes[:values][:mountpoint] if attributes[:values].
|
88
|
+
fs[filesystem][:mount] = attributes[:values][:mountpoint] if attributes[:values].key?("mountpoint")
|
89
89
|
fs[filesystem][:zfs_values] = attributes[:values]
|
90
90
|
fs[filesystem][:zfs_sources] = attributes[:sources]
|
91
91
|
# find all zfs parents
|