ohai 17.7.8 → 18.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/ohai/mixin/azure_metadata.rb +4 -3
- data/lib/ohai/mixin/os.rb +1 -1
- data/lib/ohai/plugins/azure.rb +4 -2
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +3 -3
- data/lib/ohai/plugins/filesystem.rb +30 -0
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/linux/mdadm.rb +2 -0
- data/lib/ohai/plugins/linux/network.rb +58 -5
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +1 -1
- data/lib/ohai/plugins/rpm.rb +119 -0
- data/lib/ohai/plugins/vmware.rb +22 -2
- data/lib/ohai/runner.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f13e229791bcb56c90dfc30f3fa5fea108b9d185c1c0492a5198c2e6bae93b
|
4
|
+
data.tar.gz: 60134dedd0d7da72c1932dc987b143303d9f832bf123380ab22db9462e6799b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 735fb50fdd3ee96a1325eaae9847d0f998b72b50116963d829bd7b350d5b6af4e76089083612c7a66f7ec7e80a374e45b25b711b38e6ff5c0435f9ac66ae39ec
|
7
|
+
data.tar.gz: ed81c806e9d91688e5c7aa5a4246aea55e62a8dbca35e3c89698795c29f45083572bafdf62382abcce201c53b736a1f11b2fcd17e4ff5aa61a114707fc2f1b11
|
data/Gemfile
CHANGED
@@ -9,14 +9,14 @@ gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "ch
|
|
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 "chefstyle", "2.
|
12
|
+
gem "chefstyle", "2.2.2"
|
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.13.3"
|
20
20
|
gem "rubocop-rspec"
|
21
21
|
end
|
22
22
|
|
@@ -35,9 +35,10 @@ module Ohai
|
|
35
35
|
AZURE_METADATA_ADDR ||= "169.254.169.254"
|
36
36
|
|
37
37
|
# it's important that the newer versions are at the end of this array so we can skip sorting it
|
38
|
-
AZURE_SUPPORTED_VERSIONS ||= %w{
|
39
|
-
|
40
|
-
|
38
|
+
AZURE_SUPPORTED_VERSIONS ||= %w{ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
|
39
|
+
2019-06-04 2019-08-01 2019-08-15 2019-11-01 2020-06-01
|
40
|
+
2020-07-15 2020-09-01 2020-10-01 2020-12-01 2021-01-01
|
41
|
+
2021-02-01 2021-03-01 2021-05-01 2021-10-01 }.freeze
|
41
42
|
|
42
43
|
def best_api_version
|
43
44
|
@api_version ||= begin
|
data/lib/ohai/mixin/os.rb
CHANGED
@@ -110,7 +110,7 @@ module Ohai
|
|
110
110
|
"dragonflybsd"
|
111
111
|
when /solaris2/
|
112
112
|
"solaris2"
|
113
|
-
when /mswin|
|
113
|
+
when /mswin|mingw|windows/
|
114
114
|
# After long discussion in IRC the "powers that be" have come to a consensus
|
115
115
|
# that no Windows platform exists that was not based on the
|
116
116
|
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -73,9 +73,11 @@ Ohai.plugin(:Azure) do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def tcp_ip_dhcp_domain
|
76
|
-
return unless RUBY_PLATFORM.match?(/mswin|
|
76
|
+
return unless RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
77
77
|
|
78
|
-
|
78
|
+
if ChefUtils.windows?
|
79
|
+
require "win32/registry" unless defined?(Win32::Registry)
|
80
|
+
end
|
79
81
|
|
80
82
|
begin
|
81
83
|
key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters")
|
data/lib/ohai/plugins/chef.rb
CHANGED
@@ -33,7 +33,7 @@ Ohai.plugin(:Chef) do
|
|
33
33
|
begin
|
34
34
|
require "chef/version"
|
35
35
|
require "chef-config/config" unless defined?(ChefConfig::Config)
|
36
|
-
rescue
|
36
|
+
rescue LoadError
|
37
37
|
logger.trace("Plugin Chef: Unable to load the chef gem to determine the version")
|
38
38
|
# this catches when you've done a major version bump of ohai, but
|
39
39
|
# your chef gem is incompatible, so we can't load it in the same VM
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -81,7 +81,7 @@ Ohai.plugin(:EC2) do
|
|
81
81
|
# linux hosts
|
82
82
|
# @return [Boolean] do we have a Xen Identifying Number or not?
|
83
83
|
def has_ec2_identifying_number?
|
84
|
-
if RUBY_PLATFORM.match?(/mswin|
|
84
|
+
if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
85
85
|
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
86
86
|
wmi = WmiLite::Wmi.new
|
87
87
|
if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
|
@@ -142,8 +142,8 @@ Ohai.plugin(:EC2) do
|
|
142
142
|
ec2[:account_id] = fetch_dynamic_data["accountId"]
|
143
143
|
ec2[:availability_zone] = fetch_dynamic_data["availabilityZone"]
|
144
144
|
ec2[:region] = fetch_dynamic_data["region"]
|
145
|
-
|
146
|
-
if ec2[:userdata] && ec2[:userdata].encoding
|
145
|
+
|
146
|
+
if ec2[:userdata] && ec2[:userdata].encoding == Encoding::BINARY
|
147
147
|
logger.trace("Plugin EC2: Binary UserData Found. Storing in base64")
|
148
148
|
ec2[:userdata] = Base64.encode64(ec2[:userdata])
|
149
149
|
end
|
@@ -271,6 +271,30 @@ Ohai.plugin(:Filesystem) do
|
|
271
271
|
fs
|
272
272
|
end
|
273
273
|
|
274
|
+
def collect_btrfs_data(entry)
|
275
|
+
btrfs = Mash.new
|
276
|
+
if entry[:fs_type] == "btrfs" && entry["uuid"]
|
277
|
+
uuid = entry["uuid"]
|
278
|
+
alloc = "/sys/fs/btrfs/#{uuid}/allocation"
|
279
|
+
%w{data metadata system}.each do |bg_type|
|
280
|
+
dir = "#{alloc}/#{bg_type}"
|
281
|
+
%w{single dup}.each do |raid|
|
282
|
+
if file_exist?("#{dir}/#{raid}")
|
283
|
+
btrfs["raid"] = raid
|
284
|
+
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
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
btrfs
|
296
|
+
end
|
297
|
+
|
274
298
|
collect_data(:linux) do
|
275
299
|
fs = Mash.new
|
276
300
|
|
@@ -394,6 +418,12 @@ Ohai.plugin(:Filesystem) do
|
|
394
418
|
end
|
395
419
|
end
|
396
420
|
|
421
|
+
fs.each do |key, entry|
|
422
|
+
if entry[:fs_type] == "btrfs"
|
423
|
+
fs[key][:btrfs] = collect_btrfs_data(entry)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
397
427
|
by_pair = fs
|
398
428
|
by_device = generate_device_view(fs)
|
399
429
|
by_mountpoint = generate_mountpoint_view(fs)
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -49,7 +49,7 @@ Ohai.plugin(:GCE) do
|
|
49
49
|
# looks at the Manufacturer and Model WMI values to see if they starts with Google.
|
50
50
|
# @return [Boolean] Are the manufacturer and model Google?
|
51
51
|
def has_gce_system_info?
|
52
|
-
if RUBY_PLATFORM.match?(/mswin|
|
52
|
+
if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
53
53
|
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
54
54
|
wmi = WmiLite::Wmi.new
|
55
55
|
computer_system = wmi.first_of("Win32_ComputerSystem")
|
@@ -35,6 +35,8 @@ Ohai.plugin(:Mdadm) do
|
|
35
35
|
device_mash[:size] = Regexp.last_match[1].to_f
|
36
36
|
when /State\s+: ([a-z]+)/
|
37
37
|
device_mash[:state] = Regexp.last_match[1]
|
38
|
+
when /UUID\s+: ([0-9a-z:]+)/
|
39
|
+
device_mash[:UUID] = Regexp.last_match[1]
|
38
40
|
when /Total Devices\s+: ([0-9]+)/
|
39
41
|
device_mash[:device_counts][:total] = Regexp.last_match[1].to_i
|
40
42
|
when /Raid Devices\s+: ([0-9]+)/
|
@@ -80,9 +80,22 @@ Ohai.plugin(:Network) do
|
|
80
80
|
line.strip!
|
81
81
|
logger.trace("Plugin Network: Parsing #{line}")
|
82
82
|
if /\\/.match?(line)
|
83
|
+
# If we have multipath routing, then the first part will be a normal
|
84
|
+
# looking route:
|
85
|
+
# default proto ra metric 1024 <other options>
|
86
|
+
# Each successive part after that is a hop without those options.
|
87
|
+
# So the first thing we do is grab that first part, and split it into
|
88
|
+
# the route destination ("default"), and the route options.
|
83
89
|
parts = line.split("\\")
|
84
|
-
route_dest = parts.
|
85
|
-
|
90
|
+
route_dest, dest_opts = parts.first.split(nil, 2)
|
91
|
+
# Then all the route endings, generally just nexthops.
|
92
|
+
route_endings = parts[1..]
|
93
|
+
if dest_opts && !dest_opts.empty?
|
94
|
+
# Route options like proto, metric, etc. only appear once for each
|
95
|
+
# multipath configuration. Prepend this information to the route
|
96
|
+
# endings so the code below will assign the fields properly.
|
97
|
+
route_endings.map! { |e| e.include?("nexthop") ? "#{dest_opts} #{e}" : e }
|
98
|
+
end
|
86
99
|
elsif line =~ /^([^\s]+)\s(.*)$/
|
87
100
|
route_dest = $1
|
88
101
|
route_endings = [$2]
|
@@ -90,9 +103,24 @@ Ohai.plugin(:Network) do
|
|
90
103
|
next
|
91
104
|
end
|
92
105
|
route_endings.each do |route_ending|
|
106
|
+
route_entry = Mash.new(destination: route_dest,
|
107
|
+
family: family[:name])
|
108
|
+
route_int = nil
|
93
109
|
if route_ending =~ /\bdev\s+([^\s]+)\b/
|
94
110
|
route_int = $1
|
95
|
-
|
111
|
+
end
|
112
|
+
# does any known interface own the src address?
|
113
|
+
# we try to infer the interface/device from its address if it isn't specified
|
114
|
+
# we want to override the interface set via nexthop but only if possible
|
115
|
+
if line =~ /\bsrc\s+([^\s]+)\b/ && (!route_int || line.include?("nexthop"))
|
116
|
+
# only clobber previously set route_int if we find a match
|
117
|
+
if (match = iface.select { |name, intf| intf.fetch("addresses", {}).any? { |addr, _| addr == $1 } }.keys.first)
|
118
|
+
route_int = match
|
119
|
+
route_entry[:inferred] = true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
unless route_int
|
96
124
|
logger.trace("Plugin Network: Skipping route entry without a device: '#{line}'")
|
97
125
|
next
|
98
126
|
end
|
@@ -103,8 +131,6 @@ Ohai.plugin(:Network) do
|
|
103
131
|
next
|
104
132
|
end
|
105
133
|
|
106
|
-
route_entry = Mash.new(destination: route_dest,
|
107
|
-
family: family[:name])
|
108
134
|
%w{via scope metric proto src}.each do |k|
|
109
135
|
# http://rubular.com/r/pwTNp65VFf
|
110
136
|
route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
|
@@ -350,6 +376,7 @@ Ohai.plugin(:Network) do
|
|
350
376
|
so = shell_out("ip -d -s link")
|
351
377
|
tmp_int = nil
|
352
378
|
on_rx = true
|
379
|
+
xdp_mode = nil
|
353
380
|
so.stdout.lines do |line|
|
354
381
|
if line =~ IPROUTE_INT_REGEX
|
355
382
|
tmp_int = $2
|
@@ -425,6 +452,30 @@ Ohai.plugin(:Network) do
|
|
425
452
|
if line =~ /\sstate (\w+)/
|
426
453
|
iface[tmp_int]["state"] = $1.downcase
|
427
454
|
end
|
455
|
+
|
456
|
+
if line.include?("xdp")
|
457
|
+
mode = line.scan(/\s(xdp|xdpgeneric|xdpoffload|xdpmulti)\s/).flatten[0]
|
458
|
+
# Fetches and sets the mode from the first line.
|
459
|
+
unless mode.nil?
|
460
|
+
iface[tmp_int][:xdp] = {}
|
461
|
+
if mode.eql?("xdp")
|
462
|
+
# In case of xdpdrv, mode is xdp,
|
463
|
+
# to keep it consistent, keeping mode as xdpdrv.
|
464
|
+
mode = "xdpdrv"
|
465
|
+
end
|
466
|
+
xdp_mode = mode
|
467
|
+
iface[tmp_int][:xdp][:attached] = []
|
468
|
+
end
|
469
|
+
|
470
|
+
if line =~ %r{prog/(\w+) id (\d+) tag (\w+)}
|
471
|
+
mode = $1.eql?("xdp") ? xdp_mode : $1
|
472
|
+
iface[tmp_int][:xdp][:attached] << {
|
473
|
+
mode: mode,
|
474
|
+
id: $2,
|
475
|
+
tag: $3,
|
476
|
+
}
|
477
|
+
end
|
478
|
+
end
|
428
479
|
end
|
429
480
|
iface
|
430
481
|
end
|
@@ -607,10 +658,12 @@ Ohai.plugin(:Network) do
|
|
607
658
|
# sorting the selected routes:
|
608
659
|
# - getting default routes first
|
609
660
|
# - then sort by metric
|
661
|
+
# - then sort by if the device was inferred or not (preferring explicit to inferred)
|
610
662
|
# - then by prefixlen
|
611
663
|
[
|
612
664
|
r[:destination] == "default" ? 0 : 1,
|
613
665
|
r[:metric].nil? ? 0 : r[:metric].to_i,
|
666
|
+
r[:inferred] ? 1 : 0,
|
614
667
|
# for some reason IPAddress doesn't accept "::/0", it doesn't like prefix==0
|
615
668
|
# just a quick workaround: use 0 if IPAddress fails
|
616
669
|
begin
|
@@ -49,7 +49,7 @@ Ohai.plugin(:Openstack) do
|
|
49
49
|
# https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
|
50
50
|
def openstack_provider
|
51
51
|
# dream host doesn't support windows so bail early if we're on windows
|
52
|
-
return "openstack" if RUBY_PLATFORM.match?(/mswin|
|
52
|
+
return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
53
53
|
|
54
54
|
if Etc::Passwd.entries.map(&:name).include?("dhc-user")
|
55
55
|
"dreamhost"
|
@@ -48,7 +48,7 @@ Ohai.plugin(:Rackspace) do
|
|
48
48
|
# true:: If the rackspace cloud can be identified
|
49
49
|
# false:: Otherwise
|
50
50
|
def has_rackspace_manufacturer?
|
51
|
-
return false unless RUBY_PLATFORM.match?(/mswin|
|
51
|
+
return false unless RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
52
52
|
|
53
53
|
require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
|
54
54
|
wmi = WmiLite::Wmi.new
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
5
|
+
# Copyright:: Copyright (c) 2021 Meta Platforms, Inc. and affiliates.
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
Ohai.plugin(:Rpm) do
|
22
|
+
provides "rpm"
|
23
|
+
optional "true"
|
24
|
+
|
25
|
+
MACROS_MARKER = /========================/.freeze
|
26
|
+
|
27
|
+
DO_NOT_SPLIT = %w{
|
28
|
+
build_arch
|
29
|
+
build_os
|
30
|
+
install_arch
|
31
|
+
install_os
|
32
|
+
archcolor
|
33
|
+
optflags
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
collect_data(:aix, :darwin, :dragonflybsd, :freebsd, :linux, :netbsd, :openbsd, :solaris2) do
|
37
|
+
rpm_path = which("rpm")
|
38
|
+
if rpm_path
|
39
|
+
rpm_version_out = shell_out("#{rpm_path} --version")
|
40
|
+
rpm_showrc_out = shell_out("#{rpm_path} --showrc")
|
41
|
+
|
42
|
+
rpm Mash.new unless rpm
|
43
|
+
rpm[:macros] ||= Mash.new
|
44
|
+
|
45
|
+
m = rpm_version_out.stdout.match(/\w+ (\d.*)/)
|
46
|
+
if m
|
47
|
+
rpm[:version] = m[1]
|
48
|
+
end
|
49
|
+
|
50
|
+
lines = rpm_showrc_out.stdout.split("\n")
|
51
|
+
# there's a marker to separate the beginning and end of the macros list
|
52
|
+
macros_start_idx = lines.index { |x| x.match(MACROS_MARKER) }
|
53
|
+
macros_end_idx = lines.rindex { |x| x.match(MACROS_MARKER) }
|
54
|
+
section = nil
|
55
|
+
lines[0..macros_start_idx - 1].each do |line|
|
56
|
+
if line.start_with?("ARCHITECTURE AND OS")
|
57
|
+
section = :arch_os
|
58
|
+
rpm[section] ||= Mash.new
|
59
|
+
elsif line.start_with?("RPMRC VALUES")
|
60
|
+
section = :rpmrc
|
61
|
+
rpm[section] ||= Mash.new
|
62
|
+
elsif line.start_with?("Features supported by rpmlib")
|
63
|
+
section = :features
|
64
|
+
rpm[section] ||= Mash.new
|
65
|
+
elsif line.start_with?("Macro path")
|
66
|
+
fields = line.split(":", 2)
|
67
|
+
if fields
|
68
|
+
rpm[:macro_path] = fields[1].strip.split(":")
|
69
|
+
end
|
70
|
+
section = nil
|
71
|
+
elsif %i{arch_os rpmrc}.include?(section)
|
72
|
+
fields = line.split(":")
|
73
|
+
if fields && fields[0] && fields[1]
|
74
|
+
key = fields[0].strip.sub("'s", "es").tr(" ", "_")
|
75
|
+
if DO_NOT_SPLIT.include?(key)
|
76
|
+
values = fields[1].strip
|
77
|
+
else
|
78
|
+
values = fields[1].strip.split(" ")
|
79
|
+
end
|
80
|
+
rpm[section][key] = values
|
81
|
+
end
|
82
|
+
elsif section == :features
|
83
|
+
fields = line.split("=")
|
84
|
+
if fields && fields[0] && fields[1]
|
85
|
+
rpm[section][fields[0].strip] = fields[1].strip
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
name = nil
|
91
|
+
value = ""
|
92
|
+
lines[macros_start_idx + 1..macros_end_idx - 1].each do |line|
|
93
|
+
if line.start_with?("-")
|
94
|
+
# new macros are always prefixed by a dash
|
95
|
+
if name
|
96
|
+
# if we had parsed a macro before, store it
|
97
|
+
rpm[:macros][name] = value
|
98
|
+
name = nil
|
99
|
+
value = ""
|
100
|
+
end
|
101
|
+
|
102
|
+
# parse the new macro definition
|
103
|
+
_prefix, name, value = line.split(" ", 3)
|
104
|
+
else
|
105
|
+
# continuations have no prefix and just append to the previous one
|
106
|
+
value += "\n#{line}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Once we're done parsing all lines, we might have a parsed definition
|
111
|
+
# we haven't stored - if so, store it.
|
112
|
+
if name
|
113
|
+
rpm[:macros][name] = value
|
114
|
+
end
|
115
|
+
else
|
116
|
+
logger.trace("Plugin RPM: Could not find rpm. Skipping plugin.")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/lib/ohai/plugins/vmware.rb
CHANGED
@@ -45,12 +45,14 @@ Ohai.plugin(:VMware) do
|
|
45
45
|
logger.trace("Plugin VMware: #{vmtools_path} not found")
|
46
46
|
else
|
47
47
|
vmware Mash.new
|
48
|
+
vmware[:host] = Mash.new
|
49
|
+
vmware[:guest] = Mash.new
|
48
50
|
begin
|
49
51
|
# vmware-toolbox-cmd stat <param> commands
|
50
52
|
# Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value
|
51
53
|
# to attribute "vmware[:<parameter>]"
|
52
54
|
%w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
|
53
|
-
vmware[param] = from_cmd(
|
55
|
+
vmware[param] = from_cmd([vmtools_path, "stat", param])
|
54
56
|
if /UpdateInfo failed/.match?(vmware[param])
|
55
57
|
vmware[param] = nil
|
56
58
|
end
|
@@ -59,8 +61,23 @@ Ohai.plugin(:VMware) do
|
|
59
61
|
# Iterate through each parameter supported by the "vmware-toolbox-cmd status" command, assign value
|
60
62
|
# to attribute "vmware[:<parameter>]"
|
61
63
|
%w{upgrade timesync}.each do |param|
|
62
|
-
vmware[param] = from_cmd(
|
64
|
+
vmware[param] = from_cmd([vmtools_path, param, "status"])
|
63
65
|
end
|
66
|
+
# Distinguish hypervisors by presence of raw session data (vSphere only)
|
67
|
+
raw_session = from_cmd([vmtools_path, "stat", "raw", "json", "session"])
|
68
|
+
if raw_session.empty?
|
69
|
+
vmware[:host] = {
|
70
|
+
type: "vmware_desktop",
|
71
|
+
}
|
72
|
+
else
|
73
|
+
require "json" unless defined?(JSON)
|
74
|
+
session = JSON.parse(raw_session)
|
75
|
+
vmware[:host] = {
|
76
|
+
type: "vmware_vsphere",
|
77
|
+
version: session["version"],
|
78
|
+
}
|
79
|
+
end
|
80
|
+
vmware[:guest][:vmware_tools_version] = from_cmd([vmtools_path, "-v"]).split(" ").first
|
64
81
|
rescue
|
65
82
|
logger.trace("Plugin VMware: Error while collecting VMware guest attributes")
|
66
83
|
end
|
@@ -71,4 +88,7 @@ Ohai.plugin(:VMware) do
|
|
71
88
|
get_vm_attributes("/usr/bin/vmware-toolbox-cmd") if virtualization[:systems][:vmware]
|
72
89
|
end
|
73
90
|
|
91
|
+
collect_data(:windows) do
|
92
|
+
get_vm_attributes("C:/Program Files/VMWare/VMware Tools/VMwareToolboxCmd.exe") if virtualization[:systems][:vmware]
|
93
|
+
end
|
74
94
|
end
|
data/lib/ohai/runner.rb
CHANGED
@@ -61,7 +61,7 @@ module Ohai
|
|
61
61
|
rescue Ohai::Exceptions::Error, SystemExit # SystemExit: abort or exit from plug-in should exit Ohai with failure code
|
62
62
|
raise
|
63
63
|
rescue Exception => e
|
64
|
-
logger.
|
64
|
+
logger.warn("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
logger.trace("Plugin #{plugin.name} took #{"%f" % elapsed.truncate(6)} seconds to run.")
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.required_ruby_version = ">= 2.7"
|
16
16
|
|
17
|
-
s.add_dependency "chef-config", ">= 14.12", "<
|
18
|
-
s.add_dependency "chef-utils", ">= 16.0", "<
|
17
|
+
s.add_dependency "chef-config", ">= 14.12", "< 19"
|
18
|
+
s.add_dependency "chef-utils", ">= 16.0", "< 19"
|
19
19
|
s.add_dependency "ffi", "~> 1.9"
|
20
20
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
21
21
|
s.add_dependency "ipaddress"
|
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:
|
4
|
+
version: 18.0.14
|
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: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '14.12'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '19'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '14.12'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '19'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: chef-utils
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '16.0'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '19'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '16.0'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '19'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: ffi
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -341,6 +341,7 @@ files:
|
|
341
341
|
- lib/ohai/plugins/python.rb
|
342
342
|
- lib/ohai/plugins/rackspace.rb
|
343
343
|
- lib/ohai/plugins/root_group.rb
|
344
|
+
- lib/ohai/plugins/rpm.rb
|
344
345
|
- lib/ohai/plugins/ruby.rb
|
345
346
|
- lib/ohai/plugins/rust.rb
|
346
347
|
- lib/ohai/plugins/scala.rb
|