ohai 18.0.14 → 18.1.0
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 +1 -1
- data/lib/ohai/common/dmi.rb +60 -56
- data/lib/ohai/mixin/dmi_decode.rb +1 -1
- data/lib/ohai/mixin/network_helper.rb +6 -4
- data/lib/ohai/mixin/oci_metadata.rb +69 -0
- data/lib/ohai/plugins/alibaba.rb +1 -1
- data/lib/ohai/plugins/azure.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +22 -0
- data/lib/ohai/plugins/cpu.rb +15 -6
- data/lib/ohai/plugins/darwin/virtualization.rb +6 -9
- data/lib/ohai/plugins/ec2.rb +3 -10
- data/lib/ohai/plugins/fips.rb +2 -1
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +5 -5
- data/lib/ohai/plugins/linux/platform.rb +3 -2
- data/lib/ohai/plugins/linux/virtualization.rb +4 -4
- data/lib/ohai/plugins/oci.rb +94 -0
- data/lib/ohai/plugins/rpm.rb +11 -9
- data/lib/ohai/plugins/scaleway.rb +1 -1
- data/lib/ohai/plugins/timezone.rb +20 -0
- data/lib/ohai/plugins/vmware.rb +16 -1
- data/lib/ohai/util/ip_helper.rb +2 -2
- data/lib/ohai/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d6704f249d63eb6abebd08dd48e408fee70bd50d5ca2304471bdcc53b80941c
|
4
|
+
data.tar.gz: f761a02520c31d96e8a8bab3853f5a432d0fb9460b2901dd1a0abe4efdcdcc6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a58f353ea899d897e4fc3cd8aa5dabe9737b8002ceda5483482ac7fceded93d40ef5581ca4e403edaa049e6f43587932945e8f1f125cb88162e31ae424a80865
|
7
|
+
data.tar.gz: a58f4b0a239f206e2194abacbdbf137931057980745f0b5b9eee528ff314c21a042ae1b88a0325b12a68fc928c77817778d53d89e952bbd9d88410df35a93865
|
data/Gemfile
CHANGED
data/lib/ohai/common/dmi.rb
CHANGED
@@ -25,57 +25,59 @@ module Ohai
|
|
25
25
|
# all-lowercase, all non-alphanumeric converted to '_'
|
26
26
|
# 128-255 are 'oem_data_[id]'
|
27
27
|
# Everything else is 'unknown'
|
28
|
-
ID_TO_DESCRIPTION
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
28
|
+
unless defined?(ID_TO_DESCRIPTION)
|
29
|
+
ID_TO_DESCRIPTION = {
|
30
|
+
0 => "bios",
|
31
|
+
1 => "system",
|
32
|
+
2 => "base_board",
|
33
|
+
3 => "chassis",
|
34
|
+
4 => "processor",
|
35
|
+
5 => "memory_controller",
|
36
|
+
6 => "memory_module",
|
37
|
+
7 => "cache",
|
38
|
+
8 => "port_connector",
|
39
|
+
9 => "system_slots",
|
40
|
+
10 => "on_board_devices",
|
41
|
+
11 => "oem_strings",
|
42
|
+
12 => "system_configuration_options",
|
43
|
+
13 => "bios_language",
|
44
|
+
14 => "group_associations",
|
45
|
+
15 => "system_event_log",
|
46
|
+
16 => "physical_memory_array",
|
47
|
+
17 => "memory_device",
|
48
|
+
18 => "32_bit_memory_error",
|
49
|
+
19 => "memory_array_mapped_address",
|
50
|
+
20 => "memory_device_mapped_address",
|
51
|
+
21 => "built_in_pointing_device",
|
52
|
+
22 => "portable_battery",
|
53
|
+
23 => "system_reset",
|
54
|
+
24 => "hardware_security",
|
55
|
+
25 => "system_power_controls",
|
56
|
+
26 => "voltage_probe",
|
57
|
+
27 => "cooling_device",
|
58
|
+
28 => "temperature_probe",
|
59
|
+
29 => "electrical_current_probe",
|
60
|
+
30 => "out_of_band_remote_access",
|
61
|
+
31 => "boot_integrity_services",
|
62
|
+
32 => "system_boot",
|
63
|
+
33 => "64_bit_memory_error",
|
64
|
+
34 => "management_device",
|
65
|
+
35 => "management_device_component",
|
66
|
+
36 => "management_device_threshold_data",
|
67
|
+
37 => "memory_channel",
|
68
|
+
38 => "ipmi_device",
|
69
|
+
39 => "power_supply",
|
70
|
+
40 => "additional_information",
|
71
|
+
41 => "onboard_devices_extended_information",
|
72
|
+
42 => "management_controller_host_interfaces",
|
73
|
+
126 => "disabled_entries",
|
74
|
+
127 => "end_of_table_marker",
|
75
|
+
}.freeze
|
76
|
+
end
|
75
77
|
|
76
78
|
# list of IDs to collect from config or default to a sane list that prunes
|
77
79
|
# away some of the less useful IDs
|
78
|
-
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze
|
80
|
+
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze unless defined?(ID_TO_CAPTURE)
|
79
81
|
|
80
82
|
# the allowlisted DMI IDs. This is combination of the defaults + any additional
|
81
83
|
# IDs defined in the :additional_dmi_ids config
|
@@ -116,14 +118,16 @@ module Ohai
|
|
116
118
|
id
|
117
119
|
end
|
118
120
|
|
119
|
-
SKIPPED_CONVENIENCE_KEYS
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
unless defined?(SKIPPED_CONVENIENCE_KEYS)
|
122
|
+
SKIPPED_CONVENIENCE_KEYS = %w{
|
123
|
+
application_identifier
|
124
|
+
caption
|
125
|
+
creation_class_name
|
126
|
+
size
|
127
|
+
system_creation_class_name
|
128
|
+
record_id
|
129
|
+
}.freeze
|
130
|
+
end
|
127
131
|
|
128
132
|
# create simplified convenience access keys for each record type
|
129
133
|
# for single occurrences of one type, copy to top level all fields and values
|
@@ -23,10 +23,12 @@ require "socket" unless defined?(Socket)
|
|
23
23
|
module Ohai
|
24
24
|
module Mixin
|
25
25
|
module NetworkHelper
|
26
|
-
FAMILIES
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
unless defined?(FAMILIES)
|
27
|
+
FAMILIES = {
|
28
|
+
"inet" => "default",
|
29
|
+
"inet6" => "default_inet6",
|
30
|
+
}.freeze
|
31
|
+
end
|
30
32
|
|
31
33
|
def hex_to_dec_netmask(netmask)
|
32
34
|
# example 'ffff0000' -> '255.255.0.0'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Author:: Renato Covarrubias (<rnt@rnt.cl>)
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require "net/http" unless defined?(Net::HTTP)
|
20
|
+
|
21
|
+
module Ohai
|
22
|
+
module Mixin
|
23
|
+
module OCIMetadata
|
24
|
+
OCI_METADATA_ADDR = "169.254.169.254"
|
25
|
+
OCI_METADATA_URL = "/opc/v2"
|
26
|
+
CHASSIS_ASSET_TAG_FILE = "/sys/devices/virtual/dmi/id/chassis_asset_tag"
|
27
|
+
|
28
|
+
# fetch the meta content with a timeout and the required header
|
29
|
+
def http_get(uri)
|
30
|
+
conn = Net::HTTP.start(OCI_METADATA_ADDR)
|
31
|
+
conn.read_timeout = 6
|
32
|
+
conn.get(
|
33
|
+
uri,
|
34
|
+
{
|
35
|
+
"Authorization" => "Bearer Oracle",
|
36
|
+
"User-Agent" => "chef-ohai/#{Ohai::VERSION}",
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
# parse JSON data from a String to a Hash
|
42
|
+
#
|
43
|
+
# @param [String] response_body json as string to parse
|
44
|
+
#
|
45
|
+
# @return [Hash]
|
46
|
+
def parse_json(response_body)
|
47
|
+
data = String(response_body)
|
48
|
+
parser = FFI_Yajl::Parser.new
|
49
|
+
parser.parse(data)
|
50
|
+
rescue FFI_Yajl::ParseError
|
51
|
+
logger.warn("Mixin OciMetadata: Metadata response is NOT valid JSON")
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
# Fetch metadata from api
|
56
|
+
def fetch_metadata(metadata = "instance")
|
57
|
+
response = http_get("#{OCI_METADATA_URL}/#{metadata}")
|
58
|
+
return nil unless response.code == "200"
|
59
|
+
|
60
|
+
if response.code == "200"
|
61
|
+
parse_json(response.body)
|
62
|
+
else
|
63
|
+
logger.warn("Mixin OciMetadata: Received response code #{response.code} requesting metadata")
|
64
|
+
nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/ohai/plugins/alibaba.rb
CHANGED
@@ -33,7 +33,7 @@ Ohai.plugin(:Alibaba) do
|
|
33
33
|
# this works even if the system lacks dmidecode use by the Dmi plugin
|
34
34
|
# @return [Boolean] do we have Alibaba DMI data?
|
35
35
|
def has_ali_dmi?
|
36
|
-
if
|
36
|
+
if file_val_if_exists("/sys/class/dmi/id/sys_vendor").to_s.include?("Alibaba")
|
37
37
|
logger.trace("Plugin Alibaba: has_ali_dmi? == true")
|
38
38
|
true
|
39
39
|
else
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -58,7 +58,7 @@ Ohai.plugin(:Azure) do
|
|
58
58
|
has_245 = false
|
59
59
|
if file_exist?("/var/lib/dhcp/dhclient.eth0.leases")
|
60
60
|
file_open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
|
61
|
-
if
|
61
|
+
if line.include?("unknown-245")
|
62
62
|
logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
|
63
63
|
has_245 = true
|
64
64
|
break
|
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -28,6 +28,7 @@ Ohai.plugin(:Cloud) do
|
|
28
28
|
depends "azure"
|
29
29
|
depends "digital_ocean"
|
30
30
|
depends "softlayer"
|
31
|
+
depends "oci"
|
31
32
|
|
32
33
|
# Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
|
33
34
|
#
|
@@ -336,6 +337,26 @@ Ohai.plugin(:Cloud) do
|
|
336
337
|
@cloud_attr_obj.provider = "softlayer"
|
337
338
|
end
|
338
339
|
|
340
|
+
# ----------------------------------------
|
341
|
+
# OCI
|
342
|
+
# ----------------------------------------
|
343
|
+
|
344
|
+
# Is current Oracle Cloud Infrastructure?
|
345
|
+
#
|
346
|
+
# === Return
|
347
|
+
# true:: If oci Hash is defined
|
348
|
+
# false:: Otherwise
|
349
|
+
def on_oci?
|
350
|
+
oci != nil
|
351
|
+
end
|
352
|
+
|
353
|
+
# Fill cloud hash with OCI values
|
354
|
+
def oci_values
|
355
|
+
oci["metadata"]["network"]["interface"].each { |vnic| @cloud_attr_obj.add_ipv4_addr(vnic["privateIp"], :private) }
|
356
|
+
@cloud_attr_obj.local_hostname = oci["metadata"]["compute"]["hostname"]
|
357
|
+
@cloud_attr_obj.provider = "oci"
|
358
|
+
end
|
359
|
+
|
339
360
|
collect_data do
|
340
361
|
require "ipaddr" unless defined?(IPAddr)
|
341
362
|
|
@@ -351,6 +372,7 @@ Ohai.plugin(:Cloud) do
|
|
351
372
|
get_digital_ocean_values if on_digital_ocean?
|
352
373
|
get_softlayer_values if on_softlayer?
|
353
374
|
get_alibaba_values if on_alibaba?
|
375
|
+
oci_values if on_oci?
|
354
376
|
|
355
377
|
cloud @cloud_attr_obj.cloud_mash
|
356
378
|
end
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -193,7 +193,8 @@ Ohai.plugin(:CPU) do
|
|
193
193
|
lscpu_real = lscpu_info[:sockets]
|
194
194
|
lscpu_cores = lscpu_info[:sockets] * lscpu_info[:cores_per_socket]
|
195
195
|
else
|
196
|
-
|
196
|
+
threads_per_core = [lscpu_info[:threads_per_core], 1].max
|
197
|
+
lscpu_total = lscpu_info[:sockets] * lscpu_info[:cores_per_socket] * threads_per_core
|
197
198
|
lscpu_real = lscpu_info[:sockets]
|
198
199
|
lscpu_cores = lscpu_info[:sockets] * lscpu_info[:cores_per_socket]
|
199
200
|
end
|
@@ -344,15 +345,23 @@ Ohai.plugin(:CPU) do
|
|
344
345
|
cpuinfo
|
345
346
|
end
|
346
347
|
|
348
|
+
# Check if the `lscpu` data looks reasonable
|
349
|
+
def valid_lscpu?(lscpu)
|
350
|
+
return false if lscpu.empty?
|
351
|
+
return false if %i{total real cores}.any? { |key| lscpu[key].to_i == 0 }
|
352
|
+
|
353
|
+
true
|
354
|
+
end
|
355
|
+
|
347
356
|
collect_data(:linux) do
|
348
357
|
cpuinfo = parse_cpuinfo
|
349
358
|
lscpu = parse_lscpu(cpuinfo)
|
350
359
|
|
351
|
-
# If we don't have any data from lscpu then get it from /proc/cpuinfo
|
352
|
-
if lscpu
|
353
|
-
cpu cpuinfo
|
354
|
-
else
|
360
|
+
# If we don't have any sensible data from lscpu then get it from /proc/cpuinfo
|
361
|
+
if valid_lscpu?(lscpu)
|
355
362
|
cpu lscpu
|
363
|
+
else
|
364
|
+
cpu cpuinfo
|
356
365
|
end
|
357
366
|
end
|
358
367
|
|
@@ -515,7 +524,7 @@ Ohai.plugin(:CPU) do
|
|
515
524
|
cpu[index] = Mash.new
|
516
525
|
cpu[index][:status] = status
|
517
526
|
cpu[index][:location] = location
|
518
|
-
if
|
527
|
+
if status.include?("Available")
|
519
528
|
cpu[:available] += 1
|
520
529
|
lsattr = shell_out("lsattr -El #{name}").stdout.lines
|
521
530
|
lsattr.each do |attribute|
|
@@ -77,17 +77,14 @@ Ohai.plugin(:Virtualization) do
|
|
77
77
|
virtualization[:systems][:vmware] = "guest"
|
78
78
|
end
|
79
79
|
|
80
|
-
if
|
80
|
+
if ioreg_exists? && shell_out("ioreg -l").stdout.include?("pci1ab8,4000")
|
81
|
+
virtualization[:system] = "parallels"
|
82
|
+
virtualization[:role] = "guest"
|
83
|
+
virtualization[:systems][:parallels] = "guest"
|
84
|
+
elsif prlctl_exists?
|
81
85
|
virtualization[:system] = "parallels"
|
82
86
|
virtualization[:role] = "host"
|
83
87
|
virtualization[:systems][:parallels] = "host"
|
84
|
-
elsif ioreg_exists?
|
85
|
-
so = shell_out("ioreg -l")
|
86
|
-
if /pci1ab8,4000/.match?(so.stdout)
|
87
|
-
virtualization[:system] = "parallels"
|
88
|
-
virtualization[:role] = "guest"
|
89
|
-
virtualization[:systems][:parallels] = "guest"
|
90
|
-
end
|
91
88
|
end
|
92
89
|
end
|
93
|
-
end
|
90
|
+
end
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -28,10 +28,8 @@
|
|
28
28
|
|
29
29
|
Ohai.plugin(:EC2) do
|
30
30
|
require_relative "../mixin/ec2_metadata"
|
31
|
-
require_relative "../mixin/http_helper"
|
32
31
|
|
33
32
|
include Ohai::Mixin::Ec2Metadata
|
34
|
-
include Ohai::Mixin::HttpHelper
|
35
33
|
|
36
34
|
provides "ec2"
|
37
35
|
|
@@ -41,7 +39,7 @@ Ohai.plugin(:EC2) do
|
|
41
39
|
# @return [Boolean] do we have Amazon DMI data?
|
42
40
|
def has_ec2_amazon_dmi?
|
43
41
|
# detect a version of '4.2.amazon'
|
44
|
-
if
|
42
|
+
if file_val_if_exists("/sys/class/dmi/id/bios_vendor").to_s.include?("Amazon")
|
45
43
|
logger.trace("Plugin EC2: has_ec2_amazon_dmi? == true")
|
46
44
|
true
|
47
45
|
else
|
@@ -56,7 +54,7 @@ Ohai.plugin(:EC2) do
|
|
56
54
|
# @return [Boolean] do we have Amazon DMI data?
|
57
55
|
def has_ec2_xen_dmi?
|
58
56
|
# detect a version of '4.2.amazon'
|
59
|
-
if
|
57
|
+
if file_val_if_exists("/sys/class/dmi/id/bios_version").to_s.include?("amazon")
|
60
58
|
logger.trace("Plugin EC2: has_ec2_xen_dmi? == true")
|
61
59
|
true
|
62
60
|
else
|
@@ -106,12 +104,7 @@ Ohai.plugin(:EC2) do
|
|
106
104
|
# a single check that combines all the various detection methods for EC2
|
107
105
|
# @return [Boolean] Does the system appear to be on EC2
|
108
106
|
def looks_like_ec2?
|
109
|
-
|
110
|
-
|
111
|
-
# Even if it looks like EC2 try to connect first
|
112
|
-
if has_ec2_xen_uuid? || has_ec2_amazon_dmi? || has_ec2_xen_dmi? || has_ec2_identifying_number?
|
113
|
-
return true if can_socket_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
|
114
|
-
end
|
107
|
+
hint?("ec2") || has_ec2_xen_uuid? || has_ec2_amazon_dmi? || has_ec2_xen_dmi? || has_ec2_identifying_number?
|
115
108
|
end
|
116
109
|
|
117
110
|
collect_data do
|
data/lib/ohai/plugins/fips.rb
CHANGED
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -28,7 +28,7 @@ Ohai.plugin(:GCE) do
|
|
28
28
|
# this works even if the system lacks dmidecode use by the Dmi plugin
|
29
29
|
# @return [Boolean] do we have Google Compute Engine DMI data?
|
30
30
|
def has_gce_dmi?
|
31
|
-
if
|
31
|
+
if file_val_if_exists("/sys/class/dmi/id/product_name").to_s.include?("Google Compute Engine")
|
32
32
|
logger.trace("Plugin GCE: has_gce_dmi? == true")
|
33
33
|
true
|
34
34
|
else
|
@@ -79,7 +79,7 @@ Ohai.plugin(:Network) do
|
|
79
79
|
so.stdout.lines do |line|
|
80
80
|
line.strip!
|
81
81
|
logger.trace("Plugin Network: Parsing #{line}")
|
82
|
-
if
|
82
|
+
if line.include?("\\")
|
83
83
|
# If we have multipath routing, then the first part will be a normal
|
84
84
|
# looking route:
|
85
85
|
# default proto ra metric 1024 <other options>
|
@@ -218,11 +218,11 @@ Ohai.plugin(:Network) do
|
|
218
218
|
next if line.start_with?("Ring parameters for")
|
219
219
|
next if line.strip.nil?
|
220
220
|
|
221
|
-
if
|
221
|
+
if line.include?("Pre-set maximums")
|
222
222
|
type = "max"
|
223
223
|
next
|
224
224
|
end
|
225
|
-
if
|
225
|
+
if line.include?("Current hardware settings")
|
226
226
|
type = "current"
|
227
227
|
next
|
228
228
|
end
|
@@ -251,11 +251,11 @@ Ohai.plugin(:Network) do
|
|
251
251
|
next if line.start_with?("Channel parameters for")
|
252
252
|
next if line.strip.nil?
|
253
253
|
|
254
|
-
if
|
254
|
+
if line.include?("Pre-set maximums")
|
255
255
|
type = "max"
|
256
256
|
next
|
257
257
|
end
|
258
|
-
if
|
258
|
+
if line.include?("Current hardware settings")
|
259
259
|
type = "current"
|
260
260
|
next
|
261
261
|
end
|
@@ -149,7 +149,8 @@ Ohai.plugin(:Platform) do
|
|
149
149
|
"rhel"
|
150
150
|
when /amazon/
|
151
151
|
"amazon"
|
152
|
-
|
152
|
+
# suse matches opensuse, suse-* opensuse-*, etc. sle[sd\-_] intends to match sles, sled, sle-*, sle_*
|
153
|
+
when /suse/, /sle[sd\-_]/
|
153
154
|
"suse"
|
154
155
|
when /fedora/, /arista_eos/
|
155
156
|
# In the broadest sense: RPM-based, fedora-derived distributions which are not strictly re-compiled RHEL (if it uses RPMs, and smells more like redhat and less like
|
@@ -257,7 +258,7 @@ Ohai.plugin(:Platform) do
|
|
257
258
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
258
259
|
elsif file_exist?("/usr/lib/os-release")
|
259
260
|
contents = file_read("/usr/lib/os-release")
|
260
|
-
if
|
261
|
+
if contents.include?("clear-linux-os") # Clear Linux https://clearlinux.org/
|
261
262
|
platform "clearlinux"
|
262
263
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
263
264
|
end
|
@@ -118,7 +118,7 @@ Ohai.plugin(:Virtualization) do
|
|
118
118
|
# guests will have the hypervisor cpu feature that hosts don't have
|
119
119
|
if file_exist?("/sys/devices/virtual/misc/kvm")
|
120
120
|
virtualization[:system] = "kvm"
|
121
|
-
if
|
121
|
+
if file_read("/proc/cpuinfo").include?("hypervisor")
|
122
122
|
logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
|
123
123
|
virtualization[:role] = "guest"
|
124
124
|
virtualization[:systems][:kvm] = "guest"
|
@@ -220,17 +220,17 @@ Ohai.plugin(:Virtualization) do
|
|
220
220
|
virtualization[:system] = $1
|
221
221
|
virtualization[:role] = "guest"
|
222
222
|
virtualization[:systems][$1.to_sym] = "guest"
|
223
|
-
elsif
|
223
|
+
elsif file_read("/proc/1/environ").include?("container=lxc")
|
224
224
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
|
225
225
|
virtualization[:system] = "lxc"
|
226
226
|
virtualization[:role] = "guest"
|
227
227
|
virtualization[:systems][:lxc] = "guest"
|
228
|
-
elsif
|
228
|
+
elsif file_read("/proc/1/environ").include?("container=systemd-nspawn")
|
229
229
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
|
230
230
|
virtualization[:system] = "nspawn"
|
231
231
|
virtualization[:role] = "guest"
|
232
232
|
virtualization[:systems][:nspawn] = "guest"
|
233
|
-
elsif
|
233
|
+
elsif file_read("/proc/1/environ").include?("container=podman")
|
234
234
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates podman container. Detecting as podman guest")
|
235
235
|
virtualization[:system] = "podman"
|
236
236
|
virtualization[:role] = "guest"
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Author:: Renato Covarrubias (<rnt@rnt.cl>)
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Oci) do
|
21
|
+
require_relative "../mixin/oci_metadata"
|
22
|
+
require_relative "../mixin/http_helper"
|
23
|
+
|
24
|
+
include Ohai::Mixin::OCIMetadata
|
25
|
+
include Ohai::Mixin::HttpHelper
|
26
|
+
|
27
|
+
provides "oci"
|
28
|
+
|
29
|
+
collect_data do
|
30
|
+
oci_metadata_from_hints = hint?("oci")
|
31
|
+
if oci_metadata_from_hints
|
32
|
+
logger.trace("Plugin OCI: oci hint is present. Parsing any hint data.")
|
33
|
+
oci Mash.new
|
34
|
+
oci_metadata_from_hints.each { |k, v| oci[k] = v }
|
35
|
+
oci["metadata"] = parse_metadata
|
36
|
+
elsif oci_chassis_asset_tag?
|
37
|
+
logger.trace("Plugin oci: No hints present, but system appears to be on oci.")
|
38
|
+
oci Mash.new
|
39
|
+
oci["metadata"] = parse_metadata
|
40
|
+
else
|
41
|
+
logger.trace("Plugin oci: No hints present and doesn't appear to be on oci.")
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def oci_chassis_asset_tag?
|
47
|
+
has_oci_chassis_asset_tag = false
|
48
|
+
if file_exist?(Ohai::Mixin::OCIMetadata::CHASSIS_ASSET_TAG_FILE)
|
49
|
+
file_open(Ohai::Mixin::OCIMetadata::CHASSIS_ASSET_TAG_FILE).each do |line|
|
50
|
+
next unless /OracleCloud.com/.match?(line)
|
51
|
+
|
52
|
+
logger.trace("Plugin oci: Found OracleCloud.com chassis_asset_tag used by oci.")
|
53
|
+
has_oci_chassis_asset_tag = true
|
54
|
+
break
|
55
|
+
end
|
56
|
+
end
|
57
|
+
has_oci_chassis_asset_tag
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_metadata
|
61
|
+
return nil unless can_socket_connect?(Ohai::Mixin::OCIMetadata::OCI_METADATA_ADDR, 80)
|
62
|
+
|
63
|
+
instance_data = fetch_metadata("instance")
|
64
|
+
return nil if instance_data.nil?
|
65
|
+
|
66
|
+
metadata = Mash.new
|
67
|
+
metadata["compute"] = Mash.new
|
68
|
+
|
69
|
+
instance_data.each do |k, v|
|
70
|
+
metadata["compute"][k] = v
|
71
|
+
end
|
72
|
+
|
73
|
+
vnics_data = fetch_metadata("vnics")
|
74
|
+
|
75
|
+
unless vnics_data.nil?
|
76
|
+
metadata["network"] = Mash.new
|
77
|
+
metadata["network"]["interface"] = []
|
78
|
+
vnics_data.each do |v|
|
79
|
+
metadata["network"]["interface"].append(v)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
volume_attachments_data = fetch_metadata("volumeAttachments")
|
84
|
+
|
85
|
+
unless volume_attachments_data.nil?
|
86
|
+
metadata["volumes"] = Mash.new
|
87
|
+
volume_attachments_data.each do |k, v|
|
88
|
+
metadata["volumes"][k] = v
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
metadata
|
93
|
+
end
|
94
|
+
end
|
data/lib/ohai/plugins/rpm.rb
CHANGED
@@ -22,16 +22,18 @@ Ohai.plugin(:Rpm) do
|
|
22
22
|
provides "rpm"
|
23
23
|
optional "true"
|
24
24
|
|
25
|
-
MACROS_MARKER = /========================/.freeze
|
25
|
+
MACROS_MARKER = /========================/.freeze unless defined?(MACROS_MARKER)
|
26
26
|
|
27
|
-
DO_NOT_SPLIT
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
unless defined?(DO_NOT_SPLIT)
|
28
|
+
DO_NOT_SPLIT = %w{
|
29
|
+
build_arch
|
30
|
+
build_os
|
31
|
+
install_arch
|
32
|
+
install_os
|
33
|
+
archcolor
|
34
|
+
optflags
|
35
|
+
}.freeze
|
36
|
+
end
|
35
37
|
|
36
38
|
collect_data(:aix, :darwin, :dragonflybsd, :freebsd, :linux, :netbsd, :openbsd, :solaris2) do
|
37
39
|
rpm_path = which("rpm")
|
@@ -27,7 +27,7 @@ Ohai.plugin(:Scaleway) do
|
|
27
27
|
# looks for `scaleway` keyword in kernel command line
|
28
28
|
# @return [Boolean] do we have the keyword or not?
|
29
29
|
def has_scaleway_cmdline?
|
30
|
-
if file_exist?("/proc/cmdline") &&
|
30
|
+
if file_exist?("/proc/cmdline") && file_read("/proc/cmdline").include?("scaleway")
|
31
31
|
logger.trace("Plugin Scaleway: has_scaleway_cmdline? == true")
|
32
32
|
return true
|
33
33
|
end
|
@@ -21,5 +21,25 @@ Ohai.plugin(:Timezone) do
|
|
21
21
|
collect_data(:default) do
|
22
22
|
time Mash.new unless time
|
23
23
|
time[:timezone] = Time.now.getlocal.zone
|
24
|
+
|
25
|
+
# Windows in German display language outputs LATIN1 bytes for .zone, but marks them as
|
26
|
+
# IBM437, which somehow fails any attempt at conversion to other encodings when
|
27
|
+
# ä is present, as in the timezone name "Mitteleuropäische Zeit" (Central Europe Time)
|
28
|
+
#
|
29
|
+
# Windows-1252 is the legacy encoding for Windows for German that actually
|
30
|
+
# translates (ISO-8859-1 works as well), but going with the more correct
|
31
|
+
# encoding name for Windows' implementation of Latin-1
|
32
|
+
#
|
33
|
+
# References
|
34
|
+
# * [Code Page 437/IBM437](https://en.wikipedia.org/wiki/Code_page_437)
|
35
|
+
# * [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
|
36
|
+
# * [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252)
|
37
|
+
if time[:timezone].encoding == Encoding::IBM437
|
38
|
+
# Assume encoding is WINDOWS_1252
|
39
|
+
time[:timezone] = time[:timezone].force_encoding(Encoding::WINDOWS_1252)
|
40
|
+
# Re-encode in UTF_8. Note: If other encodings have problems converting
|
41
|
+
# it might be worth re-encode everything in UTF_8.
|
42
|
+
time[:timezone] = time[:timezone].encode(Encoding::UTF_8)
|
43
|
+
end
|
24
44
|
end
|
25
45
|
end
|
data/lib/ohai/plugins/vmware.rb
CHANGED
@@ -53,7 +53,22 @@ Ohai.plugin(:VMware) do
|
|
53
53
|
# to attribute "vmware[:<parameter>]"
|
54
54
|
%w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
|
55
55
|
vmware[param] = from_cmd([vmtools_path, "stat", param])
|
56
|
-
if
|
56
|
+
if param == "hosttime" && vmtools_path.include?("Program Files")
|
57
|
+
# popen and %x return stdout encoded as IBM437 in Windows but in a string marked
|
58
|
+
# UTF-8. The string doesn't throw an exception when encoded to "UTF-8" but
|
59
|
+
# displays [?] character in Windows without this.
|
60
|
+
#
|
61
|
+
# .force_encoding(Encoding::ISO_8859_1) causes the character to be dropped
|
62
|
+
# and .force_encoding(Encoding::Windows_1252) displays the „ character in place
|
63
|
+
# of an ä. .force_encoding(Encoding::IBM437) allows for the correct characters
|
64
|
+
# to be displayed.
|
65
|
+
#
|
66
|
+
# Note:
|
67
|
+
# * this is broken for at least Ruby 2.7 through 3.1.3
|
68
|
+
# * confirmed that this is broken on Windows Server 2022
|
69
|
+
vmware[param] = vmware[param].force_encoding(Encoding::IBM437).encode("UTF-8")
|
70
|
+
end
|
71
|
+
if vmware[param].include?("UpdateInfo failed")
|
57
72
|
vmware[param] = nil
|
58
73
|
end
|
59
74
|
end
|
data/lib/ohai/util/ip_helper.rb
CHANGED
@@ -21,8 +21,8 @@ module Ohai
|
|
21
21
|
require "ipaddress" unless defined?(IPAddress)
|
22
22
|
|
23
23
|
# Corresponding to RFC 4192 + RFC 4193
|
24
|
-
IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10")
|
25
|
-
IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7")
|
24
|
+
IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10") unless defined?(IPV6_LINK_LOCAL_UNICAST_BLOCK)
|
25
|
+
IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7") unless defined?(IPV6_PRIVATE_ADDRESS_BLOCK)
|
26
26
|
|
27
27
|
def private_address?(addr)
|
28
28
|
ip = IPAddress(addr)
|
data/lib/ohai/version.rb
CHANGED
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.0
|
4
|
+
version: 18.1.0
|
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: 2023-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -241,6 +241,7 @@ files:
|
|
241
241
|
- lib/ohai/mixin/gce_metadata.rb
|
242
242
|
- lib/ohai/mixin/http_helper.rb
|
243
243
|
- lib/ohai/mixin/network_helper.rb
|
244
|
+
- lib/ohai/mixin/oci_metadata.rb
|
244
245
|
- lib/ohai/mixin/os.rb
|
245
246
|
- lib/ohai/mixin/scaleway_metadata.rb
|
246
247
|
- lib/ohai/mixin/seconds_to_human.rb
|
@@ -324,6 +325,7 @@ files:
|
|
324
325
|
- lib/ohai/plugins/netbsd/platform.rb
|
325
326
|
- lib/ohai/plugins/network.rb
|
326
327
|
- lib/ohai/plugins/nodejs.rb
|
328
|
+
- lib/ohai/plugins/oci.rb
|
327
329
|
- lib/ohai/plugins/ohai.rb
|
328
330
|
- lib/ohai/plugins/ohai_time.rb
|
329
331
|
- lib/ohai/plugins/openbsd/memory.rb
|