ohai 18.1.18 → 19.1.16
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 +5 -5
- data/lib/ohai/application.rb +1 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +2 -2
- data/lib/ohai/loader.rb +7 -6
- data/lib/ohai/mixin/ec2_metadata.rb +8 -2
- data/lib/ohai/mixin/oci_metadata.rb +34 -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/virtualization.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +5 -1
- data/lib/ohai/plugins/eucalyptus.rb +1 -1
- data/lib/ohai/plugins/filesystem.rb +14 -16
- data/lib/ohai/plugins/freebsd/network.rb +35 -10
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/linux/interrupts.rb +2 -3
- data/lib/ohai/plugins/linux/network.rb +4 -2
- data/lib/ohai/plugins/oci.rb +15 -15
- 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/plugins/rpm.rb +1 -1
- data/lib/ohai/plugins/windows/dmi.rb +1 -1
- data/lib/ohai/plugins/windows/network.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 +6 -5
- metadata +28 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6339d53754721217929ead82d4a232ace638f648d5e7ba2469221dfd22da54a0
|
|
4
|
+
data.tar.gz: 28eda66502f23a2bacf4c96407fb89193023fe76cd5f30f0ab839096def6e044
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c33166e19c09e55f3b28d9ee437a350666b7241b949e0b45bc1e4cc27118bc86130f2c6520c7a136de879d3e72fde0254cadbe3d562646abc7298cbb8b437731
|
|
7
|
+
data.tar.gz: ffd0515bda588dee888dcd1deed4a8d1275b35ddbb55d7b8913b5e87203781628820f0417df55847da3e27a2cec85b2df2e7a2cb7dcb632b9f1181d2f0575e03
|
data/Gemfile
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
source "https://rubygems.org"
|
|
3
4
|
|
|
4
5
|
gemspec
|
|
5
6
|
|
|
6
|
-
# pull these gems from main of chef/chef so that we
|
|
7
|
+
# pull these gems from main of chef/chef so that we"re testing against what we will release
|
|
8
|
+
gem "appbundler"
|
|
7
9
|
gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec"
|
|
8
10
|
gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec"
|
|
9
|
-
|
|
11
|
+
gem "ffi", "~> 1.17", force_ruby_platform: true
|
|
10
12
|
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
|
|
11
13
|
group :development do
|
|
12
|
-
gem "
|
|
14
|
+
gem "cookstyle", ">= 7.32.8"
|
|
13
15
|
gem "ipaddr_extensions"
|
|
14
16
|
gem "rake", ">= 10.1.0"
|
|
15
17
|
gem "rspec-collection_matchers", "~> 1.0"
|
|
16
18
|
gem "rspec-core", "~> 3.0"
|
|
17
19
|
gem "rspec-expectations", "~> 3.0"
|
|
18
20
|
gem "rspec-mocks", "~> 3.0"
|
|
19
|
-
gem "rubocop-performance", "1.18.0"
|
|
20
|
-
gem "rubocop-rspec"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
group :debug do
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Author:: Claire McQuin (<claire@chef.io>)
|
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
|
@@ -97,10 +98,10 @@ module Ohai
|
|
|
97
98
|
# @return [Object] class object for the ohai plugin defined in the file
|
|
98
99
|
def load_plugin_class(plugin_path)
|
|
99
100
|
# Read the contents of the plugin to understand if it's a V6 or V7 plugin.
|
|
100
|
-
contents =
|
|
101
|
+
contents = nil
|
|
101
102
|
begin
|
|
102
103
|
logger.trace("Loading plugin at #{plugin_path}")
|
|
103
|
-
contents
|
|
104
|
+
contents = File.read(plugin_path)
|
|
104
105
|
rescue IOError, Errno::ENOENT
|
|
105
106
|
logger.warn("Unable to open or read plugin at #{plugin_path}")
|
|
106
107
|
return nil
|
|
@@ -110,9 +111,9 @@ module Ohai
|
|
|
110
111
|
if contents.include?("Ohai.plugin")
|
|
111
112
|
load_v7_plugin_class(contents, plugin_path)
|
|
112
113
|
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"\
|
|
114
|
+
raise Exceptions::IllegalPluginDefinition, "[DEPRECATION] Plugin at #{plugin_path}" \
|
|
115
|
+
" is a version 6 plugin. Version 6 plugins are no longer supported by Ohai. This" \
|
|
116
|
+
" plugin will need to be updated to the v7 Ohai plugin format. See" \
|
|
116
117
|
" https://docs.chef.io/ohai_custom.html for v7 syntax."
|
|
117
118
|
end
|
|
118
119
|
end
|
|
@@ -151,7 +152,7 @@ module Ohai
|
|
|
151
152
|
rescue Ohai::Exceptions::IllegalPluginDefinition => e
|
|
152
153
|
logger.warn("Plugin Definition Error: <#{plugin_path}>: #{e.message}")
|
|
153
154
|
rescue NoMethodError => e
|
|
154
|
-
logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation
|
|
155
|
+
logger.warn("Plugin Method Error: <#{plugin_path}>: unsupported operation '#{e.name}'")
|
|
155
156
|
rescue SyntaxError => e
|
|
156
157
|
# split on occurrences of
|
|
157
158
|
# <env>: syntax error,
|
|
@@ -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(/^$/, "/")
|
|
@@ -28,6 +28,39 @@ module Ohai
|
|
|
28
28
|
OCI_METADATA_URL = "/opc/v2"
|
|
29
29
|
CHASSIS_ASSET_TAG_FILE = "/sys/devices/virtual/dmi/id/chassis_asset_tag"
|
|
30
30
|
|
|
31
|
+
# Get the chassis asset tag from DMI information
|
|
32
|
+
# On Linux: reads from sysfs
|
|
33
|
+
# On Windows: queries WMI Win32_SystemEnclosure
|
|
34
|
+
def chassis_asset_tag
|
|
35
|
+
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
|
36
|
+
get_chassis_asset_tag_windows
|
|
37
|
+
else
|
|
38
|
+
get_chassis_asset_tag_linux
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Read chassis asset tag from Linux sysfs
|
|
43
|
+
def get_chassis_asset_tag_linux
|
|
44
|
+
return unless ::File.exist?(CHASSIS_ASSET_TAG_FILE)
|
|
45
|
+
|
|
46
|
+
::File.read(CHASSIS_ASSET_TAG_FILE).strip
|
|
47
|
+
rescue => e
|
|
48
|
+
logger.debug("Mixin OciMetadata: Failed to read chassis asset tag from #{CHASSIS_ASSET_TAG_FILE}: #{e}")
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Read chassis asset tag from Windows WMI
|
|
53
|
+
def get_chassis_asset_tag_windows
|
|
54
|
+
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
|
55
|
+
|
|
56
|
+
wmi = WmiLite::Wmi.new
|
|
57
|
+
enclosure = wmi.first_of("Win32_SystemEnclosure")
|
|
58
|
+
enclosure&.[]("SMBIOSAssetTag")
|
|
59
|
+
rescue => e
|
|
60
|
+
logger.debug("Mixin OciMetadata: Failed to read chassis asset tag from WMI: #{e}")
|
|
61
|
+
nil
|
|
62
|
+
end
|
|
63
|
+
|
|
31
64
|
# fetch the meta content with a timeout and the required header
|
|
32
65
|
def http_get(uri)
|
|
33
66
|
conn = Net::HTTP.start(OCI_METADATA_ADDR)
|
|
@@ -51,7 +84,7 @@ module Ohai
|
|
|
51
84
|
end
|
|
52
85
|
json_data
|
|
53
86
|
else
|
|
54
|
-
logger.
|
|
87
|
+
logger.debug("Mixin OciMetadata: Received response code #{response.code} requesting #{metadata}")
|
|
55
88
|
nil
|
|
56
89
|
end
|
|
57
90
|
end
|
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
|
+
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
|
data/lib/ohai/plugins/ec2.rb
CHANGED
|
@@ -108,7 +108,11 @@ Ohai.plugin(:EC2) do
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
collect_data do
|
|
111
|
-
|
|
111
|
+
begin
|
|
112
|
+
require "base64" unless defined?(Base64)
|
|
113
|
+
rescue LoadError
|
|
114
|
+
logger.warn("Plugin EC2: base64 gem not found. Binary userdata will not be properly encoded.")
|
|
115
|
+
end
|
|
112
116
|
|
|
113
117
|
if looks_like_ec2?
|
|
114
118
|
logger.trace("Plugin EC2: looks_like_ec2? == true")
|
|
@@ -29,7 +29,7 @@ Ohai.plugin(:Eucalyptus) do
|
|
|
29
29
|
provides "eucalyptus"
|
|
30
30
|
depends "network/interfaces"
|
|
31
31
|
|
|
32
|
-
MAC_MATCH = /^[dD]0:0[dD]
|
|
32
|
+
MAC_MATCH = /^[dD]0:0[dD]:/ unless defined?(MAC_MATCH)
|
|
33
33
|
|
|
34
34
|
# returns the mac address from the collection of all address types
|
|
35
35
|
def get_mac_address(addresses)
|
|
@@ -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
|
|
@@ -742,10 +744,6 @@ Ohai.plugin(:Filesystem) do
|
|
|
742
744
|
fs_data["by_mountpoint"] = by_mountpoint
|
|
743
745
|
fs_data["by_pair"] = by_pair
|
|
744
746
|
|
|
745
|
-
# Chef 16 added 'filesystem2'
|
|
746
|
-
# In Chef 17 we made 'filesystem' and 'filesystem2' match (both new-style)
|
|
747
|
-
# In Chef 18 we will drop 'filesystem2'
|
|
748
747
|
filesystem fs_data
|
|
749
|
-
filesystem2 fs_data
|
|
750
748
|
end
|
|
751
749
|
end
|
|
@@ -43,7 +43,7 @@ Ohai.plugin(:Network) do
|
|
|
43
43
|
so = shell_out("#{Ohai.abs_path( "/sbin/ifconfig" )} -a")
|
|
44
44
|
cint = nil
|
|
45
45
|
so.stdout.lines do |line|
|
|
46
|
-
if line =~ /^([0-9a-zA-Z\.]+):\s+/
|
|
46
|
+
if line =~ /^([0-9a-zA-Z\._]+):\s+/
|
|
47
47
|
cint = $1
|
|
48
48
|
iface[cint] = Mash.new
|
|
49
49
|
if cint =~ /^(\w+)(\d+.*)/
|
|
@@ -80,10 +80,13 @@ Ohai.plugin(:Network) do
|
|
|
80
80
|
flags = $1.split(",")
|
|
81
81
|
iface[cint][:flags] = flags if flags.length > 0
|
|
82
82
|
end
|
|
83
|
-
if line =~ /metric
|
|
83
|
+
if line =~ /metric (\d+) mtu (\d+)/
|
|
84
84
|
iface[cint][:metric] = $1
|
|
85
85
|
iface[cint][:mtu] = $2
|
|
86
86
|
end
|
|
87
|
+
if line =~ /media: (\w+)/
|
|
88
|
+
iface[cint][:encapsulation] = $1
|
|
89
|
+
end
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
so = shell_out("arp -an")
|
|
@@ -104,22 +107,44 @@ Ohai.plugin(:Network) do
|
|
|
104
107
|
# which have been auto-configured (interfaces statically configured
|
|
105
108
|
# into a system, but not located at boot time are not shown).
|
|
106
109
|
so = shell_out("netstat -ibdn")
|
|
107
|
-
so.stdout.lines
|
|
110
|
+
head = so.stdout.lines[0]
|
|
111
|
+
have_drop = false
|
|
112
|
+
if head =~ /Idrop/
|
|
113
|
+
have_drop = true
|
|
114
|
+
# Name Mtu Network Address Ipkts Ierrs Idrop Ibytes Opkts Oerrs Obytes Coll Drop
|
|
115
|
+
# vtnet0 1500 <Link#1> fa:16:3e:ba:3e:25 579 0 0 46746 210 0 26242 0 0
|
|
116
|
+
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11
|
|
117
|
+
regex = /^([\w\.\*]+)\s+\d+\s+<Link#\d+>\s+([\w\d:]*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
|
118
|
+
else
|
|
108
119
|
# Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
|
109
120
|
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
|
110
121
|
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
|
|
111
|
-
|
|
122
|
+
regex = /^([\w\.\*]+)\s+\d+\s+<Link#\d+>\s+([\w\d:]*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
|
123
|
+
end
|
|
124
|
+
so.stdout.lines do |line|
|
|
125
|
+
if line =~ regex
|
|
112
126
|
net_counters[$1] ||= Mash.new
|
|
113
127
|
net_counters[$1]["rx"] ||= Mash.new
|
|
114
128
|
net_counters[$1]["tx"] ||= Mash.new
|
|
115
129
|
net_counters[$1]["rx"]["packets"] = $3
|
|
116
130
|
net_counters[$1]["rx"]["errors"] = $4
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
131
|
+
if have_drop
|
|
132
|
+
net_counters[$1]["rx"]["dropped"] = $5
|
|
133
|
+
net_counters[$1]["rx"]["bytes"] = $6
|
|
134
|
+
net_counters[$1]["tx"]["packets"] = $7
|
|
135
|
+
net_counters[$1]["tx"]["errors"] = $8
|
|
136
|
+
net_counters[$1]["tx"]["bytes"] = $9
|
|
137
|
+
net_counters[$1]["tx"]["collisions"] = $10
|
|
138
|
+
net_counters[$1]["tx"]["dropped"] = $11
|
|
139
|
+
else
|
|
140
|
+
net_counters[$1]["rx"]["bytes"] = $5
|
|
141
|
+
net_counters[$1]["tx"]["packets"] = $6
|
|
142
|
+
net_counters[$1]["tx"]["errors"] = $7
|
|
143
|
+
net_counters[$1]["tx"]["bytes"] = $8
|
|
144
|
+
net_counters[$1]["tx"]["collisions"] = $9
|
|
145
|
+
net_counters[$1]["tx"]["dropped"] = $10
|
|
146
|
+
end
|
|
147
|
+
|
|
123
148
|
end
|
|
124
149
|
end
|
|
125
150
|
|
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
|
+
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
|
|
@@ -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
|
|
@@ -578,6 +578,8 @@ Ohai.plugin(:Network) do
|
|
|
578
578
|
|
|
579
579
|
# returns the macaddress for interface from a hash of interfaces (iface elsewhere in this file)
|
|
580
580
|
def get_mac_for_interface(interfaces, interface)
|
|
581
|
+
return "00:00:00:00:00:00" if interfaces[interface][:flags].include?("LOOPBACK")
|
|
582
|
+
|
|
581
583
|
interfaces[interface][:addresses].find { |k, v| v["family"] == "lladdr" }.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?("NOARP")
|
|
582
584
|
end
|
|
583
585
|
|
|
@@ -700,7 +702,7 @@ Ohai.plugin(:Network) do
|
|
|
700
702
|
# Match the lead line for an interface from iproute2
|
|
701
703
|
# 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
|
|
702
704
|
# 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
|
|
705
|
+
IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:;\.\-_]*?)(@[0-9a-zA-Z\-_]+|):\s/
|
|
704
706
|
|
|
705
707
|
if which("ip")
|
|
706
708
|
# families to get default routes from
|
data/lib/ohai/plugins/oci.rb
CHANGED
|
@@ -44,24 +44,22 @@ Ohai.plugin(:Oci) do
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def oci_chassis_asset_tag?
|
|
47
|
-
|
|
48
|
-
if
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
47
|
+
asset_tag = chassis_asset_tag
|
|
48
|
+
return false if asset_tag.nil? || asset_tag.empty?
|
|
49
|
+
|
|
50
|
+
if /OracleCloud.com/.match?(asset_tag)
|
|
51
|
+
logger.trace("Plugin oci: Found OracleCloud.com chassis_asset_tag used by oci.")
|
|
52
|
+
true
|
|
53
|
+
else
|
|
54
|
+
false
|
|
56
55
|
end
|
|
57
|
-
has_oci_chassis_asset_tag
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def parse_metadata
|
|
61
|
-
return
|
|
59
|
+
return unless can_socket_connect?(Ohai::Mixin::OCIMetadata::OCI_METADATA_ADDR, 80)
|
|
62
60
|
|
|
63
61
|
instance_data = fetch_metadata("instance")
|
|
64
|
-
return
|
|
62
|
+
return if instance_data.nil?
|
|
65
63
|
|
|
66
64
|
metadata = Mash.new
|
|
67
65
|
metadata["compute"] = Mash.new
|
|
@@ -80,12 +78,14 @@ Ohai.plugin(:Oci) do
|
|
|
80
78
|
end
|
|
81
79
|
end
|
|
82
80
|
|
|
83
|
-
volume_attachments_data = fetch_metadata("
|
|
81
|
+
volume_attachments_data = fetch_metadata("allVolumeAttachments")
|
|
84
82
|
|
|
85
83
|
unless volume_attachments_data.nil?
|
|
86
84
|
metadata["volumes"] = Mash.new
|
|
87
|
-
volume_attachments_data.each do |
|
|
88
|
-
|
|
85
|
+
volume_attachments_data.each do |v|
|
|
86
|
+
if v.is_a?(Hash) && v["id"]
|
|
87
|
+
metadata["volumes"][v["id"]] = v
|
|
88
|
+
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
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/plugins/rpm.rb
CHANGED
|
@@ -22,7 +22,7 @@ Ohai.plugin(:Rpm) do
|
|
|
22
22
|
provides "rpm"
|
|
23
23
|
optional "true"
|
|
24
24
|
|
|
25
|
-
MACROS_MARKER =
|
|
25
|
+
MACROS_MARKER = /========================/ unless defined?(MACROS_MARKER)
|
|
26
26
|
|
|
27
27
|
unless defined?(DO_NOT_SPLIT)
|
|
28
28
|
DO_NOT_SPLIT = %w{
|
|
@@ -37,7 +37,7 @@ Ohai.plugin(:DMI) do
|
|
|
37
37
|
#
|
|
38
38
|
# This cannot handle some property names, eg SMBIOSBIOSVersion.
|
|
39
39
|
# https://rubular.com/r/FBNtXod4wkZGAG
|
|
40
|
-
SPLIT_REGEX ||= /[A-Z][a-z0-9]+|[A-Z]{2,}(?=[A-Z][a-z0-9])|[A-Z]{2,}
|
|
40
|
+
SPLIT_REGEX ||= /[A-Z][a-z0-9]+|[A-Z]{2,}(?=[A-Z][a-z0-9])|[A-Z]{2,}/
|
|
41
41
|
|
|
42
42
|
WINDOWS_TO_UNIX_KEYS ||= [
|
|
43
43
|
%w{vendor manufacturer},
|
|
@@ -41,7 +41,7 @@ Ohai.plugin(:Network) do
|
|
|
41
41
|
# If we are running on windows nano or another operating system from the future
|
|
42
42
|
# that does not populate the deprecated win32_* WMI classes, then we should
|
|
43
43
|
# grab data from the newer MSFT_* classes
|
|
44
|
-
return msft_adapter_data if data[:addresses].
|
|
44
|
+
return msft_adapter_data if data[:addresses].none?
|
|
45
45
|
|
|
46
46
|
data[:adapters] = wmi.instances_of("Win32_NetworkAdapter")
|
|
47
47
|
data
|
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
|
@@ -12,17 +12,18 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.email = "adam@chef.io"
|
|
13
13
|
s.homepage = "https://github.com/chef/ohai/"
|
|
14
14
|
|
|
15
|
-
s.required_ruby_version = ">=
|
|
15
|
+
s.required_ruby_version = ">= 3.1"
|
|
16
16
|
|
|
17
|
-
s.add_dependency "
|
|
18
|
-
s.add_dependency "chef-
|
|
19
|
-
s.add_dependency "
|
|
17
|
+
s.add_dependency "base64" # For encoding binary data in Ruby 3.4+
|
|
18
|
+
s.add_dependency "chef-config", ">= 14.12", "< 20"
|
|
19
|
+
s.add_dependency "chef-utils", ">= 16.0", "< 20"
|
|
20
|
+
s.add_dependency "ffi", ">= 1.15.5"
|
|
20
21
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
|
21
22
|
s.add_dependency "ipaddress"
|
|
22
23
|
s.add_dependency "mixlib-cli", ">= 1.7.0" # 1.7+ needed to support passing multiple options
|
|
23
24
|
s.add_dependency "mixlib-config", ">= 2.0", "< 4.0"
|
|
24
25
|
s.add_dependency "mixlib-log", ">= 2.0.1", "< 4.0"
|
|
25
|
-
s.add_dependency "mixlib-shellout", "~> 3.
|
|
26
|
+
s.add_dependency "mixlib-shellout", "~> 3.3.6"
|
|
26
27
|
s.add_dependency "plist", "~> 3.1"
|
|
27
28
|
s.add_dependency "train-core"
|
|
28
29
|
s.add_dependency "wmi-lite", "~> 1.0"
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ohai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 19.1.16
|
|
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-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: base64
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: chef-config
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -19,7 +33,7 @@ dependencies:
|
|
|
19
33
|
version: '14.12'
|
|
20
34
|
- - "<"
|
|
21
35
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
36
|
+
version: '20'
|
|
23
37
|
type: :runtime
|
|
24
38
|
prerelease: false
|
|
25
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +43,7 @@ dependencies:
|
|
|
29
43
|
version: '14.12'
|
|
30
44
|
- - "<"
|
|
31
45
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
46
|
+
version: '20'
|
|
33
47
|
- !ruby/object:Gem::Dependency
|
|
34
48
|
name: chef-utils
|
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,7 +53,7 @@ dependencies:
|
|
|
39
53
|
version: '16.0'
|
|
40
54
|
- - "<"
|
|
41
55
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '
|
|
56
|
+
version: '20'
|
|
43
57
|
type: :runtime
|
|
44
58
|
prerelease: false
|
|
45
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -49,21 +63,21 @@ dependencies:
|
|
|
49
63
|
version: '16.0'
|
|
50
64
|
- - "<"
|
|
51
65
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '
|
|
66
|
+
version: '20'
|
|
53
67
|
- !ruby/object:Gem::Dependency
|
|
54
68
|
name: ffi
|
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
|
56
70
|
requirements:
|
|
57
|
-
- - "
|
|
71
|
+
- - ">="
|
|
58
72
|
- !ruby/object:Gem::Version
|
|
59
|
-
version:
|
|
73
|
+
version: 1.15.5
|
|
60
74
|
type: :runtime
|
|
61
75
|
prerelease: false
|
|
62
76
|
version_requirements: !ruby/object:Gem::Requirement
|
|
63
77
|
requirements:
|
|
64
|
-
- - "
|
|
78
|
+
- - ">="
|
|
65
79
|
- !ruby/object:Gem::Version
|
|
66
|
-
version:
|
|
80
|
+
version: 1.15.5
|
|
67
81
|
- !ruby/object:Gem::Dependency
|
|
68
82
|
name: ffi-yajl
|
|
69
83
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -152,20 +166,14 @@ dependencies:
|
|
|
152
166
|
requirements:
|
|
153
167
|
- - "~>"
|
|
154
168
|
- !ruby/object:Gem::Version
|
|
155
|
-
version:
|
|
156
|
-
- - ">="
|
|
157
|
-
- !ruby/object:Gem::Version
|
|
158
|
-
version: 3.2.5
|
|
169
|
+
version: 3.3.6
|
|
159
170
|
type: :runtime
|
|
160
171
|
prerelease: false
|
|
161
172
|
version_requirements: !ruby/object:Gem::Requirement
|
|
162
173
|
requirements:
|
|
163
174
|
- - "~>"
|
|
164
175
|
- !ruby/object:Gem::Version
|
|
165
|
-
version:
|
|
166
|
-
- - ">="
|
|
167
|
-
- !ruby/object:Gem::Version
|
|
168
|
-
version: 3.2.5
|
|
176
|
+
version: 3.3.6
|
|
169
177
|
- !ruby/object:Gem::Dependency
|
|
170
178
|
name: plist
|
|
171
179
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -394,14 +402,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
394
402
|
requirements:
|
|
395
403
|
- - ">="
|
|
396
404
|
- !ruby/object:Gem::Version
|
|
397
|
-
version: '
|
|
405
|
+
version: '3.1'
|
|
398
406
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
407
|
requirements:
|
|
400
408
|
- - ">="
|
|
401
409
|
- !ruby/object:Gem::Version
|
|
402
410
|
version: '0'
|
|
403
411
|
requirements: []
|
|
404
|
-
rubygems_version: 3.
|
|
412
|
+
rubygems_version: 3.3.27
|
|
405
413
|
signing_key:
|
|
406
414
|
specification_version: 4
|
|
407
415
|
summary: Ohai profiles your system and emits JSON
|