ohai 14.15.0 → 15.0.35
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/lib/ohai/application.rb +0 -4
- data/lib/ohai/common/dmi.rb +43 -43
- data/lib/ohai/config.rb +1 -1
- data/lib/ohai/loader.rb +32 -47
- data/lib/ohai/mixin/dmi_decode.rb +29 -32
- data/lib/ohai/mixin/os.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
- data/lib/ohai/plugins/aix/virtualization.rb +4 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
- data/lib/ohai/plugins/c.rb +0 -20
- data/lib/ohai/plugins/elixir.rb +13 -13
- data/lib/ohai/plugins/filesystem.rb +10 -10
- data/lib/ohai/plugins/gce.rb +42 -8
- data/lib/ohai/plugins/go.rb +11 -11
- data/lib/ohai/plugins/groovy.rb +12 -12
- data/lib/ohai/plugins/hostname.rb +9 -2
- data/lib/ohai/plugins/linux/fips.rb +2 -9
- data/lib/ohai/plugins/linux/memory.rb +5 -0
- data/lib/ohai/plugins/linux/network.rb +1 -1
- data/lib/ohai/plugins/linux/platform.rb +84 -83
- data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
- data/lib/ohai/plugins/linux/virtualization.rb +10 -20
- data/lib/ohai/plugins/lua.rb +13 -13
- data/lib/ohai/plugins/mono.rb +23 -23
- data/lib/ohai/plugins/nodejs.rb +13 -13
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/packages.rb +1 -28
- data/lib/ohai/plugins/perl.rb +17 -17
- data/lib/ohai/plugins/php.rb +22 -22
- data/lib/ohai/plugins/powershell.rb +30 -30
- data/lib/ohai/plugins/ps.rb +1 -1
- data/lib/ohai/plugins/python.rb +15 -15
- data/lib/ohai/plugins/rust.rb +11 -11
- data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
- data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
- data/lib/ohai/plugins/virtualbox.rb +21 -21
- data/lib/ohai/plugins/windows/filesystem.rb +2 -2
- data/lib/ohai/plugins/windows/fips.rb +2 -21
- data/lib/ohai/plugins/windows/virtualization.rb +9 -35
- data/lib/ohai/runner.rb +2 -2
- data/lib/ohai/system.rb +0 -17
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -2
- data/spec/data/plugins/rpmquery.output +0 -2
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/loader_spec.rb +2 -2
- data/spec/functional/plugins/powershell_spec.rb +2 -2
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
- data/spec/ohai_spec.rb +1 -1
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +12 -12
- data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
- data/spec/unit/mixin/command_spec.rb +1 -1
- data/spec/unit/mixin/dmi_decode.rb +68 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +1 -1
- data/spec/unit/plugins/abort_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
- data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +1 -1
- data/spec/unit/plugins/aix/network_spec.rb +6 -6
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
- data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
- data/spec/unit/plugins/c_spec.rb +1 -53
- data/spec/unit/plugins/chef_spec.rb +1 -1
- data/spec/unit/plugins/cloud_spec.rb +1 -1
- data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
- data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
- data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
- data/spec/unit/plugins/darwin/network_spec.rb +1 -1
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
- data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/docker_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +1 -1
- data/spec/unit/plugins/elixir_spec.rb +1 -1
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
- data/spec/unit/plugins/fail_spec.rb +28 -28
- data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/hostname_spec.rb +68 -1
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +3 -3
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linode_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +6 -6
- data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
- data/spec/unit/plugins/linux/fips_spec.rb +13 -45
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
- data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
- data/spec/unit/plugins/linux/memory_spec.rb +26 -1
- data/spec/unit/plugins/linux/network_spec.rb +37 -37
- data/spec/unit/plugins/linux/platform_spec.rb +580 -837
- data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +2 -2
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +11 -11
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/openstack_spec.rb +8 -4
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -21
- data/spec/unit/plugins/passwd_spec.rb +1 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +6 -6
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +2 -2
- data/spec/unit/plugins/root_group_spec.rb +1 -11
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +1 -1
- data/spec/unit/plugins/scsi_spec.rb +2 -2
- data/spec/unit/plugins/shard_spec.rb +1 -1
- data/spec/unit/plugins/shells_spec.rb +1 -1
- data/spec/unit/plugins/softlayer_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +6 -6
- data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
- data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
- data/spec/unit/plugins/sysconf_spec.rb +2 -2
- data/spec/unit/plugins/timezone_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +1 -1
- data/spec/unit/plugins/vmware_spec.rb +1 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
- data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
- data/spec/unit/plugins/windows/fips_spec.rb +17 -77
- data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +2 -2
- data/spec/unit/plugins/windows/network_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
- data/spec/unit/plugins/zpools_spec.rb +7 -7
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +10 -77
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -9
- data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
- data/lib/ohai/util/win32/group_helper.rb +0 -76
- data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +0 -40
data/lib/ohai/plugins/elixir.rb
CHANGED
@@ -18,19 +18,19 @@ Ohai.plugin(:Elixir) do
|
|
18
18
|
depends "languages"
|
19
19
|
|
20
20
|
collect_data do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
rescue Ohai::Exceptions::Exec
|
33
|
-
logger.trace('Plugin Elixir: Could not shell_out "elixir -v". Skipping plugin')
|
21
|
+
|
22
|
+
so = shell_out("elixir -v")
|
23
|
+
# Sample output:
|
24
|
+
# Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
|
25
|
+
#
|
26
|
+
# Elixir 1.2.4
|
27
|
+
if so.exitstatus == 0 && so.stdout =~ /^Elixir (\S*)/
|
28
|
+
elixir = Mash.new
|
29
|
+
elixir[:version] = $1
|
30
|
+
languages[:elixir] = elixir
|
34
31
|
end
|
32
|
+
rescue Ohai::Exceptions::Exec
|
33
|
+
logger.trace('Plugin Elixir: Could not shell_out "elixir -v". Skipping plugin')
|
34
|
+
|
35
35
|
end
|
36
36
|
end
|
@@ -250,16 +250,16 @@ Ohai.plugin(:Filesystem) do
|
|
250
250
|
# we have to non-block read dev files. Ew.
|
251
251
|
f = File.open("/proc/mounts")
|
252
252
|
loop do
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
253
|
+
|
254
|
+
data = f.read_nonblock(4096)
|
255
|
+
mounts << data
|
256
|
+
# We should just catch EOFError, but the kernel had a period of
|
257
|
+
# bugginess with reading virtual files, so we're being extra
|
258
|
+
# cautious here, catching all exceptions, and then we'll read
|
259
|
+
# whatever data we might have
|
260
|
+
rescue Exception
|
261
|
+
break
|
262
|
+
|
263
263
|
end
|
264
264
|
f.close
|
265
265
|
mounts.each_line do |line|
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -23,13 +23,43 @@ Ohai.plugin(:GCE) do
|
|
23
23
|
|
24
24
|
provides "gce"
|
25
25
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
# look for GCE string in dmi vendor bios data within the sys tree.
|
27
|
+
# this works even if the system lacks dmidecode use by the Dmi plugin
|
28
|
+
# @return [Boolean] do we have Google Compute Engine DMI data?
|
29
|
+
def has_gce_dmi?
|
30
|
+
if file_val_if_exists("/sys/class/dmi/id/product_name") =~ /Google Compute Engine/
|
31
|
+
logger.trace("Plugin GCE: has_gce_dmi? == true")
|
32
|
+
true
|
33
|
+
else
|
34
|
+
logger.trace("Plugin GCE: has_gce_dmi? == false")
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# return the contents of a file if the file exists
|
40
|
+
# @param path[String] abs path to the file
|
41
|
+
# @return [String] contents of the file if it exists
|
42
|
+
def file_val_if_exists(path)
|
43
|
+
if ::File.exist?(path)
|
44
|
+
::File.read(path)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# looks at the Manufacturer and Model WMI values to see if they starts with Google.
|
49
|
+
# @return [Boolean] Are the manufacturer and model Google?
|
50
|
+
def has_gce_system_info?
|
51
|
+
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
52
|
+
require "wmi-lite/wmi"
|
53
|
+
wmi = WmiLite::Wmi.new
|
54
|
+
computer_system = wmi.first_of("Win32_ComputerSystem")
|
55
|
+
if computer_system["Manufacturer"] =~ /^Google/ && computer_system["Model"] =~ /^Google/
|
56
|
+
logger.trace("Plugin GCE: has_gce_system_info? == true")
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
else
|
60
|
+
logger.trace("Plugin GCE: has_gce_system_info? == false")
|
61
|
+
false
|
62
|
+
end
|
33
63
|
end
|
34
64
|
|
35
65
|
# Identifies gce
|
@@ -38,7 +68,11 @@ Ohai.plugin(:GCE) do
|
|
38
68
|
# true:: If gce can be identified
|
39
69
|
# false:: Otherwise
|
40
70
|
def looks_like_gce?
|
41
|
-
hint?("gce")
|
71
|
+
return true if hint?("gce")
|
72
|
+
|
73
|
+
if has_gce_dmi? || has_gce_system_info?
|
74
|
+
return true if can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
|
75
|
+
end
|
42
76
|
end
|
43
77
|
|
44
78
|
collect_data do
|
data/lib/ohai/plugins/go.rb
CHANGED
@@ -18,17 +18,17 @@ Ohai.plugin(:Go) do
|
|
18
18
|
depends "languages"
|
19
19
|
|
20
20
|
collect_data do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
rescue Ohai::Exceptions::Exec
|
31
|
-
logger.trace('Plugin Go: Could not shell_out "go version". Skipping plugin')
|
21
|
+
|
22
|
+
so = shell_out("go version")
|
23
|
+
# Sample output:
|
24
|
+
# go version go1.6.1 darwin/amd64
|
25
|
+
if so.exitstatus == 0 && so.stdout =~ /go(\S+)/
|
26
|
+
go = Mash.new
|
27
|
+
go[:version] = $1
|
28
|
+
languages[:go] = go
|
32
29
|
end
|
30
|
+
rescue Ohai::Exceptions::Exec
|
31
|
+
logger.trace('Plugin Go: Could not shell_out "go version". Skipping plugin')
|
32
|
+
|
33
33
|
end
|
34
34
|
end
|
data/lib/ohai/plugins/groovy.rb
CHANGED
@@ -21,18 +21,18 @@ Ohai.plugin(:Groovy) do
|
|
21
21
|
depends "languages"
|
22
22
|
|
23
23
|
collect_data do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
rescue Ohai::Exceptions::Exec
|
35
|
-
logger.trace('Plugin Groovy: Could not shell_out "groovy -v". Skipping plugin')
|
24
|
+
|
25
|
+
so = shell_out("groovy -v")
|
26
|
+
# Sample output:
|
27
|
+
# Groovy Version: 2.4.6 JVM: 1.8.0_60 Vendor: Oracle Corporation OS: Mac OS X
|
28
|
+
if so.exitstatus == 0 && so.stdout =~ /Groovy Version: (\S+).*JVM: (\S+)/
|
29
|
+
groovy = Mash.new
|
30
|
+
groovy[:version] = $1
|
31
|
+
groovy[:jvm] = $2
|
32
|
+
languages[:groovy] = groovy
|
36
33
|
end
|
34
|
+
rescue Ohai::Exceptions::Exec
|
35
|
+
logger.trace('Plugin Groovy: Could not shell_out "groovy -v". Skipping plugin')
|
36
|
+
|
37
37
|
end
|
38
38
|
end
|
@@ -74,7 +74,7 @@ Ohai.plugin(:Hostname) do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
collect_data(:
|
77
|
+
collect_data(:default) do
|
78
78
|
machinename from_cmd("hostname")
|
79
79
|
fqdn resolve_fqdn
|
80
80
|
collect_hostname
|
@@ -175,7 +175,14 @@ Ohai.plugin(:Hostname) do
|
|
175
175
|
else
|
176
176
|
# host is not in dns. optionally use:
|
177
177
|
# C:\WINDOWS\system32\drivers\etc\hosts
|
178
|
-
|
178
|
+
info[3..info.length].reverse_each do |addr|
|
179
|
+
hostent = Socket.gethostbyaddr(addr)
|
180
|
+
if hostent.first =~ /.+?\.(.*)/
|
181
|
+
fqdn hostent.first
|
182
|
+
break
|
183
|
+
end
|
184
|
+
end
|
185
|
+
fqdn info.first unless fqdn
|
179
186
|
end
|
180
187
|
domain collect_domain
|
181
188
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
3
|
+
# Copyright:: Copyright (c) 2016-2018 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");
|
@@ -28,18 +28,11 @@ Ohai.plugin(:Fips) do
|
|
28
28
|
collect_data(:linux) do
|
29
29
|
fips Mash.new
|
30
30
|
|
31
|
-
# Check for new fips_mode method added in Ruby 2.5. After we drop support
|
32
|
-
# for Ruby 2.4, clean up everything after this and collapse the FIPS plugins.
|
33
31
|
require "openssl"
|
34
32
|
if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE
|
35
33
|
fips["kernel"] = { "enabled" => true }
|
36
34
|
else
|
37
|
-
|
38
|
-
enabled = File.read("/proc/sys/crypto/fips_enabled").chomp
|
39
|
-
fips["kernel"] = { "enabled" => enabled == "0" ? false : true }
|
40
|
-
rescue Errno::ENOENT
|
41
|
-
fips["kernel"] = { "enabled" => false }
|
42
|
-
end
|
35
|
+
fips["kernel"] = { "enabled" => false }
|
43
36
|
end
|
44
37
|
end
|
45
38
|
end
|
@@ -23,6 +23,7 @@ Ohai.plugin(:Memory) do
|
|
23
23
|
memory Mash.new
|
24
24
|
memory[:swap] = Mash.new
|
25
25
|
memory[:hugepages] = Mash.new
|
26
|
+
memory[:directmap] = Mash.new
|
26
27
|
|
27
28
|
File.open("/proc/meminfo").each do |line|
|
28
29
|
case line
|
@@ -94,6 +95,10 @@ Ohai.plugin(:Memory) do
|
|
94
95
|
memory[:hugepages][:surplus] = $1.to_s
|
95
96
|
when /^Hugepagesize:\s+(\d+) (.+)$/
|
96
97
|
memory[:hugepage_size] = "#{$1}#{$2}"
|
98
|
+
when /^Hugetlb:\s+(\d+) (.+)$/
|
99
|
+
memory[:hugetlb] = "#{$1}#{$2}"
|
100
|
+
when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)$/
|
101
|
+
memory[:directmap][$1.to_sym] = "#{$2}#{$3}"
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -491,7 +491,7 @@ Ohai.plugin(:Network) do
|
|
491
491
|
# Match the lead line for an interface from iproute2
|
492
492
|
# 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
|
493
493
|
# The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
|
494
|
-
IPROUTE_INT_REGEX = /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s
|
494
|
+
IPROUTE_INT_REGEX = /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/.freeze unless defined? IPROUTE_INT_REGEX
|
495
495
|
|
496
496
|
if which("ip")
|
497
497
|
# families to get default routes from
|
@@ -20,16 +20,39 @@ Ohai.plugin(:Platform) do
|
|
20
20
|
provides "platform", "platform_version", "platform_family"
|
21
21
|
depends "lsb"
|
22
22
|
|
23
|
+
# the platform mappings between the 'ID' field in /etc/os-release and the value
|
24
|
+
# ohai uses. If you're adding a new platform here and you want to change the name
|
25
|
+
# you'll want to add it here and then add a spec for the platform_id_remap method
|
26
|
+
unless defined?(PLATFORM_MAPPINGS)
|
27
|
+
PLATFORM_MAPPINGS = {
|
28
|
+
"rhel" => "redhat",
|
29
|
+
"amzn" => "amazon",
|
30
|
+
"ol" => "oracle",
|
31
|
+
"sles" => "suse",
|
32
|
+
"sles_sap" => "suse",
|
33
|
+
"opensuse-leap" => "opensuseleap",
|
34
|
+
"xenenterprise" => "xenserver",
|
35
|
+
"cumulus-linux" => "cumulus",
|
36
|
+
}.freeze
|
37
|
+
end
|
38
|
+
|
39
|
+
# @deprecated
|
23
40
|
def get_redhatish_platform(contents)
|
24
41
|
contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
|
25
42
|
end
|
26
43
|
|
27
44
|
# Amazon Linux AMI release 2013.09
|
28
45
|
# Amazon Linux 2
|
46
|
+
# Amazon Linux 2 (Karoo)
|
29
47
|
# Fedora release 28 (Twenty Eight)
|
30
48
|
# CentOS release 5.8 (Final)
|
31
49
|
# CentOS release 6.7 (Final)
|
32
50
|
# Red Hat Enterprise Linux Server release 7.5 (Maipo)
|
51
|
+
#
|
52
|
+
# @param contents [String] the contents of /etc/redhat-release
|
53
|
+
#
|
54
|
+
# @returns [String] the version string
|
55
|
+
#
|
33
56
|
def get_redhatish_version(contents)
|
34
57
|
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
|
35
58
|
end
|
@@ -78,22 +101,11 @@ Ohai.plugin(:Platform) do
|
|
78
101
|
File.exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
|
79
102
|
end
|
80
103
|
|
81
|
-
#
|
82
|
-
# Determines the platform version for Cumulus Linux systems
|
83
|
-
#
|
84
|
-
# @returns [String] cumulus Linux version from /etc/cumulus/etc.replace/os-release
|
85
|
-
#
|
86
|
-
def cumulus_version
|
87
|
-
release_contents = File.read("/etc/cumulus/etc.replace/os-release")
|
88
|
-
release_contents.match(/VERSION_ID=(.*)/)[1]
|
89
|
-
rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
|
90
|
-
logger.warn("Detected Cumulus Linux, but /etc/cumulus/etc/replace/os-release could not be parsed to determine platform_version")
|
91
|
-
nil
|
92
|
-
end
|
93
|
-
|
94
104
|
#
|
95
105
|
# Determines the platform version for F5 Big-IP systems
|
96
106
|
#
|
107
|
+
# @deprecated
|
108
|
+
#
|
97
109
|
# @returns [String] bigip Linux version from /etc/f5-release
|
98
110
|
#
|
99
111
|
def bigip_version
|
@@ -104,27 +116,32 @@ Ohai.plugin(:Platform) do
|
|
104
116
|
nil
|
105
117
|
end
|
106
118
|
|
119
|
+
# our platform names don't match os-release. given a time machine they would but ohai
|
120
|
+
# came before the os-release file. This method remaps the os-release names to
|
121
|
+
# the ohai names
|
107
122
|
#
|
108
|
-
#
|
123
|
+
# @param id [String] the platform ID from /etc/os-release
|
109
124
|
#
|
110
|
-
# @returns [String]
|
125
|
+
# @returns [String] the platform name to use in Ohai
|
111
126
|
#
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
127
|
+
def platform_id_remap(id)
|
128
|
+
# this catches the centos guest shell in the nexus switch which identifies itself as centos
|
129
|
+
return "nexus_centos" if id == "centos" && os_release_file_is_cisco?
|
130
|
+
|
131
|
+
# remap based on the hash of platforms
|
132
|
+
PLATFORM_MAPPINGS[id] || id
|
118
133
|
end
|
119
134
|
|
120
135
|
#
|
121
136
|
# Determines the platform_family based on the platform
|
122
137
|
#
|
138
|
+
# @param plat [String] the platform name
|
139
|
+
#
|
123
140
|
# @returns [String] platform_family value
|
124
141
|
#
|
125
|
-
def
|
126
|
-
case
|
127
|
-
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/
|
142
|
+
def platform_family_from_platform(plat)
|
143
|
+
case plat
|
144
|
+
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/
|
128
145
|
# apt-get+dpkg almost certainly goes here
|
129
146
|
"debian"
|
130
147
|
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xcp/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
@@ -162,7 +179,13 @@ Ohai.plugin(:Platform) do
|
|
162
179
|
end
|
163
180
|
end
|
164
181
|
|
165
|
-
|
182
|
+
# modern linux distros include a /etc/os-release file, which we now rely on for
|
183
|
+
# OS detection. For older distros that do not include that file we fall back to
|
184
|
+
# our pre-Ohai 15 detection logic, which is the method below. No new functionality
|
185
|
+
# should be added to this logic.
|
186
|
+
#
|
187
|
+
# @deprecated
|
188
|
+
def legacy_platform_detection
|
166
189
|
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
167
190
|
if File.exist?("/etc/oracle-release")
|
168
191
|
contents = File.read("/etc/oracle-release").chomp
|
@@ -181,18 +204,9 @@ Ohai.plugin(:Platform) do
|
|
181
204
|
if lsb[:id] =~ /Ubuntu/i
|
182
205
|
platform "ubuntu"
|
183
206
|
platform_version lsb[:release]
|
184
|
-
elsif lsb[:id] =~ /LinuxMint/i
|
185
|
-
platform "linuxmint"
|
186
|
-
platform_version lsb[:release]
|
187
207
|
else
|
188
|
-
|
189
|
-
|
190
|
-
elsif Dir.exist?("/etc/cumulus")
|
191
|
-
platform "cumulus"
|
192
|
-
else
|
193
|
-
platform "debian"
|
194
|
-
end
|
195
|
-
platform_version debian_platform_version
|
208
|
+
platform "debian"
|
209
|
+
platform_version File.read("/etc/debian_version").chomp
|
196
210
|
end
|
197
211
|
elsif File.exist?("/etc/parallels-release")
|
198
212
|
contents = File.read("/etc/parallels-release").chomp
|
@@ -202,14 +216,9 @@ Ohai.plugin(:Platform) do
|
|
202
216
|
platform "arista_eos"
|
203
217
|
platform_version File.read("/etc/Eos-release").strip.split[-1]
|
204
218
|
elsif File.exist?("/etc/redhat-release")
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
else
|
209
|
-
contents = File.read("/etc/redhat-release").chomp
|
210
|
-
platform get_redhatish_platform(contents)
|
211
|
-
platform_version get_redhatish_version(contents)
|
212
|
-
end
|
219
|
+
contents = File.read("/etc/redhat-release").chomp
|
220
|
+
platform get_redhatish_platform(contents)
|
221
|
+
platform_version get_redhatish_version(contents)
|
213
222
|
elsif File.exist?("/etc/system-release")
|
214
223
|
contents = File.read("/etc/system-release").chomp
|
215
224
|
platform get_redhatish_platform(contents)
|
@@ -231,7 +240,7 @@ Ohai.plugin(:Platform) do
|
|
231
240
|
end
|
232
241
|
elsif os_release_file_is_cisco?
|
233
242
|
raise "unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field" if
|
234
|
-
os_release_info["ID_LIKE"].nil? || !
|
243
|
+
os_release_info["ID_LIKE"].nil? || !os_release_info["ID_LIKE"].include?("wrlinux")
|
235
244
|
|
236
245
|
case os_release_info["ID"]
|
237
246
|
when "nexus"
|
@@ -242,34 +251,18 @@ Ohai.plugin(:Platform) do
|
|
242
251
|
raise "unknown Cisco /etc/os-release or /etc/cisco-release ID field"
|
243
252
|
end
|
244
253
|
|
245
|
-
platform_family "wrlinux"
|
246
254
|
platform_version os_release_info["VERSION"]
|
247
|
-
elsif File.exist?("/etc/gentoo-release")
|
248
|
-
platform "gentoo"
|
249
|
-
# the gentoo release version is the base version used to bootstrap
|
250
|
-
# a node and doesn't have a lot of meaning in a rolling release distro
|
251
|
-
# kernel release will be used - ex. 3.18.7-gentoo
|
252
|
-
platform_version shell_out("/bin/uname -r").stdout.strip
|
253
255
|
elsif File.exist?("/etc/slackware-version")
|
254
256
|
platform "slackware"
|
255
257
|
platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
256
|
-
elsif File.exist?("/etc/arch-release")
|
257
|
-
platform "arch"
|
258
|
-
# no way to determine platform_version in a rolling release distribution
|
259
|
-
# kernel release will be used - ex. 2.6.32-ARCH
|
260
|
-
platform_version shell_out("/bin/uname -r").stdout.strip
|
261
258
|
elsif File.exist?("/etc/exherbo-release")
|
262
259
|
platform "exherbo"
|
263
260
|
# no way to determine platform_version in a rolling release distribution
|
264
261
|
# kernel release will be used - ex. 3.13
|
265
262
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
266
|
-
elsif File.exist?("/
|
267
|
-
platform "alpine"
|
268
|
-
platform_version File.read("/etc/alpine-release").strip
|
269
|
-
# If /etc/os-release file exists, we take that as source of truth
|
270
|
-
elsif File.exist?("/usr/lib/os-release") && !File.exist?("/etc/os-release")
|
263
|
+
elsif File.exist?("/usr/lib/os-release")
|
271
264
|
contents = File.read("/usr/lib/os-release")
|
272
|
-
if /
|
265
|
+
if /clear-linux-os/ =~ contents # Clear Linux https://clearlinux.org/
|
273
266
|
platform "clearlinux"
|
274
267
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
275
268
|
end
|
@@ -291,27 +284,35 @@ Ohai.plugin(:Platform) do
|
|
291
284
|
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties
|
292
285
|
platform lsb[:id].downcase
|
293
286
|
platform_version lsb[:release]
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
# Grab the version from the VERSION_ID field and use the kernel release if that's not
|
291
|
+
# available. It should be there for everything, but rolling releases like arch / gentoo
|
292
|
+
# where we've traditionally used the kernel as the version
|
293
|
+
# @return String the OS version
|
294
|
+
def determine_os_version
|
295
|
+
# centos only includes the major version in os-release for some reason
|
296
|
+
if os_release_info["ID"] == "centos"
|
297
|
+
get_redhatish_version(File.read("/etc/redhat-release").chomp)
|
298
|
+
else
|
299
|
+
os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
collect_data(:linux) do
|
304
|
+
if ::File.exist?("/etc/os-release")
|
305
|
+
logger.trace("Plugin platform: Using /etc/os-release for platform detection")
|
306
|
+
|
307
|
+
# fixup os-release names to ohai platform names
|
308
|
+
platform platform_id_remap(os_release_info["ID"])
|
309
|
+
|
310
|
+
platform_version determine_os_version
|
311
|
+
else # we're on an old Linux distro
|
312
|
+
legacy_platform_detection
|
313
313
|
end
|
314
314
|
|
315
|
-
|
315
|
+
# unless we set it in a specific way with the platform logic above set based on platform data
|
316
|
+
platform_family platform_family_from_platform(platform) if platform_family.nil?
|
316
317
|
end
|
317
318
|
end
|