ohai 18.1.3 → 18.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/lib/ohai/application.rb +1 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +2 -2
- data/lib/ohai/loader.rb +5 -5
- data/lib/ohai/mixin/alibaba_metadata.rb +23 -13
- data/lib/ohai/mixin/azure_metadata.rb +2 -1
- data/lib/ohai/mixin/ec2_metadata.rb +8 -2
- data/lib/ohai/mixin/gce_metadata.rb +4 -2
- data/lib/ohai/mixin/network_helper.rb +28 -1
- data/lib/ohai/mixin/string.rb +1 -1
- data/lib/ohai/plugins/aix/kernel.rb +2 -2
- data/lib/ohai/plugins/aix/network.rb +1 -1
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/alibaba.rb +1 -1
- data/lib/ohai/plugins/cpu.rb +10 -3
- data/lib/ohai/plugins/darwin/platform.rb +3 -1
- data/lib/ohai/plugins/darwin/virtualization.rb +16 -2
- data/lib/ohai/plugins/filesystem.rb +14 -12
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/linux/interrupts.rb +2 -3
- data/lib/ohai/plugins/linux/lspci.rb +5 -1
- data/lib/ohai/plugins/linux/network.rb +2 -2
- data/lib/ohai/plugins/packages.rb +3 -3
- data/lib/ohai/plugins/passwd.rb +1 -1
- data/lib/ohai/plugins/platform.rb +13 -1
- data/lib/ohai/plugins/rackspace.rb +1 -1
- data/lib/ohai/provides_map.rb +5 -5
- data/lib/ohai/runner.rb +1 -3
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc1e862dfe2a3422ef70b91b2564c12e2ca00d48bee8b48960b89af65e07bc5c
|
4
|
+
data.tar.gz: efcd968a8da9052c51bfc3aaffddd8fe8c57fe571700196f9326821f24d2f852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1717b87c35a7b0dde1b5df9366fef96b2656d63a15be005baa52c42206e811623922421fc9aaf6ceb2fce61edb077e95d3613a057f73d69d2297f94cd52661f3
|
7
|
+
data.tar.gz: ead72e1e179af3e3c2037deda21c4a4fc1a8cc8f56aa75784759f143c412c113a92ee5b1a6baf8a89ab8336dde6e84cd1aea9ef49947e30e36eac93562c411ba
|
data/Gemfile
CHANGED
@@ -4,19 +4,19 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
# pull these gems from main of chef/chef so that we're testing against what we will release
|
7
|
-
gem "chef-config", git: "https://github.com/chef/chef", branch: "
|
8
|
-
gem "chef-utils", git: "https://github.com/chef/chef", branch: "
|
7
|
+
gem "chef-config", git: "https://github.com/chef/chef", branch: "chef-18", glob: "chef-config/chef-config.gemspec"
|
8
|
+
gem "chef-utils", git: "https://github.com/chef/chef", branch: "chef-18", glob: "chef-utils/chef-utils.gemspec"
|
9
9
|
|
10
10
|
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
|
11
11
|
group :development do
|
12
|
-
gem "
|
12
|
+
gem "cookstyle", ">= 7.32.8"
|
13
13
|
gem "ipaddr_extensions"
|
14
14
|
gem "rake", ">= 10.1.0"
|
15
15
|
gem "rspec-collection_matchers", "~> 1.0"
|
16
16
|
gem "rspec-core", "~> 3.0"
|
17
17
|
gem "rspec-expectations", "~> 3.0"
|
18
18
|
gem "rspec-mocks", "~> 3.0"
|
19
|
-
gem "rubocop-performance", "1.
|
19
|
+
gem "rubocop-performance", "1.18.0"
|
20
20
|
gem "rubocop-rspec"
|
21
21
|
end
|
22
22
|
|
data/lib/ohai/application.rb
CHANGED
@@ -49,7 +49,7 @@ class Ohai::Application
|
|
49
49
|
short: "-l LEVEL",
|
50
50
|
long: "--log_level LEVEL",
|
51
51
|
description: "Set the log level (debug, info, warn, error, fatal)",
|
52
|
-
proc: lambda
|
52
|
+
proc: lambda(&:to_sym)
|
53
53
|
|
54
54
|
option :log_location,
|
55
55
|
short: "-L LOGLOCATION",
|
@@ -149,11 +149,11 @@ module Ohai
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def provides(*paths)
|
152
|
-
logger.warn("[UNSUPPORTED OPERATION]
|
152
|
+
logger.warn("[UNSUPPORTED OPERATION] 'provides' is no longer supported in a 'collect_data' context. Please specify 'provides' before collecting plugin data. Ignoring command 'provides #{paths.join(", ")}")
|
153
153
|
end
|
154
154
|
|
155
155
|
def require_plugin(*args)
|
156
|
-
logger.warn("[UNSUPPORTED OPERATION]
|
156
|
+
logger.warn("[UNSUPPORTED OPERATION] 'require_plugin' is no longer supported. Please use 'depends' instead.\nIgnoring plugin(s) #{args.join(", ")}")
|
157
157
|
end
|
158
158
|
|
159
159
|
def configuration(option, *options)
|
data/lib/ohai/loader.rb
CHANGED
@@ -100,7 +100,7 @@ module Ohai
|
|
100
100
|
contents = ""
|
101
101
|
begin
|
102
102
|
logger.trace("Loading plugin at #{plugin_path}")
|
103
|
-
contents <<
|
103
|
+
contents << File.read(plugin_path)
|
104
104
|
rescue IOError, Errno::ENOENT
|
105
105
|
logger.warn("Unable to open or read plugin at #{plugin_path}")
|
106
106
|
return nil
|
@@ -110,9 +110,9 @@ module Ohai
|
|
110
110
|
if contents.include?("Ohai.plugin")
|
111
111
|
load_v7_plugin_class(contents, plugin_path)
|
112
112
|
else
|
113
|
-
raise Exceptions::IllegalPluginDefinition, "[DEPRECATION] Plugin at #{plugin_path}"\
|
114
|
-
" is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This"\
|
115
|
-
" plugin will need to be updated to the v7 Ohai plugin format. See"\
|
113
|
+
raise Exceptions::IllegalPluginDefinition, "[DEPRECATION] Plugin at #{plugin_path}" \
|
114
|
+
" is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This" \
|
115
|
+
" plugin will need to be updated to the v7 Ohai plugin format. See" \
|
116
116
|
" https://docs.chef.io/ohai_custom.html for v7 syntax."
|
117
117
|
end
|
118
118
|
end
|
@@ -151,7 +151,7 @@ module Ohai
|
|
151
151
|
rescue Ohai::Exceptions::IllegalPluginDefinition => e
|
152
152
|
logger.warn("Plugin Definition Error: <#{plugin_path}>: #{e.message}")
|
153
153
|
rescue NoMethodError => e
|
154
|
-
logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation
|
154
|
+
logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation '#{e.name}'")
|
155
155
|
rescue SyntaxError => e
|
156
156
|
# split on occurrences of
|
157
157
|
# <env>: syntax error,
|
@@ -41,23 +41,26 @@ module Ohai
|
|
41
41
|
conn.get("/2016-01-01/#{uri}", { "User-Agent" => "chef-ohai/#{Ohai::VERSION}" })
|
42
42
|
end
|
43
43
|
|
44
|
-
def fetch_metadata(id = "")
|
44
|
+
def fetch_metadata(id = "", is_directory = true)
|
45
45
|
response = http_get(id)
|
46
46
|
if response.code == "200"
|
47
|
-
|
48
|
-
if
|
49
|
-
|
50
|
-
if
|
51
|
-
temp = {}
|
52
|
-
response.body.split("\n").each do |sub_attr|
|
53
|
-
temp[sanitize_key(sub_attr)] = fetch_metadata("#{id}/#{sub_attr}")
|
54
|
-
end
|
55
|
-
temp
|
56
|
-
else
|
47
|
+
|
48
|
+
if !is_directory
|
49
|
+
json_data = parse_json(response.body)
|
50
|
+
if json_data.nil?
|
57
51
|
response.body
|
52
|
+
else
|
53
|
+
json_data
|
58
54
|
end
|
59
|
-
|
60
|
-
|
55
|
+
elsif is_directory
|
56
|
+
temp = {}
|
57
|
+
response.body.split("\n").each do |sub_attr|
|
58
|
+
if "#{id}/#{sub_attr}" != "/user-data"
|
59
|
+
uri = id == "" ? "#{id}#{sub_attr}/" : "#{id}#{sub_attr}"
|
60
|
+
temp[sanitize_key(sub_attr).gsub(/_$/, "")] = fetch_metadata(uri, has_trailing_slash?(uri))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
temp
|
61
64
|
end
|
62
65
|
else
|
63
66
|
logger.warn("Mixin AlibabaMetadata: Received response code #{response.code} requesting metadata for id='#{id}'")
|
@@ -65,6 +68,13 @@ module Ohai
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
71
|
+
# @param data [String]
|
72
|
+
#
|
73
|
+
# @return [Boolean] is there a trailing /?
|
74
|
+
def has_trailing_slash?(data)
|
75
|
+
!!(data =~ %r{/$})
|
76
|
+
end
|
77
|
+
|
68
78
|
def sanitize_key(key)
|
69
79
|
key.gsub(%r{\-|/}, "_")
|
70
80
|
end
|
@@ -41,7 +41,8 @@ module Ohai
|
|
41
41
|
AZURE_SUPPORTED_VERSIONS ||= %w{ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
|
42
42
|
2019-06-04 2019-08-01 2019-08-15 2019-11-01 2020-06-01
|
43
43
|
2020-07-15 2020-09-01 2020-10-01 2020-12-01 2021-01-01
|
44
|
-
2021-02-01 2021-03-01 2021-05-01 2021-10-01
|
44
|
+
2021-02-01 2021-03-01 2021-05-01 2021-10-01 2021-11-01
|
45
|
+
2021-11-15 2021-12-13 2023-07-01 }.freeze
|
45
46
|
|
46
47
|
def best_api_version
|
47
48
|
@api_version ||= begin
|
@@ -248,8 +248,14 @@ module Ohai
|
|
248
248
|
private
|
249
249
|
|
250
250
|
def expand_path(file_name)
|
251
|
-
|
252
|
-
|
251
|
+
# First substitution - exactly matches original behavior but safer
|
252
|
+
path = if file_name.include?("=")
|
253
|
+
file_name[0...file_name.index("=")] + "/"
|
254
|
+
else
|
255
|
+
file_name.dup
|
256
|
+
end
|
257
|
+
|
258
|
+
# Handle relative path components
|
253
259
|
path.gsub(%r{/\.\.?(?:/|$)}, "/")
|
254
260
|
.sub(%r{^\.\.?(?:/|$)}, "")
|
255
261
|
.sub(/^$/, "/")
|
@@ -26,7 +26,7 @@ module Ohai
|
|
26
26
|
|
27
27
|
# Trailing dot to host is added to avoid DNS search path
|
28
28
|
GCE_METADATA_ADDR ||= "metadata.google.internal."
|
29
|
-
GCE_METADATA_URL ||= "/computeMetadata/v1
|
29
|
+
GCE_METADATA_URL ||= "/computeMetadata/v1"
|
30
30
|
|
31
31
|
# fetch the meta content with a timeout and the required header
|
32
32
|
def http_get(uri)
|
@@ -39,7 +39,9 @@ module Ohai
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def fetch_metadata(id = "")
|
42
|
-
|
42
|
+
url = "#{GCE_METADATA_URL}/#{id}"
|
43
|
+
url = "#{url}?recursive=true" if url.end_with?("/")
|
44
|
+
response = http_get(url)
|
43
45
|
if response.code == "200"
|
44
46
|
json_data = parse_json(response.body)
|
45
47
|
if json_data.nil?
|
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
require "socket" unless defined?(Socket)
|
22
|
+
require "resolv" unless defined?(Resolv)
|
22
23
|
|
23
24
|
module Ohai
|
24
25
|
module Mixin
|
@@ -37,6 +38,12 @@ module Ohai
|
|
37
38
|
dec
|
38
39
|
end
|
39
40
|
|
41
|
+
# Addrinfo#ip*? methods return true on AI_CANONNAME Addrinfo records that match
|
42
|
+
# the ipv* scheme and #ip? always returns true unless a non tcp Addrinfo
|
43
|
+
def ip?(hostname)
|
44
|
+
Resolv::IPv4::Regex.match?(hostname) || Resolv::IPv6::Regex.match?(hostname)
|
45
|
+
end
|
46
|
+
|
40
47
|
# This does a forward and reverse lookup on the hostname to return what should be
|
41
48
|
# the FQDN for the host determined by name lookup (generally DNS). If the forward
|
42
49
|
# lookup fails this will throw. If the reverse lookup fails this will return the
|
@@ -47,7 +54,27 @@ module Ohai
|
|
47
54
|
# server), and the method should return the hostname and not the IP address.
|
48
55
|
#
|
49
56
|
def canonicalize_hostname(hostname)
|
50
|
-
|
57
|
+
ai = Addrinfo
|
58
|
+
.getaddrinfo(hostname, nil, nil, nil, nil, Socket::AI_CANONNAME)
|
59
|
+
.first
|
60
|
+
|
61
|
+
canonname = ai&.canonname
|
62
|
+
# use canonname if it's an FQDN
|
63
|
+
# This API is preferred as it never gives us an IP address for broken DNS
|
64
|
+
# (see https://github.com/chef/ohai/pull/1705)
|
65
|
+
# However, we have found that Windows hosts that are not joined to a domain
|
66
|
+
# can return a non-qualified hostname).
|
67
|
+
# Use a '.' in the canonname as indicator of FQDN
|
68
|
+
return canonname if canonname.include?(".")
|
69
|
+
|
70
|
+
# If we got a non-qualified name, then we do a standard reverse resolve
|
71
|
+
# which, assuming DNS is working, will work around that windows bug
|
72
|
+
# (and maybe others)
|
73
|
+
canonname = ai&.getnameinfo&.first
|
74
|
+
return canonname unless ip?(canonname)
|
75
|
+
|
76
|
+
# if all else fails, return the name we were given as a safety
|
77
|
+
hostname
|
51
78
|
end
|
52
79
|
|
53
80
|
def canonicalize_hostname_with_retries(hostname)
|
data/lib/ohai/mixin/string.rb
CHANGED
@@ -25,7 +25,7 @@ class String
|
|
25
25
|
# ActiveSupport::CoreExtensions::String::Inflections
|
26
26
|
# @return [String]
|
27
27
|
def wmi_underscore
|
28
|
-
gsub(
|
28
|
+
gsub("::", "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
29
29
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
|
30
30
|
end
|
31
31
|
end
|
@@ -26,11 +26,11 @@ Ohai.plugin(:Kernel) do
|
|
26
26
|
|
27
27
|
uname_so = shell_out("uname -rvp").stdout.split
|
28
28
|
|
29
|
-
kernel[:name] =
|
29
|
+
kernel[:name] = "aix" # this is here for historical reasons, but it's always aix
|
30
30
|
kernel[:release] = uname_so[0]
|
31
31
|
kernel[:version] = uname_so[1]
|
32
32
|
kernel[:machine] = uname_so[2]
|
33
|
-
kernel[:bits] =
|
33
|
+
kernel[:bits] = shell_out("getconf KERNEL_BITMODE").stdout.strip
|
34
34
|
|
35
35
|
modules = Mash.new
|
36
36
|
so = shell_out("genkex -d")
|
@@ -143,7 +143,7 @@ Ohai.plugin(:Virtualization) do
|
|
143
143
|
evalstr = "wpars['#{wpar_name}']"
|
144
144
|
breadcrumb = attribute.split(".")
|
145
145
|
breadcrumb.each do |node|
|
146
|
-
evalstr << "[
|
146
|
+
evalstr << "['#{node}']"
|
147
147
|
end
|
148
148
|
wpars[wpar_name][breadcrumb[-1]] = eval evalstr # rubocop: disable Security/Eval
|
149
149
|
end
|
data/lib/ohai/plugins/alibaba.rb
CHANGED
@@ -54,7 +54,7 @@ Ohai.plugin(:Alibaba) do
|
|
54
54
|
# a single check that combines all the various detection methods for Alibaba
|
55
55
|
# @return [Boolean] Does the system appear to be on Alibaba
|
56
56
|
def looks_like_alibaba?
|
57
|
-
|
57
|
+
true if hint?("alibaba") || has_ali_dmi?
|
58
58
|
end
|
59
59
|
|
60
60
|
collect_data do
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -63,7 +63,8 @@ Ohai.plugin(:CPU) do
|
|
63
63
|
def parse_lscpu(cpu_info)
|
64
64
|
lscpu_info = Mash.new
|
65
65
|
begin
|
66
|
-
|
66
|
+
# Pipe to cat to retain previous output on newer util-linux (see lscpu(1))
|
67
|
+
so = shell_out("lscpu | cat")
|
67
68
|
cpu_cores = shell_out("lscpu -p=CPU,CORE,SOCKET")
|
68
69
|
if so.exitstatus == 0 && cpu_cores.exitstatus == 0
|
69
70
|
lscpu_info[:numa_node_cpus] = Mash.new
|
@@ -96,10 +97,12 @@ Ohai.plugin(:CPU) do
|
|
96
97
|
end
|
97
98
|
when /^Thread\(s\) per core:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
|
98
99
|
lscpu_info[:threads_per_core] = $1.to_i
|
99
|
-
when /^Core\(s\) per socket:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
|
100
|
+
when /^Core\(s\) per (?:socket|cluster):\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q
|
100
101
|
lscpu_info[:cores_per_socket] = $1.to_i
|
101
102
|
when /^Socket\(s\):\s+(.+)/ # http://rubular.com/r/DIzmPtJFvK
|
102
103
|
lscpu_info[:sockets] = $1.to_i
|
104
|
+
when /^Clusters\(s\):\s+(.+)/
|
105
|
+
lscpu_info[:clusters] = $1.to_i
|
103
106
|
when /^Socket\(s\) per book:\s+(.+)/
|
104
107
|
lscpu_info[:sockets_per_book] = $1.to_i
|
105
108
|
when /^Book\(s\) per drawer:\s+(.+)/
|
@@ -110,6 +113,10 @@ Ohai.plugin(:CPU) do
|
|
110
113
|
lscpu_info[:numa_nodes] = $1.to_i
|
111
114
|
when /^Vendor ID:\s+(.+)/
|
112
115
|
lscpu_info[:vendor_id] = $1
|
116
|
+
when /^BIOS Vendor ID:\s+(.+)/
|
117
|
+
lscpu_info[:bios_vendor_id] = $1
|
118
|
+
when /^BIOS Model name:\s+(.+)/
|
119
|
+
lscpu_info[:bios_model_name] = $1.strip
|
113
120
|
when /^Machine type:\s+(.+)/
|
114
121
|
lscpu_info[:machine_type] = $1
|
115
122
|
when /^CPU family:\s+(.+)/
|
@@ -630,6 +637,6 @@ Ohai.plugin(:CPU) do
|
|
630
637
|
|
631
638
|
cpu[:total] = logical_processors
|
632
639
|
cpu[:cores] = cores
|
633
|
-
cpu[:real] =
|
640
|
+
cpu[:real] = processors.length
|
634
641
|
end
|
635
642
|
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
Ohai.plugin(:Platform) do
|
21
|
-
provides "platform", "platform_version", "platform_build", "platform_family"
|
21
|
+
provides "platform", "platform_version", "platform_version_extra", "platform_build", "platform_family"
|
22
22
|
|
23
23
|
collect_data(:darwin) do
|
24
24
|
so = shell_out(Ohai.abs_path( "/usr/bin/sw_vers" ).to_s)
|
@@ -26,6 +26,8 @@ Ohai.plugin(:Platform) do
|
|
26
26
|
case line
|
27
27
|
when /^ProductVersion:\s+(.+)$/
|
28
28
|
platform_version $1
|
29
|
+
when /^ProductVersionExtra:\s+(.+)$/
|
30
|
+
platform_version_extra $1
|
29
31
|
when /^BuildVersion:\s+(.+)$/
|
30
32
|
platform_build $1
|
31
33
|
end
|
@@ -36,13 +36,17 @@ Ohai.plugin(:Virtualization) do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def fusion_exists?
|
39
|
-
file_exist?("/Applications/VMware
|
39
|
+
file_exist?("/Applications/VMware Fusion.app/")
|
40
40
|
end
|
41
41
|
|
42
42
|
def docker_exists?
|
43
43
|
which("docker")
|
44
44
|
end
|
45
45
|
|
46
|
+
def sysctl_exists?
|
47
|
+
which("sysctl")
|
48
|
+
end
|
49
|
+
|
46
50
|
collect_data(:darwin) do
|
47
51
|
virtualization Mash.new unless virtualization
|
48
52
|
virtualization[:systems] ||= Mash.new
|
@@ -77,6 +81,11 @@ Ohai.plugin(:Virtualization) do
|
|
77
81
|
virtualization[:systems][:vmware] = "guest"
|
78
82
|
end
|
79
83
|
|
84
|
+
if sysctl_exists? && shell_out("sysctl -in kern.hv_vmm_present").stdout.strip.to_i == 1
|
85
|
+
virtualization[:system] = "qemu"
|
86
|
+
virtualization[:role] = "guest"
|
87
|
+
end
|
88
|
+
|
80
89
|
if ioreg_exists? && shell_out("ioreg -l").stdout.include?("pci1ab8,4000")
|
81
90
|
virtualization[:system] = "parallels"
|
82
91
|
virtualization[:role] = "guest"
|
@@ -86,5 +95,10 @@ Ohai.plugin(:Virtualization) do
|
|
86
95
|
virtualization[:role] = "host"
|
87
96
|
virtualization[:systems][:parallels] = "host"
|
88
97
|
end
|
98
|
+
|
99
|
+
if hardware["machine_model"].include? "VirtualMac"
|
100
|
+
virtualization[:system] = "apple"
|
101
|
+
virtualization[:role] = "guest"
|
102
|
+
end
|
89
103
|
end
|
90
|
-
end
|
104
|
+
end
|
@@ -276,19 +276,21 @@ Ohai.plugin(:Filesystem) do
|
|
276
276
|
if entry[:fs_type] == "btrfs" && entry["uuid"]
|
277
277
|
uuid = entry["uuid"]
|
278
278
|
alloc = "/sys/fs/btrfs/#{uuid}/allocation"
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
279
|
+
if Dir.exist?(alloc)
|
280
|
+
%w{data metadata system}.each do |bg_type|
|
281
|
+
dir = "#{alloc}/#{bg_type}"
|
282
|
+
%w{single dup}.each do |raid|
|
283
|
+
if file_exist?("#{dir}/#{raid}")
|
284
|
+
btrfs["raid"] = raid
|
285
|
+
end
|
286
|
+
end
|
287
|
+
logger.trace("Plugin Filesystem: reading btrfs allocation files at #{dir}")
|
288
|
+
btrfs["allocation"] ||= Mash.new
|
289
|
+
btrfs["allocation"][bg_type] ||= Mash.new
|
290
|
+
%w{total_bytes bytes_used}.each do |field|
|
291
|
+
bytes = file_read("#{dir}/#{field}").chomp.to_i
|
292
|
+
btrfs["allocation"][bg_type][field] = "#{bytes}"
|
284
293
|
end
|
285
|
-
end
|
286
|
-
logger.trace("Plugin Filesystem: reading btrfs allocation files at #{dir}")
|
287
|
-
btrfs["allocation"] ||= Mash.new
|
288
|
-
btrfs["allocation"][bg_type] ||= Mash.new
|
289
|
-
%w{total_bytes bytes_used}.each do |field|
|
290
|
-
bytes = file_read("#{dir}/#{field}").chomp.to_i
|
291
|
-
btrfs["allocation"][bg_type][field] = "#{bytes}"
|
292
294
|
end
|
293
295
|
end
|
294
296
|
end
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -72,7 +72,7 @@ Ohai.plugin(:GCE) do
|
|
72
72
|
return true if hint?("gce")
|
73
73
|
|
74
74
|
if has_gce_dmi? || has_gce_system_info?
|
75
|
-
|
75
|
+
true if can_socket_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -27,9 +27,8 @@ Ohai.plugin(:Interrupts) do
|
|
27
27
|
# each bit is a CPU, right to left ordering (i.e. CPU0 is rightmost)
|
28
28
|
def parse_smp_affinity(path, cpus)
|
29
29
|
masks = file_read(path).strip
|
30
|
-
bit_masks =
|
31
|
-
|
32
|
-
bit_masks << mask.rjust(8, "0").to_i(16).to_s(2)
|
30
|
+
bit_masks = masks.split(",").map do |mask|
|
31
|
+
mask.rjust(8, "0").to_i(16).to_s(2)
|
33
32
|
end
|
34
33
|
affinity_mask = bit_masks.join
|
35
34
|
affinity_by_cpu = affinity_mask.split("").reverse
|
@@ -51,10 +51,14 @@ Ohai.plugin(:Lspci) do
|
|
51
51
|
|
52
52
|
case dev[0]
|
53
53
|
when "Device" # There are two different Device tags
|
54
|
-
if ( tmp = dev[1].match(/(#{hh}:#{hh}
|
54
|
+
if ( tmp = dev[1].match(/(#{hhhh}:)?(#{hh}:#{hh}\.#{h})/) )
|
55
55
|
# We have a device id
|
56
56
|
d_id = tmp[0] # From now on we will need this id
|
57
57
|
devices[d_id] = Mash.new
|
58
|
+
if tmp[1]
|
59
|
+
# We have a root complex
|
60
|
+
devices[d_id]["root_port"] = tmp[1][0..-2]
|
61
|
+
end
|
58
62
|
else
|
59
63
|
standard_form(devices, d_id, hhhh, "device", dev[1])
|
60
64
|
end
|
@@ -104,7 +104,7 @@ Ohai.plugin(:Network) do
|
|
104
104
|
end
|
105
105
|
route_endings.each do |route_ending|
|
106
106
|
route_entry = Mash.new(destination: route_dest,
|
107
|
-
|
107
|
+
family: family[:name])
|
108
108
|
route_int = nil
|
109
109
|
if route_ending =~ /\bdev\s+([^\s]+)\b/
|
110
110
|
route_int = $1
|
@@ -700,7 +700,7 @@ Ohai.plugin(:Network) do
|
|
700
700
|
# Match the lead line for an interface from iproute2
|
701
701
|
# 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
|
702
702
|
# The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
|
703
|
-
IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/.freeze
|
703
|
+
IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z\-_]+|):\s/.freeze
|
704
704
|
|
705
705
|
if which("ip")
|
706
706
|
# families to get default routes from
|
@@ -33,13 +33,13 @@ Ohai.plugin(:Packages) do
|
|
33
33
|
packages Mash.new
|
34
34
|
case platform_family
|
35
35
|
when "debian"
|
36
|
-
format = '${Package}\t${Version}\t${Architecture}\n'
|
36
|
+
format = '${Package}\t${Version}\t${Architecture}\t${db:Status-Status}\n'
|
37
37
|
so = shell_out("dpkg-query -W -f='#{format}'")
|
38
38
|
pkgs = so.stdout.lines
|
39
39
|
|
40
40
|
pkgs.each do |pkg|
|
41
|
-
name, version, arch = pkg.split
|
42
|
-
packages[name] = { "version" => version, "arch" => arch }
|
41
|
+
name, version, arch, status = pkg.split
|
42
|
+
packages[name] = { "version" => version, "arch" => arch, "status" => status }
|
43
43
|
end
|
44
44
|
|
45
45
|
when "rhel", "fedora", "suse", "pld", "amazon"
|
data/lib/ohai/plugins/passwd.rb
CHANGED
@@ -18,12 +18,24 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
Ohai.plugin(:Platform) do
|
21
|
-
provides "platform", "platform_version", "platform_family"
|
21
|
+
provides "platform", "platform_version", "platform_family", "platform_backend"
|
22
22
|
depends "os", "os_version"
|
23
23
|
|
24
24
|
collect_data(:default) do
|
25
25
|
platform os unless attribute?("platform")
|
26
26
|
platform_version os_version unless attribute?("platform_version")
|
27
27
|
platform_family platform unless attribute?("platform_family")
|
28
|
+
|
29
|
+
platform_backend Mash.new
|
30
|
+
platform_backend["type"] = "local"
|
31
|
+
platform_backend["uri"] = "local://"
|
32
|
+
|
33
|
+
if connection
|
34
|
+
platform_backend["type"] = connection.backend_type
|
35
|
+
if connection.respond_to?(:uri)
|
36
|
+
platform_backend["type"] = connection.uri.split(":").first
|
37
|
+
platform_backend["uri"] = connection.uri
|
38
|
+
end
|
39
|
+
end
|
28
40
|
end
|
29
41
|
end
|
@@ -115,7 +115,7 @@ Ohai.plugin(:Rackspace) do
|
|
115
115
|
def get_instance_id
|
116
116
|
so = shell_out("xenstore-read name")
|
117
117
|
if so.exitstatus == 0
|
118
|
-
rackspace[:instance_id] = so.stdout.gsub(
|
118
|
+
rackspace[:instance_id] = so.stdout.gsub("instance-", "")
|
119
119
|
end
|
120
120
|
rescue Ohai::Exceptions::Exec
|
121
121
|
logger.trace("Plugin Rackspace: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
|
data/lib/ohai/provides_map.rb
CHANGED
@@ -65,8 +65,8 @@ module Ohai
|
|
65
65
|
plugins = []
|
66
66
|
attributes.each do |attribute|
|
67
67
|
attrs = select_subtree(@map, attribute)
|
68
|
-
raise Ohai::Exceptions::AttributeNotFound, "No such attribute:
|
69
|
-
raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute:
|
68
|
+
raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'" unless attrs
|
69
|
+
raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: '#{attribute}'" unless attrs[:_plugins]
|
70
70
|
|
71
71
|
plugins += attrs[:_plugins]
|
72
72
|
end
|
@@ -93,7 +93,7 @@ module Ohai
|
|
93
93
|
attrs = select_closest_subtree(@map, attribute)
|
94
94
|
|
95
95
|
unless attrs
|
96
|
-
raise Ohai::Exceptions::AttributeNotFound, "No such attribute:
|
96
|
+
raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'"
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -115,10 +115,10 @@ module Ohai
|
|
115
115
|
plugins = []
|
116
116
|
attributes.each do |attribute|
|
117
117
|
parts = normalize_and_validate(attribute)
|
118
|
-
raise Ohai::Exceptions::AttributeNotFound, "No such attribute:
|
118
|
+
raise Ohai::Exceptions::AttributeNotFound, "No such attribute: '#{attribute}'" unless @map[parts[0]]
|
119
119
|
|
120
120
|
attrs = select_closest_subtree(@map, attribute)
|
121
|
-
raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute:
|
121
|
+
raise Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: '#{attribute}'" unless attrs
|
122
122
|
|
123
123
|
plugins += attrs[:_plugins]
|
124
124
|
end
|
data/lib/ohai/runner.rb
CHANGED
@@ -119,9 +119,7 @@ module Ohai
|
|
119
119
|
# cycle. Does not include plugins that aren't a part of the cycle
|
120
120
|
def get_cycle(plugins, cycle_start)
|
121
121
|
cycle = plugins.drop_while { |plugin| !plugin.eql?(cycle_start) }
|
122
|
-
|
123
|
-
cycle.each { |plugin| names << plugin.name }
|
124
|
-
names
|
122
|
+
cycle.map(&:name)
|
125
123
|
end
|
126
124
|
|
127
125
|
end
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_dependency "chef-config", ">= 14.12", "< 19"
|
18
18
|
s.add_dependency "chef-utils", ">= 16.0", "< 19"
|
19
|
-
s.add_dependency "ffi", "~> 1.9"
|
19
|
+
s.add_dependency "ffi", "~> 1.9", "<= 1.17.0"
|
20
20
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
21
21
|
s.add_dependency "ipaddress"
|
22
22
|
s.add_dependency "mixlib-cli", ">= 1.7.0" # 1.7+ needed to support passing multiple options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 18.
|
4
|
+
version: 18.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -57,6 +57,9 @@ dependencies:
|
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '1.9'
|
60
|
+
- - "<="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.17.0
|
60
63
|
type: :runtime
|
61
64
|
prerelease: false
|
62
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -64,6 +67,9 @@ dependencies:
|
|
64
67
|
- - "~>"
|
65
68
|
- !ruby/object:Gem::Version
|
66
69
|
version: '1.9'
|
70
|
+
- - "<="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.17.0
|
67
73
|
- !ruby/object:Gem::Dependency
|
68
74
|
name: ffi-yajl
|
69
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -401,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
401
407
|
- !ruby/object:Gem::Version
|
402
408
|
version: '0'
|
403
409
|
requirements: []
|
404
|
-
rubygems_version: 3.
|
410
|
+
rubygems_version: 3.3.27
|
405
411
|
signing_key:
|
406
412
|
specification_version: 4
|
407
413
|
summary: Ohai profiles your system and emits JSON
|