ohai 16.0.20 → 16.3.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/dsl/plugin.rb +1 -1
- data/lib/ohai/mash.rb +21 -201
- data/lib/ohai/mixin/command.rb +1 -1
- data/lib/ohai/mixin/dmi_decode.rb +1 -1
- data/lib/ohai/plugins/aix/uptime.rb +1 -1
- data/lib/ohai/plugins/aix/virtualization.rb +5 -5
- data/lib/ohai/plugins/azure.rb +1 -1
- data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
- data/lib/ohai/plugins/cpu.rb +2 -2
- data/lib/ohai/plugins/darwin/hardware.rb +2 -2
- data/lib/ohai/plugins/darwin/network.rb +3 -3
- data/lib/ohai/plugins/darwin/platform.rb +3 -6
- data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +5 -5
- data/lib/ohai/plugins/eucalyptus.rb +1 -1
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/kernel.rb +8 -7
- data/lib/ohai/plugins/linux/interrupts.rb +1 -1
- data/lib/ohai/plugins/linux/mdadm.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +8 -6
- data/lib/ohai/plugins/linux/platform.rb +8 -8
- data/lib/ohai/plugins/linux/selinux.rb +68 -0
- data/lib/ohai/plugins/linux/virtualization.rb +12 -9
- data/lib/ohai/plugins/network.rb +1 -1
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +2 -2
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +1 -1
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/vmware.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +1 -1
- data/lib/ohai/provides_map.rb +2 -2
- data/lib/ohai/util/win32.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b791ee540d095a6bbdca2f681a5b2dbbe8574f2b58e5ba9c274fdaccc210c86f
|
4
|
+
data.tar.gz: db0fc191334ce76a8c0effc4a66afd1c9f025125e10186feb0f3ebf03dbb1768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b5f2dfbe7e517ef9f0bb6fa334bb66e8b6623356fabe0211aa895e416a50fbb6b97d39cfc422cc7727d2d943aa3aa8ff4e3f5fe71877f702212b55a83484115
|
7
|
+
data.tar.gz: d1a23eb7a0cc5aa5619edb4568ae2e4f0e930d4356ecea2356a789c8c37b49ea0660d9c39b11bddb577f78871dc0c383e2af2bb03c8eac6120fe680e89797622
|
data/Gemfile
CHANGED
data/lib/ohai/dsl/plugin.rb
CHANGED
data/lib/ohai/mash.rb
CHANGED
@@ -1,201 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
# ---
|
23
|
-
# ---
|
24
|
-
|
25
|
-
# Some portions of blank.rb and mash.rb are verbatim copies of software
|
26
|
-
# licensed under the MIT license. That license is included below:
|
27
|
-
|
28
|
-
# Copyright (c) 2005-2008 David Heinemeier Hansson
|
29
|
-
|
30
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
31
|
-
# a copy of this software and associated documentation files (the
|
32
|
-
# "Software"), to deal in the Software without restriction, including
|
33
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
34
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
35
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
36
|
-
# the following conditions:
|
37
|
-
|
38
|
-
# The above copyright notice and this permission notice shall be
|
39
|
-
# included in all copies or substantial portions of the Software.
|
40
|
-
|
41
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
42
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
43
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
44
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
45
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
46
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
47
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
48
|
-
|
49
|
-
# This class has dubious semantics and we only have it so that people can write
|
50
|
-
# params[:key] instead of params['key'].
|
51
|
-
class Mash < Hash
|
52
|
-
|
53
|
-
# @param constructor [Object] The default value for the mash.
|
54
|
-
# If constructor is a Hash, a new mash will be created based on the keys of the hash and
|
55
|
-
# no default value will be set.
|
56
|
-
def initialize(constructor = {})
|
57
|
-
if constructor.is_a?(Hash)
|
58
|
-
super()
|
59
|
-
update(constructor)
|
60
|
-
else
|
61
|
-
super(constructor)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# @param key [Object] The default value for the mash.
|
66
|
-
# If key is a Symbol and it is a key in the mash, then the default value will be set to
|
67
|
-
# the value matching the key.
|
68
|
-
def default(key = nil)
|
69
|
-
if key.is_a?(Symbol) && include?(key = key.to_s)
|
70
|
-
self[key]
|
71
|
-
else
|
72
|
-
super
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
77
|
-
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
78
|
-
|
79
|
-
# @param key [Object] The key to set.
|
80
|
-
# @param value [Object] The value to set the key to.
|
81
|
-
#
|
82
|
-
# @see Mash#convert_key
|
83
|
-
# @see Mash#convert_value
|
84
|
-
def []=(key, value)
|
85
|
-
regular_writer(convert_key(key), convert_value(value))
|
86
|
-
end
|
87
|
-
|
88
|
-
# @param other_hash [Hash]
|
89
|
-
# A hash to update values in the mash with. The keys and the values will be
|
90
|
-
# converted to Mash format.
|
91
|
-
#
|
92
|
-
# @return [Mash] The updated mash.
|
93
|
-
def update(other_hash)
|
94
|
-
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
|
95
|
-
self
|
96
|
-
end
|
97
|
-
|
98
|
-
alias_method :merge!, :update
|
99
|
-
|
100
|
-
# @param key [Object] The key to check for. This will be run through convert_key.
|
101
|
-
#
|
102
|
-
# @return [Boolean] True if the key exists in the mash.
|
103
|
-
def key?(key)
|
104
|
-
super(convert_key(key))
|
105
|
-
end
|
106
|
-
|
107
|
-
# def include? def has_key? def member?
|
108
|
-
alias_method :include?, :key?
|
109
|
-
alias_method :has_key?, :key?
|
110
|
-
alias_method :member?, :key?
|
111
|
-
|
112
|
-
# @param key [Object] The key to fetch. This will be run through convert_key.
|
113
|
-
# @param extras [Array] Default value.
|
114
|
-
#
|
115
|
-
# @return [Object] The value at key or the default value.
|
116
|
-
def fetch(key, *extras)
|
117
|
-
super(convert_key(key), *extras)
|
118
|
-
end
|
119
|
-
|
120
|
-
# @param indices [Array] The keys to retrieve values for. These will be run through +convert_key+.
|
121
|
-
#
|
122
|
-
# @return [Array] The values at each of the provided keys
|
123
|
-
def values_at(*indices)
|
124
|
-
indices.collect { |key| self[convert_key(key)] }
|
125
|
-
end
|
126
|
-
|
127
|
-
# @param hash [Hash] The hash to merge with the mash.
|
128
|
-
#
|
129
|
-
# @return [Mash] A new mash with the hash values merged in.
|
130
|
-
def merge(hash)
|
131
|
-
dup.update(hash)
|
132
|
-
end
|
133
|
-
|
134
|
-
# @param key [Object] The key to delete from the mash.
|
135
|
-
def delete(key)
|
136
|
-
super(convert_key(key))
|
137
|
-
end
|
138
|
-
|
139
|
-
# @param keys [Array<String, Symbol>] The mash keys to exclude.
|
140
|
-
#
|
141
|
-
# @return [Mash] A new mash without the selected keys.
|
142
|
-
#
|
143
|
-
# @example
|
144
|
-
# { :one => 1, :two => 2, :three => 3 }.except(:one)
|
145
|
-
# #=> { "two" => 2, "three" => 3 }
|
146
|
-
def except(*keys)
|
147
|
-
super(*keys.map { |k| convert_key(k) })
|
148
|
-
end
|
149
|
-
|
150
|
-
# Used to provide the same interface as Hash.
|
151
|
-
#
|
152
|
-
# @return [Mash] This mash unchanged.
|
153
|
-
def stringify_keys!; self end
|
154
|
-
|
155
|
-
# @return [Hash] The mash as a Hash with symbolized keys.
|
156
|
-
def symbolize_keys
|
157
|
-
h = Hash.new(default)
|
158
|
-
each { |key, val| h[key.to_sym] = val }
|
159
|
-
h
|
160
|
-
end
|
161
|
-
|
162
|
-
# @return [Hash] The mash as a Hash with string keys.
|
163
|
-
def to_hash
|
164
|
-
Hash.new(default).merge(self)
|
165
|
-
end
|
166
|
-
|
167
|
-
# Convert a Hash into a Mash. The input Hash's default value is maintained
|
168
|
-
# @return [Mash]
|
169
|
-
def self.from_hash(hash)
|
170
|
-
mash = Mash.new(hash)
|
171
|
-
mash.default = hash.default
|
172
|
-
mash
|
173
|
-
end
|
174
|
-
|
175
|
-
protected
|
176
|
-
|
177
|
-
# @param key [Object] The key to convert.
|
178
|
-
# @return [Object] The converted key. If the key was a symbol, it will be converted to a string.
|
179
|
-
#
|
180
|
-
# @api private
|
181
|
-
def convert_key(key)
|
182
|
-
key.is_a?(Symbol) ? key.to_s : key
|
183
|
-
end
|
184
|
-
|
185
|
-
# @param value [Object] The value to convert.
|
186
|
-
#
|
187
|
-
# @return [Object]
|
188
|
-
# The converted value. A Hash or an Array of hashes, will be converted to
|
189
|
-
# their Mash equivalents.
|
190
|
-
#
|
191
|
-
# @api private
|
192
|
-
def convert_value(value)
|
193
|
-
if value.class == Hash
|
194
|
-
Mash.from_hash(value)
|
195
|
-
elsif value.is_a?(Array)
|
196
|
-
value.collect { |e| convert_value(e) }
|
197
|
-
else
|
198
|
-
value
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "chef-utils/mash" unless defined?(ChefUtils::Mash)
|
19
|
+
|
20
|
+
# For historical reasons we inject Mash directly into the top level class namespace
|
21
|
+
Mash = ChefUtils::Mash unless defined?(Mash)
|
data/lib/ohai/mixin/command.rb
CHANGED
@@ -30,7 +30,7 @@ module Ohai
|
|
30
30
|
options = options.dup
|
31
31
|
# unless specified by the caller timeout after configured timeout (default 30 seconds)
|
32
32
|
options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
|
33
|
-
unless RUBY_PLATFORM
|
33
|
+
unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
34
34
|
options[:env] = options.key?(:env) ? options[:env].dup : {}
|
35
35
|
options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
|
36
36
|
end
|
@@ -30,7 +30,7 @@ Ohai.plugin(:Uptime) do
|
|
30
30
|
so = shell_out("LC_ALL=POSIX ps -o etime= -p 1").stdout.strip
|
31
31
|
|
32
32
|
# Here we'll check our shell_out for a dash, which indicates there is a # of days involved
|
33
|
-
# We'll chunk off the days, hours (where applicable), minutes, seconds into
|
33
|
+
# We'll chunk off the days, hours (where applicable), minutes, seconds into separate vars
|
34
34
|
# We also need to do this because ps -o etime= will not display days if the machine has been up for less than 24 hours
|
35
35
|
# If the machine has been up for less than one hour, the shell_out will not output hours hence our else
|
36
36
|
# see here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm#ps__row-d3e109655
|
@@ -57,7 +57,7 @@ Ohai.plugin(:Virtualization) do
|
|
57
57
|
sections.each do |line|
|
58
58
|
case title
|
59
59
|
when "network"
|
60
|
-
next if
|
60
|
+
next if /^Interface|^---/.match?(line)
|
61
61
|
|
62
62
|
splat = line.strip.split
|
63
63
|
key = splat[0].downcase
|
@@ -68,7 +68,7 @@ Ohai.plugin(:Virtualization) do
|
|
68
68
|
}
|
69
69
|
wpars[wpar_name][title][key] = value
|
70
70
|
when "user-specified routes"
|
71
|
-
next if
|
71
|
+
next if /^Type|^---/.match?(line)
|
72
72
|
|
73
73
|
splat = line.strip.split
|
74
74
|
key = splat[2].downcase
|
@@ -78,7 +78,7 @@ Ohai.plugin(:Virtualization) do
|
|
78
78
|
}
|
79
79
|
wpars[wpar_name][title][key] = value
|
80
80
|
when "file systems"
|
81
|
-
next if
|
81
|
+
next if /^MountPoint|^---/.match?(line)
|
82
82
|
|
83
83
|
splat = line.strip.split
|
84
84
|
key = splat[1].downcase
|
@@ -93,7 +93,7 @@ Ohai.plugin(:Virtualization) do
|
|
93
93
|
privileges ||= ""
|
94
94
|
wpars[wpar_name][title]["Privileges"] ||= []
|
95
95
|
|
96
|
-
if
|
96
|
+
if /^Privileges/.match?(line)
|
97
97
|
privileges << line.split(":")[1].strip
|
98
98
|
else
|
99
99
|
privileges << line.strip
|
@@ -101,7 +101,7 @@ Ohai.plugin(:Virtualization) do
|
|
101
101
|
|
102
102
|
wpars[wpar_name][title]["Privileges"] += privileges.split(",")
|
103
103
|
when "device exports"
|
104
|
-
next if
|
104
|
+
next if /^Name|^---/.match?(line)
|
105
105
|
|
106
106
|
splat = line.strip.split
|
107
107
|
key = splat[0].downcase
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -57,7 +57,7 @@ Ohai.plugin(:Azure) do
|
|
57
57
|
has_245 = false
|
58
58
|
if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
|
59
59
|
File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
|
60
|
-
if
|
60
|
+
if /unknown-245/.match?(line)
|
61
61
|
logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
|
62
62
|
has_245 = true
|
63
63
|
break
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Virtualization) do
|
|
76
76
|
# Detect KVM/QEMU paravirt guests from cpu, report as KVM
|
77
77
|
# hw.model: QEMU Virtual CPU version 0.9.1
|
78
78
|
so = shell_out("sysctl -n hw.model")
|
79
|
-
if
|
79
|
+
if /QEMU Virtual CPU|KVM processor/.match?(so.stdout)
|
80
80
|
virtualization[:system] = "kvm"
|
81
81
|
virtualization[:role] = "guest"
|
82
82
|
virtualization[:systems][:kvm] = "guest"
|
@@ -96,7 +96,7 @@ Ohai.plugin(:Virtualization) do
|
|
96
96
|
"xen"
|
97
97
|
when /kvm/
|
98
98
|
so = shell_out("sysctl -n kern.hostuuid")
|
99
|
-
so.stdout
|
99
|
+
/^ec2/.match?(so.stdout) ? "amazonec2" : "kvm"
|
100
100
|
when /bhyve/
|
101
101
|
"bhyve"
|
102
102
|
end
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -305,7 +305,7 @@ Ohai.plugin(:CPU) do
|
|
305
305
|
cpu[index] = Mash.new
|
306
306
|
cpu[index][:status] = status
|
307
307
|
cpu[index][:location] = location
|
308
|
-
if
|
308
|
+
if /Available/.match?(status)
|
309
309
|
cpu[:available] += 1
|
310
310
|
lsattr = shell_out("lsattr -El #{name}").stdout.lines
|
311
311
|
lsattr.each do |attribute|
|
@@ -364,7 +364,7 @@ Ohai.plugin(:CPU) do
|
|
364
364
|
cpu["cpustates"][value] += 1
|
365
365
|
when /core_id/
|
366
366
|
cpu[instance]["core_id"] = value
|
367
|
-
|
367
|
+
# Detect hyperthreading/multithreading
|
368
368
|
cpucores.push(value) if cpucores.index(value).nil?
|
369
369
|
when /family|fpu_type|model|stepping|vendor_id/
|
370
370
|
cpu[instance][key] = value
|
@@ -41,8 +41,8 @@ Ohai.plugin(:Hardware) do
|
|
41
41
|
hardware.merge!(hw_hash[0]["_items"][0])
|
42
42
|
|
43
43
|
# ProductName: Mac OS X
|
44
|
-
# ProductVersion: 10.
|
45
|
-
# BuildVersion:
|
44
|
+
# ProductVersion: 10.15.6
|
45
|
+
# BuildVersion: 19G46c
|
46
46
|
shell_out("sw_vers").stdout.lines.each do |line|
|
47
47
|
case line
|
48
48
|
when /^ProductName:\s*(.*)$/
|
@@ -66,8 +66,8 @@ Ohai.plugin(:Network) do
|
|
66
66
|
|
67
67
|
def scope_lookup(scope)
|
68
68
|
return "Node" if scope.eql?("::1")
|
69
|
-
return "Link" if
|
70
|
-
return "Site" if
|
69
|
+
return "Link" if /^fe80\:/.match?(scope)
|
70
|
+
return "Site" if /^fec0\:/.match?(scope)
|
71
71
|
|
72
72
|
"Global"
|
73
73
|
end
|
@@ -79,7 +79,7 @@ Ohai.plugin(:Network) do
|
|
79
79
|
def locate_interface(ifaces, ifname, mac)
|
80
80
|
return ifname unless ifaces[ifname].nil?
|
81
81
|
# oh well, time to go hunting!
|
82
|
-
return ifname.chop if ifname
|
82
|
+
return ifname.chop if /\*$/.match?(ifname)
|
83
83
|
|
84
84
|
ifaces.each_key do |ifc|
|
85
85
|
ifaces[ifc][:addresses].each_key do |addr|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -23,11 +23,6 @@ Ohai.plugin(:Platform) do
|
|
23
23
|
so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s)
|
24
24
|
so.stdout.lines do |line|
|
25
25
|
case line
|
26
|
-
when /^ProductName:\s+(.+)$/
|
27
|
-
macname = $1
|
28
|
-
macname.downcase!
|
29
|
-
macname.tr!(" ", "_")
|
30
|
-
platform macname
|
31
26
|
when /^ProductVersion:\s+(.+)$/
|
32
27
|
platform_version $1
|
33
28
|
when /^BuildVersion:\s+(.+)$/
|
@@ -35,6 +30,8 @@ Ohai.plugin(:Platform) do
|
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
33
|
+
# if we're on darwin assume we're on mac_os_x
|
34
|
+
platform "mac_os_x"
|
38
35
|
platform_family "mac_os_x"
|
39
36
|
end
|
40
37
|
end
|
@@ -82,7 +82,7 @@ Ohai.plugin(:Virtualization) do
|
|
82
82
|
virtualization[:systems][:parallels] = "host"
|
83
83
|
elsif ioreg_exists?
|
84
84
|
so = shell_out("ioreg -l")
|
85
|
-
if
|
85
|
+
if /pci1ab8,4000/.match?(so.stdout)
|
86
86
|
virtualization[:system] = "parallels"
|
87
87
|
virtualization[:role] = "guest"
|
88
88
|
virtualization[:systems][:parallels] = "guest"
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -41,7 +41,7 @@ Ohai.plugin(:EC2) do
|
|
41
41
|
# @return [Boolean] do we have Amazon DMI data?
|
42
42
|
def has_ec2_amazon_dmi?
|
43
43
|
# detect a version of '4.2.amazon'
|
44
|
-
if file_val_if_exists("/sys/class/dmi/id/bios_vendor")
|
44
|
+
if /Amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_vendor"))
|
45
45
|
logger.trace("Plugin EC2: has_ec2_amazon_dmi? == true")
|
46
46
|
true
|
47
47
|
else
|
@@ -56,7 +56,7 @@ Ohai.plugin(:EC2) do
|
|
56
56
|
# @return [Boolean] do we have Amazon DMI data?
|
57
57
|
def has_ec2_xen_dmi?
|
58
58
|
# detect a version of '4.2.amazon'
|
59
|
-
if file_val_if_exists("/sys/class/dmi/id/bios_version")
|
59
|
+
if /amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_version"))
|
60
60
|
logger.trace("Plugin EC2: has_ec2_xen_dmi? == true")
|
61
61
|
true
|
62
62
|
else
|
@@ -68,7 +68,7 @@ Ohai.plugin(:EC2) do
|
|
68
68
|
# looks for a xen UUID that starts with ec2 from within the Linux sys tree
|
69
69
|
# @return [Boolean] do we have a Xen UUID or not?
|
70
70
|
def has_ec2_xen_uuid?
|
71
|
-
if file_val_if_exists("/sys/hypervisor/uuid")
|
71
|
+
if /^ec2/.match?(file_val_if_exists("/sys/hypervisor/uuid"))
|
72
72
|
logger.trace("Plugin EC2: has_ec2_xen_uuid? == true")
|
73
73
|
return true
|
74
74
|
end
|
@@ -81,10 +81,10 @@ 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
|
84
|
+
if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
85
85
|
require "wmi-lite/wmi"
|
86
86
|
wmi = WmiLite::Wmi.new
|
87
|
-
if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"]
|
87
|
+
if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
|
88
88
|
logger.trace("Plugin EC2: has_ec2_identifying_number? == true")
|
89
89
|
true
|
90
90
|
end
|
@@ -42,7 +42,7 @@ Ohai.plugin(:Eucalyptus) do
|
|
42
42
|
def has_euca_mac?
|
43
43
|
network[:interfaces].each_value do |iface|
|
44
44
|
mac = get_mac_address(iface[:addresses])
|
45
|
-
if
|
45
|
+
if /^[dD]0:0[dD]:/.match?(mac)
|
46
46
|
logger.trace("Plugin Eucalyptus: has_euca_mac? == true (#{mac})")
|
47
47
|
return true
|
48
48
|
end
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -27,7 +27,7 @@ Ohai.plugin(:GCE) do
|
|
27
27
|
# this works even if the system lacks dmidecode use by the Dmi plugin
|
28
28
|
# @return [Boolean] do we have Google Compute Engine DMI data?
|
29
29
|
def has_gce_dmi?
|
30
|
-
if file_val_if_exists("/sys/class/dmi/id/product_name")
|
30
|
+
if /Google Compute Engine/.match?(file_val_if_exists("/sys/class/dmi/id/product_name"))
|
31
31
|
logger.trace("Plugin GCE: has_gce_dmi? == true")
|
32
32
|
true
|
33
33
|
else
|
@@ -48,7 +48,7 @@ Ohai.plugin(:GCE) do
|
|
48
48
|
# looks at the Manufacturer and Model WMI values to see if they starts with Google.
|
49
49
|
# @return [Boolean] Are the manufacturer and model Google?
|
50
50
|
def has_gce_system_info?
|
51
|
-
if RUBY_PLATFORM
|
51
|
+
if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
52
52
|
require "wmi-lite/wmi"
|
53
53
|
wmi = WmiLite::Wmi.new
|
54
54
|
computer_system = wmi.first_of("Win32_ComputerSystem")
|
@@ -171,14 +171,14 @@ Ohai.plugin(:Hostname) do
|
|
171
171
|
machinename host["name"].to_s
|
172
172
|
|
173
173
|
info = Socket.gethostbyname(Socket.gethostname)
|
174
|
-
if
|
174
|
+
if /.+?\.(.*)/.match?(info.first)
|
175
175
|
fqdn info.first
|
176
176
|
else
|
177
177
|
# host is not in dns. optionally use:
|
178
178
|
# C:\WINDOWS\system32\drivers\etc\hosts
|
179
179
|
info[3..info.length].reverse_each do |addr|
|
180
180
|
hostent = Socket.gethostbyaddr(addr)
|
181
|
-
if
|
181
|
+
if /.+?\.(.*)/.match?(hostent.first)
|
182
182
|
fqdn hostent.first
|
183
183
|
break
|
184
184
|
end
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
5
5
|
# Author:: Claire McQuin (<claire@chef.io>)
|
6
6
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
7
|
-
# Copyright:: Copyright (c)
|
7
|
+
# Copyright:: Copyright (c) Chef Software, Inc.
|
8
8
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
9
9
|
# License:: Apache License, Version 2.0
|
10
10
|
#
|
@@ -137,11 +137,12 @@ Ohai.plugin(:Kernel) do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
# see if a WMI name is
|
141
|
-
# useless data to ohai
|
140
|
+
# see if a WMI name is in the blocked list so we can avoid writing
|
141
|
+
# out useless data to ohai
|
142
|
+
#
|
142
143
|
# @param [String] name the wmi name to check
|
143
|
-
# @return [Boolean] is the wmi name
|
144
|
-
def
|
144
|
+
# @return [Boolean] is the wmi name in the blocked list
|
145
|
+
def blocked_wmi_name?(name)
|
145
146
|
[
|
146
147
|
"creation_class_name", # this is just the wmi name
|
147
148
|
"cs_creation_class_name", # this is just the wmi name
|
@@ -262,7 +263,7 @@ Ohai.plugin(:Kernel) do
|
|
262
263
|
host = wmi.first_of("Win32_OperatingSystem")
|
263
264
|
kernel[:os_info] = Mash.new
|
264
265
|
host.wmi_ole_object.properties_.each do |p|
|
265
|
-
next if
|
266
|
+
next if blocked_wmi_name?(p.name.wmi_underscore)
|
266
267
|
|
267
268
|
kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
268
269
|
end
|
@@ -277,7 +278,7 @@ Ohai.plugin(:Kernel) do
|
|
277
278
|
kernel[:cs_info] = Mash.new
|
278
279
|
host = wmi.first_of("Win32_ComputerSystem")
|
279
280
|
host.wmi_ole_object.properties_.each do |p|
|
280
|
-
next if
|
281
|
+
next if blocked_wmi_name?(p.name.wmi_underscore)
|
281
282
|
|
282
283
|
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
283
284
|
end
|
@@ -65,7 +65,7 @@ Ohai.plugin(:Interrupts) do
|
|
65
65
|
interrupts[:irq][irqn][:events_by_cpu][cpu] = fields[cpu].to_i
|
66
66
|
end
|
67
67
|
# Only regular IRQs have extra fields and affinity settings
|
68
|
-
if /^\d+$/.match(irqn)
|
68
|
+
if /^\d+$/.match?(irqn)
|
69
69
|
interrupts[:irq][irqn][:type],
|
70
70
|
interrupts[:irq][irqn][:vector],
|
71
71
|
interrupts[:irq][irqn][:device] =
|
@@ -105,7 +105,7 @@ Ohai.plugin(:Mdadm) do
|
|
105
105
|
# gather detailed information on the array
|
106
106
|
so = shell_out("mdadm --detail /dev/#{device}")
|
107
107
|
|
108
|
-
# if the mdadm command was
|
108
|
+
# if the mdadm command was successful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
109
109
|
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
110
110
|
mdadm[device]["members"] = devices[device]["active"]
|
111
111
|
mdadm[device]["spares"] = devices[device]["spare"]
|
@@ -78,7 +78,7 @@ Ohai.plugin(:Network) do
|
|
78
78
|
so.stdout.lines do |line|
|
79
79
|
line.strip!
|
80
80
|
logger.trace("Plugin Network: Parsing #{line}")
|
81
|
-
if line
|
81
|
+
if /\\/.match?(line)
|
82
82
|
parts = line.split('\\')
|
83
83
|
route_dest = parts.shift.strip
|
84
84
|
route_endings = parts
|
@@ -108,6 +108,8 @@ Ohai.plugin(:Network) do
|
|
108
108
|
# http://rubular.com/r/pwTNp65VFf
|
109
109
|
route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
|
110
110
|
end
|
111
|
+
# https://rubular.com/r/k1sMrRn5yLjgVi
|
112
|
+
route_entry["via"] = $1 if route_ending =~ /\bvia\s+inet6\s+([^\s]+)/
|
111
113
|
|
112
114
|
# a sanity check, especially for Linux-VServer, OpenVZ and LXC:
|
113
115
|
# don't report the route entry if the src address isn't set on the node
|
@@ -189,11 +191,11 @@ Ohai.plugin(:Network) do
|
|
189
191
|
next if line.start_with?("Ring parameters for")
|
190
192
|
next if line.strip.nil?
|
191
193
|
|
192
|
-
if
|
194
|
+
if /Pre-set maximums/.match?(line)
|
193
195
|
type = "max"
|
194
196
|
next
|
195
197
|
end
|
196
|
-
if
|
198
|
+
if /Current hardware settings/.match?(line)
|
197
199
|
type = "current"
|
198
200
|
next
|
199
201
|
end
|
@@ -222,11 +224,11 @@ Ohai.plugin(:Network) do
|
|
222
224
|
next if line.start_with?("Channel parameters for")
|
223
225
|
next if line.strip.nil?
|
224
226
|
|
225
|
-
if
|
227
|
+
if /Pre-set maximums/.match?(line)
|
226
228
|
type = "max"
|
227
229
|
next
|
228
230
|
end
|
229
|
-
if
|
231
|
+
if /Current hardware settings/.match?(line)
|
230
232
|
type = "current"
|
231
233
|
next
|
232
234
|
end
|
@@ -306,7 +308,7 @@ Ohai.plugin(:Network) do
|
|
306
308
|
net_counters[tmp_int] ||= Mash.new
|
307
309
|
end
|
308
310
|
|
309
|
-
if
|
311
|
+
if /^\s+(ip6tnl|ipip)/.match?(line)
|
310
312
|
iface[tmp_int][:tunnel_info] = {}
|
311
313
|
words = line.split
|
312
314
|
words.each_with_index do |word, index|
|
@@ -195,7 +195,7 @@ Ohai.plugin(:Platform) do
|
|
195
195
|
elsif File.exist?("/etc/debian_version")
|
196
196
|
# Ubuntu and Debian both have /etc/debian_version
|
197
197
|
# Ubuntu should always have a working lsb, debian does not by default
|
198
|
-
if lsb[:id]
|
198
|
+
if /Ubuntu/i.match?(lsb[:id])
|
199
199
|
platform "ubuntu"
|
200
200
|
platform_version lsb[:release]
|
201
201
|
else
|
@@ -222,7 +222,7 @@ Ohai.plugin(:Platform) do
|
|
222
222
|
suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
223
223
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
224
224
|
platform_version suse_version
|
225
|
-
if
|
225
|
+
if /^openSUSE/.match?(suse_release)
|
226
226
|
# opensuse releases >= 42 are openSUSE Leap
|
227
227
|
if platform_version.to_i < 42
|
228
228
|
platform "opensuse"
|
@@ -256,23 +256,23 @@ Ohai.plugin(:Platform) do
|
|
256
256
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
257
257
|
elsif File.exist?("/usr/lib/os-release")
|
258
258
|
contents = File.read("/usr/lib/os-release")
|
259
|
-
if /clear-linux-os
|
259
|
+
if /clear-linux-os/.match?(contents) # Clear Linux https://clearlinux.org/
|
260
260
|
platform "clearlinux"
|
261
261
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
262
262
|
end
|
263
|
-
elsif lsb[:id]
|
263
|
+
elsif /RedHat/i.match?(lsb[:id])
|
264
264
|
platform "redhat"
|
265
265
|
platform_version lsb[:release]
|
266
|
-
elsif lsb[:id]
|
266
|
+
elsif /Amazon/i.match?(lsb[:id])
|
267
267
|
platform "amazon"
|
268
268
|
platform_version lsb[:release]
|
269
|
-
elsif lsb[:id]
|
269
|
+
elsif /ScientificSL/i.match?(lsb[:id])
|
270
270
|
platform "scientific"
|
271
271
|
platform_version lsb[:release]
|
272
|
-
elsif lsb[:id]
|
272
|
+
elsif /XenServer/i.match?(lsb[:id])
|
273
273
|
platform "xenserver"
|
274
274
|
platform_version lsb[:release]
|
275
|
-
elsif lsb[:id]
|
275
|
+
elsif /XCP/i.match?(lsb[:id])
|
276
276
|
platform "xcp"
|
277
277
|
platform_version lsb[:release]
|
278
278
|
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
3
|
+
# Copyright:: Copyright (c) 2020 Facebook
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
Ohai.plugin(:Selinux) do
|
20
|
+
provides "selinux/status", "selinux/policy_booleans", "selinux/process_contexts", "selinux/file_contexts"
|
21
|
+
optional true
|
22
|
+
|
23
|
+
collect_data(:linux) do
|
24
|
+
sestatus_path = which("sestatus")
|
25
|
+
if sestatus_path
|
26
|
+
sestatus = shell_out("#{sestatus_path} -v -b")
|
27
|
+
|
28
|
+
selinux Mash.new unless selinux
|
29
|
+
selinux[:status] ||= Mash.new
|
30
|
+
selinux[:policy_booleans] ||= Mash.new
|
31
|
+
selinux[:process_contexts] ||= Mash.new
|
32
|
+
selinux[:file_contexts] ||= Mash.new
|
33
|
+
section = nil
|
34
|
+
|
35
|
+
sestatus.stdout.split("\n").each do |line|
|
36
|
+
line.chomp!
|
37
|
+
|
38
|
+
case line
|
39
|
+
when "Policy booleans:"
|
40
|
+
section = :policy_booleans
|
41
|
+
next
|
42
|
+
when "Process contexts:"
|
43
|
+
section = :process_contexts
|
44
|
+
next
|
45
|
+
when "File contexts:"
|
46
|
+
section = :file_contexts
|
47
|
+
next
|
48
|
+
else
|
49
|
+
if section.nil?
|
50
|
+
section = :status
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
key, val = line.split(/:?\s\s+/, 2)
|
55
|
+
next if key.nil?
|
56
|
+
|
57
|
+
unless key.start_with?("/")
|
58
|
+
key.downcase!
|
59
|
+
key.tr!(" ", "_")
|
60
|
+
end
|
61
|
+
|
62
|
+
selinux[section][key] = val
|
63
|
+
end
|
64
|
+
else
|
65
|
+
logger.debug("Plugin Selinux: Could not find sestatus. Skipping plugin.")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -59,7 +59,7 @@ Ohai.plugin(:Virtualization) do
|
|
59
59
|
|
60
60
|
# This file should exist on most Xen systems, normally empty for guests
|
61
61
|
if File.exist?("/proc/xen/capabilities")
|
62
|
-
if File.read("/proc/xen/capabilities")
|
62
|
+
if /control_d/i.match?(File.read("/proc/xen/capabilities"))
|
63
63
|
logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
|
64
64
|
virtualization[:role] = "host"
|
65
65
|
virtualization[:systems][:xen] = "host"
|
@@ -70,12 +70,12 @@ Ohai.plugin(:Virtualization) do
|
|
70
70
|
# Detect Virtualbox from kernel module
|
71
71
|
if File.exist?("/proc/modules")
|
72
72
|
modules = File.read("/proc/modules")
|
73
|
-
if
|
73
|
+
if /^vboxdrv/.match?(modules)
|
74
74
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
|
75
75
|
virtualization[:system] = "vbox"
|
76
76
|
virtualization[:role] = "host"
|
77
77
|
virtualization[:systems][:vbox] = "host"
|
78
|
-
elsif
|
78
|
+
elsif /^vboxguest/.match?(modules)
|
79
79
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxguest. Detecting as vbox guest")
|
80
80
|
virtualization[:system] = "vbox"
|
81
81
|
virtualization[:role] = "guest"
|
@@ -93,7 +93,7 @@ Ohai.plugin(:Virtualization) do
|
|
93
93
|
|
94
94
|
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
95
95
|
if File.exist?("/proc/cpuinfo")
|
96
|
-
if
|
96
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(File.read("/proc/cpuinfo"))
|
97
97
|
logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
|
98
98
|
virtualization[:system] = "kvm"
|
99
99
|
virtualization[:role] = "guest"
|
@@ -105,7 +105,7 @@ Ohai.plugin(:Virtualization) do
|
|
105
105
|
# guests will have the hypervisor cpu feature that hosts don't have
|
106
106
|
if File.exist?("/sys/devices/virtual/misc/kvm")
|
107
107
|
virtualization[:system] = "kvm"
|
108
|
-
if File.read("/proc/cpuinfo")
|
108
|
+
if /hypervisor/.match?(File.read("/proc/cpuinfo"))
|
109
109
|
logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
|
110
110
|
virtualization[:role] = "guest"
|
111
111
|
virtualization[:systems][:kvm] = "guest"
|
@@ -190,18 +190,21 @@ Ohai.plugin(:Virtualization) do
|
|
190
190
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
191
191
|
if File.exist?("/proc/self/cgroup")
|
192
192
|
cgroup_content = File.read("/proc/self/cgroup")
|
193
|
-
|
194
|
-
|
193
|
+
# These two REs catch many different examples. Here's a specific one
|
194
|
+
# from when it is docker and there is no subsystem name.
|
195
|
+
# https://rubular.com/r/dV13hiU9KxmiWB
|
196
|
+
if cgroup_content =~ %r{^\d+:[^:]*:/(lxc|docker)/.+$} ||
|
197
|
+
cgroup_content =~ %r{^\d+:[^:]*:/[^/]+/(lxc|docker)-?.+$}
|
195
198
|
logger.trace("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
|
196
199
|
virtualization[:system] = $1
|
197
200
|
virtualization[:role] = "guest"
|
198
201
|
virtualization[:systems][$1.to_sym] = "guest"
|
199
|
-
elsif File.read("/proc/1/environ")
|
202
|
+
elsif /container=lxc/.match?(File.read("/proc/1/environ"))
|
200
203
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
|
201
204
|
virtualization[:system] = "lxc"
|
202
205
|
virtualization[:role] = "guest"
|
203
206
|
virtualization[:systems][:lxc] = "guest"
|
204
|
-
elsif File.read("/proc/1/environ")
|
207
|
+
elsif /container=systemd-nspawn/.match?(File.read("/proc/1/environ"))
|
205
208
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
|
206
209
|
virtualization[:system] = "nspawn"
|
207
210
|
virtualization[:role] = "guest"
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -54,7 +54,7 @@ Ohai.plugin(:NetworkAddresses) do
|
|
54
54
|
ipaddresses.sort_by do |v|
|
55
55
|
[ ( scope_prio.index(v[:scope]) || 999999 ),
|
56
56
|
128 - v[:ipaddress].prefix.to_i,
|
57
|
-
|
57
|
+
v[:ipaddress].to_i,
|
58
58
|
]
|
59
59
|
end
|
60
60
|
end
|
@@ -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
|
52
|
+
return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw32|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
|
51
|
+
return false unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
52
52
|
|
53
53
|
require "wmi-lite/wmi"
|
54
54
|
wmi = WmiLite::Wmi.new
|
@@ -102,7 +102,7 @@ Ohai.plugin(:Rackspace) do
|
|
102
102
|
so = shell_out("xenstore-ls vm-data/provider_data")
|
103
103
|
if so.exitstatus == 0
|
104
104
|
so.stdout.split("\n").each do |line|
|
105
|
-
rackspace[:region] = line.split[2].delete('\"') if
|
105
|
+
rackspace[:region] = line.split[2].delete('\"') if /^region/.match?(line)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
rescue Ohai::Exceptions::Exec
|
@@ -38,7 +38,7 @@ Ohai.plugin(:Virtualization) do
|
|
38
38
|
psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
|
39
39
|
if File.exist?(psrinfo_path)
|
40
40
|
so = shell_out("#{psrinfo_path} -pv")
|
41
|
-
if
|
41
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
|
42
42
|
virtualization[:system] = "kvm"
|
43
43
|
virtualization[:role] = "guest"
|
44
44
|
virtualization[:systems][:kvm] = "guest"
|
@@ -51,7 +51,7 @@ Ohai.plugin(:SSHHostKey) do
|
|
51
51
|
if sshd_config
|
52
52
|
File.open(sshd_config) do |conf|
|
53
53
|
conf.each_line do |line|
|
54
|
-
if
|
54
|
+
if /^hostkey\s/i.match?(line)
|
55
55
|
pub_file = "#{line.split[1]}.pub"
|
56
56
|
content = IO.read(pub_file).split
|
57
57
|
key_type, key_subtype = extract_keytype?(content)
|
@@ -93,8 +93,8 @@ Ohai.plugin(:Virtualbox) do
|
|
93
93
|
so_cmd = "VBoxManage list --sorted #{query_type}"
|
94
94
|
logger.trace(so_cmd)
|
95
95
|
so = shell_out(so_cmd)
|
96
|
-
|
97
|
-
|
96
|
+
# raise an exception if the command fails
|
97
|
+
# so.error!
|
98
98
|
|
99
99
|
if so.exitstatus == 0
|
100
100
|
# break the result into paragraph blocks, on successive newlines
|
data/lib/ohai/plugins/vmware.rb
CHANGED
@@ -51,7 +51,7 @@ Ohai.plugin(:VMware) do
|
|
51
51
|
# to attribute "vmware[:<parameter>]"
|
52
52
|
%w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
|
53
53
|
vmware[param] = from_cmd("#{vmtools_path} stat #{param}")
|
54
|
-
if vmware[param]
|
54
|
+
if /UpdateInfo failed/.match?(vmware[param])
|
55
55
|
vmware[param] = nil
|
56
56
|
end
|
57
57
|
end
|
@@ -171,7 +171,7 @@ Ohai.plugin(:Network) do
|
|
171
171
|
iface[cint][:addresses][ip] = Mash.new(prefixlen: ip2.prefix)
|
172
172
|
if ip2.ipv6?
|
173
173
|
iface[cint][:addresses][ip][:family] = "inet6"
|
174
|
-
iface[cint][:addresses][ip][:scope] = "Link" if
|
174
|
+
iface[cint][:addresses][ip][:scope] = "Link" if /^fe80/i.match?(ip)
|
175
175
|
else
|
176
176
|
if iface[cint][:configuration][:ip_subnet]
|
177
177
|
iface[cint][:addresses][ip][:netmask] = ip2.netmask.to_s
|
data/lib/ohai/provides_map.rb
CHANGED
@@ -136,8 +136,8 @@ module Ohai
|
|
136
136
|
private
|
137
137
|
|
138
138
|
def normalize_and_validate(attribute)
|
139
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if
|
140
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if
|
139
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if %r{//+}.match?(attribute)
|
140
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if %r{/$}.match?(attribute)
|
141
141
|
|
142
142
|
parts = attribute.split("/")
|
143
143
|
parts.shift if parts.length != 0 && parts[0].length == 0 # attribute begins with a '/'
|
data/lib/ohai/util/win32.rb
CHANGED
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency "wmi-lite", "~> 1.0"
|
26
26
|
s.add_dependency "ffi", "~> 1.9"
|
27
27
|
s.add_dependency "chef-config", ">= 12.8", "< 17"
|
28
|
+
s.add_dependency "chef-utils", ">= 16.0", "< 17"
|
28
29
|
# Note for ohai developers: If chef-config causes you grief, try:
|
29
30
|
# bundle install --with development
|
30
31
|
# this should work as long as chef is a development dependency in Gemfile.
|
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: 16.0
|
4
|
+
version: 16.3.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: 2020-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -188,6 +188,26 @@ dependencies:
|
|
188
188
|
- - "<"
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '17'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: chef-utils
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '16.0'
|
198
|
+
- - "<"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '17'
|
201
|
+
type: :runtime
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '16.0'
|
208
|
+
- - "<"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '17'
|
191
211
|
description: Ohai profiles your system and emits JSON
|
192
212
|
email: adam@chef.io
|
193
213
|
executables:
|
@@ -282,6 +302,7 @@ files:
|
|
282
302
|
- lib/ohai/plugins/linux/memory.rb
|
283
303
|
- lib/ohai/plugins/linux/network.rb
|
284
304
|
- lib/ohai/plugins/linux/platform.rb
|
305
|
+
- lib/ohai/plugins/linux/selinux.rb
|
285
306
|
- lib/ohai/plugins/linux/sessions.rb
|
286
307
|
- lib/ohai/plugins/linux/sysctl.rb
|
287
308
|
- lib/ohai/plugins/linux/systemd_paths.rb
|