ohai 15.7.4 → 16.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -5
- data/lib/ohai/common/dmi.rb +13 -5
- data/lib/ohai/config.rb +1 -1
- data/lib/ohai/mash.rb +21 -201
- data/lib/ohai/mixin/azure_metadata.rb +70 -14
- data/lib/ohai/mixin/ec2_metadata.rb +1 -1
- data/lib/ohai/mixin/gce_metadata.rb +2 -2
- data/lib/ohai/plugins/c.rb +2 -2
- data/lib/ohai/plugins/cpu.rb +1 -1
- data/lib/ohai/plugins/docker.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +1 -1
- data/lib/ohai/plugins/eucalyptus.rb +2 -2
- data/lib/ohai/plugins/filesystem.rb +9 -43
- data/lib/ohai/plugins/{linux/fips.rb → fips.rb} +1 -1
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +8 -7
- data/lib/ohai/plugins/linux/interrupts.rb +83 -0
- data/lib/ohai/plugins/linux/ipc.rb +51 -0
- data/lib/ohai/plugins/linux/network.rb +90 -0
- data/lib/ohai/plugins/linux/selinux.rb +68 -0
- data/lib/ohai/plugins/linux/virtualization.rb +2 -2
- data/lib/ohai/plugins/openstack.rb +3 -3
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +1 -1
- data/lib/ohai/plugins/shard.rb +11 -1
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/windows/dmi.rb +94 -0
- data/lib/ohai/plugins/windows/system_enclosure.rb +3 -5
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -1
- metadata +29 -6
- data/lib/ohai/plugins/windows/fips.rb +0 -38
data/lib/ohai/plugins/docker.rb
CHANGED
@@ -24,7 +24,7 @@ Ohai.plugin(:Docker) do
|
|
24
24
|
def docker_info_json
|
25
25
|
so = shell_out("docker info --format '{{json .}}'")
|
26
26
|
if so.exitstatus == 0
|
27
|
-
|
27
|
+
JSON.parse(so.stdout)
|
28
28
|
end
|
29
29
|
rescue Ohai::Exceptions::Exec
|
30
30
|
logger.trace('Plugin Docker: Could not shell_out "docker info --format \'{{json .}}\'". Skipping plugin')
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -86,7 +86,7 @@ Ohai.plugin(:EC2) do
|
|
86
86
|
wmi = WmiLite::Wmi.new
|
87
87
|
if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"] =~ /^ec2/
|
88
88
|
logger.trace("Plugin EC2: has_ec2_identifying_number? == true")
|
89
|
-
|
89
|
+
true
|
90
90
|
end
|
91
91
|
else
|
92
92
|
logger.trace("Plugin EC2: has_ec2_identifying_number? == false")
|
@@ -32,9 +32,9 @@ Ohai.plugin(:Eucalyptus) do
|
|
32
32
|
def get_mac_address(addresses)
|
33
33
|
detected_addresses = addresses.detect { |address, keypair| keypair == { "family" => "lladdr" } }
|
34
34
|
if detected_addresses
|
35
|
-
|
35
|
+
detected_addresses.first
|
36
36
|
else
|
37
|
-
|
37
|
+
""
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
7
7
|
# Author:: Isa Farnik (<isa@chef.io>)
|
8
8
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
9
|
-
# Copyright:: Copyright (c) 2008-
|
9
|
+
# Copyright:: Copyright (c) 2008-2020 Chef Software, Inc.
|
10
10
|
# Copyright:: Copyright (c) 2015 Facebook, Inc.
|
11
11
|
# License:: Apache License, Version 2.0
|
12
12
|
#
|
@@ -23,6 +23,8 @@
|
|
23
23
|
# limitations under the License.
|
24
24
|
#
|
25
25
|
|
26
|
+
require "set"
|
27
|
+
|
26
28
|
Ohai.plugin(:Filesystem) do
|
27
29
|
provides "filesystem"
|
28
30
|
|
@@ -98,15 +100,6 @@ Ohai.plugin(:Filesystem) do
|
|
98
100
|
view
|
99
101
|
end
|
100
102
|
|
101
|
-
def generate_deprecated_view(fs)
|
102
|
-
view = generate_device_view(fs)
|
103
|
-
view.each do |device, entry|
|
104
|
-
view[device][:mount] = entry[:mounts].first
|
105
|
-
view[device].delete(:mounts)
|
106
|
-
end
|
107
|
-
view
|
108
|
-
end
|
109
|
-
|
110
103
|
def generate_deprecated_windows_view(fs)
|
111
104
|
view = generate_mountpoint_view(fs)
|
112
105
|
view.each do |mp, entry|
|
@@ -115,22 +108,6 @@ Ohai.plugin(:Filesystem) do
|
|
115
108
|
view
|
116
109
|
end
|
117
110
|
|
118
|
-
def generate_deprecated_solaris_view(fs, old_zfs)
|
119
|
-
view = generate_deprecated_view(fs)
|
120
|
-
old_zfs.each do |fsname, attributes|
|
121
|
-
view[fsname] ||= Mash.new
|
122
|
-
view[fsname][:fs_type] = "zfs"
|
123
|
-
view[fsname][:mount] = attributes[:values][:mountpoint] if attributes[:values].key?("mountpoint")
|
124
|
-
view[fsname][:device] = fsname
|
125
|
-
view[fsname][:zfs_values] = attributes[:values]
|
126
|
-
view[fsname][:zfs_sources] = attributes[:sources]
|
127
|
-
# parents will already be here
|
128
|
-
# but we want to nuke "zfs_properties"
|
129
|
-
view[fsname].delete("zfs_properties")
|
130
|
-
end
|
131
|
-
view
|
132
|
-
end
|
133
|
-
|
134
111
|
def parse_common_df(out)
|
135
112
|
fs = {}
|
136
113
|
out.each_line do |line|
|
@@ -496,9 +473,8 @@ Ohai.plugin(:Filesystem) do
|
|
496
473
|
fs_data["by_mountpoint"] = by_mountpoint
|
497
474
|
fs_data["by_pair"] = by_pair
|
498
475
|
|
499
|
-
#
|
500
|
-
|
501
|
-
filesystem generate_deprecated_view(fs)
|
476
|
+
# @todo in Chef 17 the filesystem2 part of this goes away
|
477
|
+
filesystem fs_data
|
502
478
|
filesystem2 fs_data
|
503
479
|
end
|
504
480
|
|
@@ -595,7 +571,6 @@ Ohai.plugin(:Filesystem) do
|
|
595
571
|
|
596
572
|
# Grab any zfs data from "zfs get"
|
597
573
|
zfs = Mash.new
|
598
|
-
old_zfs = Mash.new
|
599
574
|
zfs_get = "zfs get -p -H all"
|
600
575
|
run_with_check("zfs") do
|
601
576
|
so = shell_out(zfs_get)
|
@@ -612,13 +587,6 @@ Ohai.plugin(:Filesystem) do
|
|
612
587
|
value: value,
|
613
588
|
source: source,
|
614
589
|
}
|
615
|
-
# needed for old v1 view
|
616
|
-
old_zfs[filesystem] ||= Mash.new
|
617
|
-
old_zfs[filesystem][:values] ||= Mash.new
|
618
|
-
old_zfs[filesystem][:sources] ||= Mash.new
|
619
|
-
old_zfs[filesystem][:values][property] = value
|
620
|
-
old_zfs[filesystem][:values][property] = value
|
621
|
-
old_zfs[filesystem][:sources][property] = source
|
622
590
|
end
|
623
591
|
end
|
624
592
|
|
@@ -652,9 +620,8 @@ Ohai.plugin(:Filesystem) do
|
|
652
620
|
fs_data["by_mountpoint"] = by_mountpoint
|
653
621
|
fs_data["by_pair"] = by_pair
|
654
622
|
|
655
|
-
#
|
656
|
-
|
657
|
-
filesystem generate_deprecated_solaris_view(fs, old_zfs)
|
623
|
+
# @todo in Chef 17 the filesystem2 plugin goes away
|
624
|
+
filesystem fs_data
|
658
625
|
filesystem2 fs_data
|
659
626
|
end
|
660
627
|
|
@@ -745,9 +712,8 @@ Ohai.plugin(:Filesystem) do
|
|
745
712
|
fs_data["by_mountpoint"] = by_mountpoint
|
746
713
|
fs_data["by_pair"] = by_pair
|
747
714
|
|
748
|
-
#
|
749
|
-
|
750
|
-
filesystem generate_deprecated_view(fs)
|
715
|
+
# @todo in Chef 17 the filesystem2 plugin goes away here
|
716
|
+
filesystem fs_data
|
751
717
|
filesystem2 fs_data
|
752
718
|
end
|
753
719
|
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -54,7 +54,7 @@ Ohai.plugin(:GCE) do
|
|
54
54
|
computer_system = wmi.first_of("Win32_ComputerSystem")
|
55
55
|
if computer_system["Manufacturer"] =~ /^Google/ && computer_system["Model"] =~ /^Google/
|
56
56
|
logger.trace("Plugin GCE: has_gce_system_info? == true")
|
57
|
-
|
57
|
+
true
|
58
58
|
end
|
59
59
|
else
|
60
60
|
logger.trace("Plugin GCE: has_gce_system_info? == false")
|
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
|
@@ -0,0 +1,83 @@
|
|
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(:Interrupts) do
|
20
|
+
depends "cpu"
|
21
|
+
provides "interrupts", "interrupts/irq", "interrupts/smp_affinity_by_cpu"
|
22
|
+
optional true
|
23
|
+
|
24
|
+
# Documentation: https://www.kernel.org/doc/Documentation/IRQ-affinity.txt
|
25
|
+
# format: comma-separate list of 32bit bitmask in hex
|
26
|
+
# each bit is a CPU, right to left ordering (i.e. CPU0 is rightmost)
|
27
|
+
def parse_smp_affinity(path, cpus)
|
28
|
+
masks = File.read(path).strip
|
29
|
+
bit_masks = []
|
30
|
+
masks.split(",").each do |mask|
|
31
|
+
bit_masks << mask.rjust(8, "0").to_i(16).to_s(2)
|
32
|
+
end
|
33
|
+
affinity_mask = bit_masks.join
|
34
|
+
affinity_by_cpu = affinity_mask.split("").reverse
|
35
|
+
smp_affinity_by_cpu = Mash.new
|
36
|
+
(0..cpus - 1).each do |cpu|
|
37
|
+
smp_affinity_by_cpu[cpu] = affinity_by_cpu[cpu].to_i == 1
|
38
|
+
end
|
39
|
+
smp_affinity_by_cpu
|
40
|
+
end
|
41
|
+
|
42
|
+
collect_data(:linux) do
|
43
|
+
interrupts Mash.new
|
44
|
+
|
45
|
+
cpus = cpu["total"]
|
46
|
+
interrupts[:smp_affinity_by_cpu] =
|
47
|
+
parse_smp_affinity("/proc/irq/default_smp_affinity", cpus)
|
48
|
+
|
49
|
+
interrupts[:irq] = Mash.new
|
50
|
+
File.open("/proc/interrupts").each do |line|
|
51
|
+
# Documentation: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
52
|
+
# format is "{irqn}: {CPUn...} [type] [vector] [device]"
|
53
|
+
irqn, fields = line.split(":", 2)
|
54
|
+
# skip the header
|
55
|
+
next if fields.nil?
|
56
|
+
|
57
|
+
irqn.strip!
|
58
|
+
Ohai::Log.debug("irq: processing #{irqn}")
|
59
|
+
|
60
|
+
interrupts[:irq][irqn] = Mash.new
|
61
|
+
interrupts[:irq][irqn][:events_by_cpu] = Mash.new
|
62
|
+
|
63
|
+
fields = fields.split(nil, cpus + 1)
|
64
|
+
(0..cpus - 1).each do |cpu|
|
65
|
+
interrupts[:irq][irqn][:events_by_cpu][cpu] = fields[cpu].to_i
|
66
|
+
end
|
67
|
+
# Only regular IRQs have extra fields and affinity settings
|
68
|
+
if /^\d+$/.match(irqn)
|
69
|
+
interrupts[:irq][irqn][:type],
|
70
|
+
interrupts[:irq][irqn][:vector],
|
71
|
+
interrupts[:irq][irqn][:device] =
|
72
|
+
fields[cpus].split
|
73
|
+
if File.exist?("/proc/irq/#{irqn}/smp_affinity")
|
74
|
+
interrupts[:irq][irqn][:smp_affinity_by_cpu] =
|
75
|
+
parse_smp_affinity("/proc/irq/#{irqn}/smp_affinity", cpus)
|
76
|
+
end
|
77
|
+
# ERR and MIS do not have any extra fields
|
78
|
+
elsif fields[cpus]
|
79
|
+
interrupts[:irq][irqn][:type] = fields[cpus].strip
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Jay Vana <jsvana@fb.com>
|
3
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
4
|
+
# Copyright:: Copyright (c) 2016-2020 Facebook, Inc.
|
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(:IPC) do
|
21
|
+
provides "ipc"
|
22
|
+
optional true
|
23
|
+
|
24
|
+
collect_data(:linux) do
|
25
|
+
ipcs_path = which("ipcs")
|
26
|
+
if ipcs_path
|
27
|
+
# NOTE: currently only supports shared memory
|
28
|
+
cmd = "#{ipcs_path} -m"
|
29
|
+
ipcs = shell_out(cmd)
|
30
|
+
|
31
|
+
ipc Mash.new unless ipc
|
32
|
+
ipc["shm"] = Mash.new unless ipc["shm"]
|
33
|
+
|
34
|
+
ipcs.stdout.split("\n").each do |line|
|
35
|
+
next unless line.start_with?("0x")
|
36
|
+
|
37
|
+
parts = line.split
|
38
|
+
segment = {
|
39
|
+
"key" => parts[0],
|
40
|
+
"owner" => parts[2],
|
41
|
+
"perms" => parts[3],
|
42
|
+
"bytes" => parts[4].to_i,
|
43
|
+
"nattch" => parts[5].to_i,
|
44
|
+
"status" => parts[6] ? parts[6] : "",
|
45
|
+
}
|
46
|
+
|
47
|
+
ipc["shm"][parts[1].to_i] = segment
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -207,6 +207,93 @@ Ohai.plugin(:Network) do
|
|
207
207
|
iface
|
208
208
|
end
|
209
209
|
|
210
|
+
# determine channel parameters for the interface using ethtool
|
211
|
+
def ethernet_channel_parameters(iface)
|
212
|
+
return iface unless ethtool_binary_path
|
213
|
+
|
214
|
+
iface.each_key do |tmp_int|
|
215
|
+
next unless iface[tmp_int][:encapsulation] == "Ethernet"
|
216
|
+
|
217
|
+
so = shell_out("#{ethtool_binary_path} -l #{tmp_int}")
|
218
|
+
logger.trace("Plugin Network: Parsing ethtool output: #{so.stdout}")
|
219
|
+
type = nil
|
220
|
+
iface[tmp_int]["channel_params"] = {}
|
221
|
+
so.stdout.lines.each do |line|
|
222
|
+
next if line.start_with?("Channel parameters for")
|
223
|
+
next if line.strip.nil?
|
224
|
+
|
225
|
+
if line =~ /Pre-set maximums/
|
226
|
+
type = "max"
|
227
|
+
next
|
228
|
+
end
|
229
|
+
if line =~ /Current hardware settings/
|
230
|
+
type = "current"
|
231
|
+
next
|
232
|
+
end
|
233
|
+
key, val = line.split(/:\s+/)
|
234
|
+
if type && val
|
235
|
+
channel_key = "#{type}_#{key.downcase.tr(" ", "_")}"
|
236
|
+
iface[tmp_int]["channel_params"][channel_key] = val.to_i
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
iface
|
241
|
+
end
|
242
|
+
|
243
|
+
# determine coalesce parameters for the interface using ethtool
|
244
|
+
def ethernet_coalesce_parameters(iface)
|
245
|
+
return iface unless ethtool_binary_path
|
246
|
+
|
247
|
+
iface.each_key do |tmp_int|
|
248
|
+
next unless iface[tmp_int][:encapsulation] == "Ethernet"
|
249
|
+
|
250
|
+
so = shell_out("#{ethtool_binary_path} -c #{tmp_int}")
|
251
|
+
logger.trace("Plugin Network: Parsing ethtool output: #{so.stdout}")
|
252
|
+
iface[tmp_int]["coalesce_params"] = {}
|
253
|
+
so.stdout.lines.each do |line|
|
254
|
+
next if line.start_with?("Coalesce parameters for")
|
255
|
+
next if line.strip.nil?
|
256
|
+
|
257
|
+
if line.start_with?("Adaptive")
|
258
|
+
_, adaptive_rx, _, adaptive_tx = line.split(/:\s+|\s+TX|\n/)
|
259
|
+
iface[tmp_int]["coalesce_params"]["adaptive_rx"] = adaptive_rx
|
260
|
+
iface[tmp_int]["coalesce_params"]["adaptive_tx"] = adaptive_tx
|
261
|
+
next
|
262
|
+
end
|
263
|
+
key, val = line.split(/:\s+/)
|
264
|
+
if val
|
265
|
+
coalesce_key = "#{key.downcase.tr(" ", "_")}"
|
266
|
+
iface[tmp_int]["coalesce_params"][coalesce_key] = val.to_i
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
iface
|
271
|
+
end
|
272
|
+
|
273
|
+
# determine driver info for the interface using ethtool
|
274
|
+
def ethernet_driver_info(iface)
|
275
|
+
return iface unless ethtool_binary_path
|
276
|
+
|
277
|
+
iface.each_key do |tmp_int|
|
278
|
+
next unless iface[tmp_int][:encapsulation] == "Ethernet"
|
279
|
+
|
280
|
+
so = shell_out("#{ethtool_binary_path} -i #{tmp_int}")
|
281
|
+
logger.trace("Plugin Network: Parsing ethtool output: #{so.stdout}")
|
282
|
+
iface[tmp_int]["driver_info"] = {}
|
283
|
+
so.stdout.lines.each do |line|
|
284
|
+
next if line.strip.nil?
|
285
|
+
|
286
|
+
key, val = line.split(/:\s+/)
|
287
|
+
if val.nil?
|
288
|
+
val = ""
|
289
|
+
end
|
290
|
+
driver_key = "#{key.downcase.tr(" ", "_")}"
|
291
|
+
iface[tmp_int]["driver_info"][driver_key] = val.chomp
|
292
|
+
end
|
293
|
+
end
|
294
|
+
iface
|
295
|
+
end
|
296
|
+
|
210
297
|
# determine link stats, vlans, queue length, and state for an interface using ip
|
211
298
|
def link_statistics(iface, net_counters)
|
212
299
|
so = shell_out("ip -d -s link")
|
@@ -669,6 +756,9 @@ Ohai.plugin(:Network) do
|
|
669
756
|
|
670
757
|
iface = ethernet_layer_one(iface)
|
671
758
|
iface = ethernet_ring_parameters(iface)
|
759
|
+
iface = ethernet_channel_parameters(iface)
|
760
|
+
iface = ethernet_coalesce_parameters(iface)
|
761
|
+
iface = ethernet_driver_info(iface)
|
672
762
|
counters[:network][:interfaces] = net_counters
|
673
763
|
network["interfaces"] = iface
|
674
764
|
end
|
@@ -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
|