ohai 8.25.1 → 8.26.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 +5 -5
- data/lib/ohai/plugins/ec2.rb +61 -32
- data/lib/ohai/plugins/linux/lspci.rb +76 -0
- data/lib/ohai/plugins/linux/mdadm.rb +31 -4
- data/lib/ohai/plugins/linux/network.rb +25 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +63 -11
- data/spec/unit/plugins/linux/lspci_spec.rb +133 -0
- data/spec/unit/plugins/linux/mdadm_spec.rb +23 -2
- data/spec/unit/plugins/linux/network_spec.rb +36 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cd104199be412d5cd0393ceba805110d171918f2905e8243cb9d7b34e2e5c841
|
|
4
|
+
data.tar.gz: e2d4ede2e672df83e36fb16cfb44e84724c42aa7b19dec4cf8c97a2bf8406ef1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c4bf1435c0f135060dddfafc0d55106ba6bf40f627f4da9fcd45b1ca64ef5864194754211b235b03348b1f7aa3093579c9e1565c0fbe5e40f3d4270d9d839ee
|
|
7
|
+
data.tar.gz: 2651bbb8601e41097a0f64c6f5da5653e3b4291796cee530849659a5127ed966295879498d5b7c14455c757e5dbfb2b3abd23752632f39a27f1a7f2cdad40ac4
|
data/lib/ohai/plugins/ec2.rb
CHANGED
|
@@ -21,65 +21,94 @@
|
|
|
21
21
|
# How we detect EC2 from easiest to hardest & least reliable
|
|
22
22
|
# 1. Ohai ec2 hint exists. This always works
|
|
23
23
|
# 2. Xen hypervisor UUID starts with 'ec2'. This catches Linux HVM & paravirt instances
|
|
24
|
-
# 3. DMI data mentions amazon. This catches HVM instances in a VPC
|
|
24
|
+
# 3. DMI bios version data mentions amazon. This catches HVM instances in a VPC on the Xen based hypervisor
|
|
25
|
+
# 3. DMI bios vendor data mentions amazon. This catches HVM instances in a VPC on the non-Xen based hypervisor
|
|
25
26
|
# 4. Kernel data mentioned Amazon. This catches Windows HVM & paravirt instances
|
|
26
27
|
|
|
27
|
-
require "ohai/mixin/ec2_metadata"
|
|
28
|
-
require "base64"
|
|
29
|
-
|
|
30
28
|
Ohai.plugin(:EC2) do
|
|
29
|
+
require "ohai/mixin/ec2_metadata"
|
|
30
|
+
require "base64"
|
|
31
|
+
|
|
31
32
|
include Ohai::Mixin::Ec2Metadata
|
|
32
33
|
|
|
33
34
|
provides "ec2"
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
# look for amazon string in dmi vendor bios data within the sys tree.
|
|
37
|
+
# this works even if the system lacks dmidecode use by the Dmi plugin
|
|
38
|
+
# this gets us detection of new Xen-less HVM instances that are within a VPC
|
|
39
|
+
# @return [Boolean] do we have Amazon DMI data?
|
|
40
|
+
def has_ec2_amazon_dmi?
|
|
41
|
+
# detect a version of '4.2.amazon'
|
|
42
|
+
if file_val_if_exists("/sys/class/dmi/id/bios_vendor") =~ /Amazon/
|
|
43
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_amazon_dmi? == true")
|
|
44
|
+
true
|
|
45
|
+
else
|
|
46
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_amazon_dmi? == false")
|
|
47
|
+
false
|
|
48
|
+
end
|
|
49
|
+
end
|
|
37
50
|
|
|
38
|
-
# look for amazon string in dmi bios data
|
|
51
|
+
# look for amazon string in dmi bios version data within the sys tree.
|
|
52
|
+
# this works even if the system lacks dmidecode use by the Dmi plugin
|
|
39
53
|
# this gets us detection of HVM instances that are within a VPC
|
|
40
|
-
|
|
54
|
+
# @return [Boolean] do we have Amazon DMI data?
|
|
55
|
+
def has_ec2_xen_dmi?
|
|
41
56
|
# detect a version of '4.2.amazon'
|
|
42
|
-
if
|
|
43
|
-
Ohai::Log.debug("Plugin EC2:
|
|
44
|
-
|
|
57
|
+
if file_val_if_exists("/sys/class/dmi/id/bios_version") =~ /amazon/
|
|
58
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_xen_dmi? == true")
|
|
59
|
+
true
|
|
45
60
|
else
|
|
46
|
-
Ohai::Log.debug("Plugin EC2:
|
|
47
|
-
|
|
61
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_xen_dmi? == false")
|
|
62
|
+
false
|
|
48
63
|
end
|
|
49
64
|
end
|
|
50
65
|
|
|
51
|
-
# looks for a xen UUID that starts with ec2
|
|
52
|
-
#
|
|
66
|
+
# looks for a xen UUID that starts with ec2 from within the Linux sys tree
|
|
67
|
+
# @return [Boolean] do we have a Xen UUID or not?
|
|
53
68
|
def has_ec2_xen_uuid?
|
|
54
|
-
if
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return true
|
|
58
|
-
end
|
|
69
|
+
if file_val_if_exists("/sys/hypervisor/uuid") =~ /^ec2/
|
|
70
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_xen_uuid? == true")
|
|
71
|
+
return true
|
|
59
72
|
end
|
|
60
73
|
Ohai::Log.debug("Plugin EC2: has_ec2_xen_uuid? == false")
|
|
61
|
-
|
|
74
|
+
false
|
|
62
75
|
end
|
|
63
76
|
|
|
64
|
-
# looks
|
|
65
|
-
# this
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
# looks at the identifying number WMI value to see if it starts with ec2.
|
|
78
|
+
# this is actually the same value we're looking at in has_ec2_xen_uuid? on
|
|
79
|
+
# linux hosts
|
|
80
|
+
# @return [Boolean] do we have a Xen Identifying Number or not?
|
|
81
|
+
def has_ec2_identifying_number?
|
|
82
|
+
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
|
83
|
+
require "wmi-lite/wmi"
|
|
84
|
+
wmi = WmiLite::Wmi.new
|
|
85
|
+
if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"] =~ /^ec2/
|
|
86
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_identifying_number? == true")
|
|
87
|
+
return true
|
|
88
|
+
end
|
|
71
89
|
else
|
|
72
|
-
Ohai::Log.debug("Plugin EC2:
|
|
73
|
-
|
|
90
|
+
Ohai::Log.debug("Plugin EC2: has_ec2_identifying_number? == false")
|
|
91
|
+
false
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# return the contents of a file if the file exists
|
|
96
|
+
# @param path[String] abs path to the file
|
|
97
|
+
# @return [String] contents of the file if it exists
|
|
98
|
+
def file_val_if_exists(path)
|
|
99
|
+
if ::File.exist?(path)
|
|
100
|
+
::File.read(path)
|
|
74
101
|
end
|
|
75
102
|
end
|
|
76
103
|
|
|
104
|
+
# a single check that combines all the various detection methods for EC2
|
|
105
|
+
# @return [Boolean] Does the system appear to be on EC2
|
|
77
106
|
def looks_like_ec2?
|
|
78
107
|
return true if hint?("ec2")
|
|
79
108
|
|
|
80
109
|
# Even if it looks like EC2 try to connect first
|
|
81
|
-
if has_ec2_xen_uuid? ||
|
|
82
|
-
return true if
|
|
110
|
+
if has_ec2_xen_uuid? || has_ec2_amazon_dmi? || has_ec2_xen_dmi? || has_ec2_identifying_number?
|
|
111
|
+
return true if can_socket_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
|
|
83
112
|
end
|
|
84
113
|
end
|
|
85
114
|
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Joerg Herzinger <joerg.herzinger@oiml.at>
|
|
3
|
+
# Author:: Phil Dibowitz <phil@ipom.com>
|
|
4
|
+
# Copyright:: Copyright (c) 2011 GLOBAL 2000/Friends of the Earth Austria
|
|
5
|
+
# Copyright:: Copyright (c) 2017 Facebook, Inc.
|
|
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
|
+
Ohai.plugin(:Lspci) do
|
|
21
|
+
depends "platform"
|
|
22
|
+
provides "pci"
|
|
23
|
+
|
|
24
|
+
collect_data(:linux) do
|
|
25
|
+
devices = Mash.new
|
|
26
|
+
lspci = shell_out("lspci -vnnmk")
|
|
27
|
+
|
|
28
|
+
h = /[0-9a-fA-F]/ #any hex digit
|
|
29
|
+
hh = /#{h}#{h}/ #any 2 hex digits
|
|
30
|
+
hhhh = /#{h}#{h}#{h}#{h}/ #any 4 hex digits
|
|
31
|
+
|
|
32
|
+
d_id = String.new #This identifies our pci devices
|
|
33
|
+
|
|
34
|
+
def standard_form(devices, d_id, hhhh, tag, line)
|
|
35
|
+
tmp = line.scan(/(.*)\s\[(#{hhhh})\]/)[0]
|
|
36
|
+
devices[d_id]["#{tag}_name"] = tmp[0]
|
|
37
|
+
devices[d_id]["#{tag}_id"] = tmp[1]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def standard_array(devices, d_id, tag, line)
|
|
41
|
+
if !devices[d_id][tag].kind_of?(Array)
|
|
42
|
+
devices[d_id][tag] = [line]
|
|
43
|
+
else
|
|
44
|
+
devices[d_id][tag].push(line)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
lspci.stdout.split("\n").each do |line|
|
|
49
|
+
dev = line.scan(/^(.*):\s(.*)$/)[0]
|
|
50
|
+
next if dev.nil?
|
|
51
|
+
case dev[0]
|
|
52
|
+
when "Device" # There are two different Device tags
|
|
53
|
+
if tmp = dev[1].match(/(#{hh}:#{hh}.#{h})/)
|
|
54
|
+
# We have a device id
|
|
55
|
+
d_id = tmp[0] # From now on we will need this id
|
|
56
|
+
devices[d_id] = Mash.new
|
|
57
|
+
else
|
|
58
|
+
standard_form(devices, d_id, hhhh, "device", dev[1])
|
|
59
|
+
end
|
|
60
|
+
when "Class"
|
|
61
|
+
standard_form(devices, d_id, hhhh, "class", dev[1])
|
|
62
|
+
when "Vendor"
|
|
63
|
+
standard_form(devices, d_id, hhhh, "vendor", dev[1])
|
|
64
|
+
when "Driver"
|
|
65
|
+
standard_array(devices, d_id, "driver", dev[1])
|
|
66
|
+
when "Module"
|
|
67
|
+
standard_array(devices, d_id, "module", dev[1])
|
|
68
|
+
when "SDevice"
|
|
69
|
+
standard_form(devices, d_id, hhhh, "sdevice", dev[1])
|
|
70
|
+
else
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
pci devices
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -64,10 +64,35 @@ Ohai.plugin(:Mdadm) do
|
|
|
64
64
|
# unless the array is inactive, in which case you don't get a raid
|
|
65
65
|
# level.
|
|
66
66
|
members = pieces.drop_while { |x| !x.start_with?("raid", "inactive") }
|
|
67
|
-
# drop
|
|
68
|
-
|
|
67
|
+
# and drop that too
|
|
69
68
|
members.shift unless members.empty?
|
|
70
|
-
devices[device] =
|
|
69
|
+
devices[device] = {
|
|
70
|
+
"active" => [],
|
|
71
|
+
"spare" => [],
|
|
72
|
+
"journal" => nil,
|
|
73
|
+
}
|
|
74
|
+
members.each do |member|
|
|
75
|
+
# We want to match the device, and optionally the type
|
|
76
|
+
# most entries will look like:
|
|
77
|
+
# sdc1[5]
|
|
78
|
+
# but some will look like:
|
|
79
|
+
# sdc1[5](J)
|
|
80
|
+
# where the format is:
|
|
81
|
+
# <device>[<number in array>](<type>)
|
|
82
|
+
# Type can be things like "J" for a journal device, or "S" for
|
|
83
|
+
# a spare device.
|
|
84
|
+
m = member.match(/(.+)\[\d+\](?:\((\w)\))?/)
|
|
85
|
+
member_device = m[1]
|
|
86
|
+
member_type = m[2]
|
|
87
|
+
case member_type
|
|
88
|
+
when "J"
|
|
89
|
+
devices[device]["journal"] = member_device
|
|
90
|
+
when "S"
|
|
91
|
+
devices[device]["spare"] << member_device
|
|
92
|
+
else
|
|
93
|
+
devices[device]["active"] << member_device
|
|
94
|
+
end
|
|
95
|
+
end
|
|
71
96
|
end
|
|
72
97
|
end
|
|
73
98
|
|
|
@@ -82,7 +107,9 @@ Ohai.plugin(:Mdadm) do
|
|
|
82
107
|
|
|
83
108
|
# if the mdadm command was sucessful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
|
84
109
|
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
|
85
|
-
mdadm[device]["members"] = devices[device]
|
|
110
|
+
mdadm[device]["members"] = devices[device]["active"]
|
|
111
|
+
mdadm[device]["spares"] = devices[device]["spare"]
|
|
112
|
+
mdadm[device]["journal"] = devices[device]["journal"]
|
|
86
113
|
end
|
|
87
114
|
end
|
|
88
115
|
end
|
|
@@ -215,6 +215,31 @@ Ohai.plugin(:Network) do
|
|
|
215
215
|
net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
|
|
216
216
|
end
|
|
217
217
|
|
|
218
|
+
if line =~ /^\s+(ip6tnl|ipip)/
|
|
219
|
+
iface[tmp_int][:tunnel_info] = {}
|
|
220
|
+
words = line.split
|
|
221
|
+
words.each_with_index do |word, index|
|
|
222
|
+
case word
|
|
223
|
+
when "external"
|
|
224
|
+
iface[tmp_int][:tunnel_info][word] = true
|
|
225
|
+
when "any", "ipip6", "ip6ip6"
|
|
226
|
+
iface[tmp_int][:tunnel_info][:proto] = word
|
|
227
|
+
when "remote",
|
|
228
|
+
"local",
|
|
229
|
+
"encaplimit",
|
|
230
|
+
"hoplimit",
|
|
231
|
+
"tclass",
|
|
232
|
+
"flowlabel",
|
|
233
|
+
"addrgenmode",
|
|
234
|
+
"numtxqueues",
|
|
235
|
+
"numrxqueues",
|
|
236
|
+
"gso_max_size",
|
|
237
|
+
"gso_max_segs"
|
|
238
|
+
iface[tmp_int][:tunnel_info][word] = words[index + 1]
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
218
243
|
if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
|
219
244
|
int = on_rx ? :rx : :tx
|
|
220
245
|
net_counters[tmp_int][int] = Mash.new unless net_counters[tmp_int][int]
|
data/lib/ohai/version.rb
CHANGED
|
@@ -17,20 +17,22 @@
|
|
|
17
17
|
# limitations under the License.
|
|
18
18
|
#
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
require_relative "../../spec_helper.rb"
|
|
21
21
|
require "open-uri"
|
|
22
22
|
require "base64"
|
|
23
23
|
|
|
24
24
|
describe Ohai::System, "plugin ec2" do
|
|
25
25
|
|
|
26
|
+
let(:plugin) { get_plugin("ec2") }
|
|
27
|
+
|
|
26
28
|
before(:each) do
|
|
27
29
|
allow(plugin).to receive(:hint?).with("ec2").and_return(false)
|
|
28
30
|
allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(false)
|
|
31
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(false)
|
|
32
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_version").and_return(false)
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
shared_examples_for "!ec2" do
|
|
32
|
-
let(:plugin) { get_plugin("ec2") }
|
|
33
|
-
|
|
34
36
|
it "DOESN'T attempt to fetch the ec2 metadata or set ec2 attribute" do
|
|
35
37
|
expect(plugin).not_to receive(:http_client)
|
|
36
38
|
expect(plugin[:ec2]).to be_nil
|
|
@@ -39,8 +41,6 @@ describe Ohai::System, "plugin ec2" do
|
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
shared_examples_for "ec2" do
|
|
42
|
-
let(:plugin) { get_plugin("ec2") }
|
|
43
|
-
|
|
44
44
|
before(:each) do
|
|
45
45
|
@http_client = double("Net::HTTP client")
|
|
46
46
|
allow(plugin).to receive(:http_client).and_return(@http_client)
|
|
@@ -334,19 +334,39 @@ describe Ohai::System, "plugin ec2" do
|
|
|
334
334
|
end
|
|
335
335
|
end # shared examples for ec2
|
|
336
336
|
|
|
337
|
-
describe "with
|
|
337
|
+
describe "with amazon dmi bios version data" do
|
|
338
338
|
it_behaves_like "ec2"
|
|
339
339
|
|
|
340
340
|
before(:each) do
|
|
341
|
-
|
|
341
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_version").and_return(true)
|
|
342
|
+
allow(File).to receive(:read).with("/sys/class/dmi/id/bios_version").and_return("4.2.amazon\n")
|
|
342
343
|
end
|
|
343
344
|
end
|
|
344
345
|
|
|
345
|
-
describe "with amazon
|
|
346
|
+
describe "with non-amazon dmi bios version data" do
|
|
347
|
+
it_behaves_like "!ec2"
|
|
348
|
+
|
|
349
|
+
before(:each) do
|
|
350
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_version").and_return(true)
|
|
351
|
+
allow(File).to receive(:read).with("/sys/class/dmi/id/bios_version").and_return("1.0\n")
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
describe "with amazon dmi bios vendor data" do
|
|
346
356
|
it_behaves_like "ec2"
|
|
347
357
|
|
|
348
358
|
before(:each) do
|
|
349
|
-
|
|
359
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(true)
|
|
360
|
+
allow(File).to receive(:read).with("/sys/class/dmi/id/bios_vendor").and_return("Amazon EC2\n")
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
describe "with non-amazon dmi bios vendor data" do
|
|
365
|
+
it_behaves_like "!ec2"
|
|
366
|
+
|
|
367
|
+
before(:each) do
|
|
368
|
+
allow(File).to receive(:exist?).with("/sys/class/dmi/id/bios_vendor").and_return(true)
|
|
369
|
+
allow(File).to receive(:read).with("/sys/class/dmi/id/bios_vendor").and_return("Xen\n")
|
|
350
370
|
end
|
|
351
371
|
end
|
|
352
372
|
|
|
@@ -355,7 +375,7 @@ describe Ohai::System, "plugin ec2" do
|
|
|
355
375
|
|
|
356
376
|
before(:each) do
|
|
357
377
|
allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true)
|
|
358
|
-
allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("ec2a0561-e4d6-8e15-d9c8-2e0e03adcde8")
|
|
378
|
+
allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("ec2a0561-e4d6-8e15-d9c8-2e0e03adcde8\n")
|
|
359
379
|
end
|
|
360
380
|
end
|
|
361
381
|
|
|
@@ -364,7 +384,39 @@ describe Ohai::System, "plugin ec2" do
|
|
|
364
384
|
|
|
365
385
|
before(:each) do
|
|
366
386
|
allow(File).to receive(:exist?).with("/sys/hypervisor/uuid").and_return(true)
|
|
367
|
-
allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("123a0561-e4d6-8e15-d9c8-2e0e03adcde8")
|
|
387
|
+
allow(File).to receive(:read).with("/sys/hypervisor/uuid").and_return("123a0561-e4d6-8e15-d9c8-2e0e03adcde8\n")
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
describe "with EC2 Identifying Number", :windows_only do
|
|
392
|
+
it_behaves_like "ec2"
|
|
393
|
+
|
|
394
|
+
before do
|
|
395
|
+
allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
|
|
396
|
+
{ "caption" => "Computer System Product",
|
|
397
|
+
"description" => "Computer System Product",
|
|
398
|
+
"identifyingnumber" => "ec2a355a-91cd-5fe8-bbfc-cc891d0bf9d6",
|
|
399
|
+
"name" => "HVM domU",
|
|
400
|
+
"skunumber" => nil,
|
|
401
|
+
"uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
|
|
402
|
+
"vendor" => "Xen",
|
|
403
|
+
"version" => "4.2.amazon" })
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
describe "without EC2 Identifying Number", :windows_only do
|
|
408
|
+
it_behaves_like "!ec2"
|
|
409
|
+
|
|
410
|
+
before do
|
|
411
|
+
allow_any_instance_of(WmiLite::Wmi).to receive(:first_of).and_return(
|
|
412
|
+
{ "caption" => "Computer System Product",
|
|
413
|
+
"description" => "Computer System Product",
|
|
414
|
+
"identifyingnumber" => "1234",
|
|
415
|
+
"name" => "HVM domU",
|
|
416
|
+
"skunumber" => nil,
|
|
417
|
+
"uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
|
|
418
|
+
"vendor" => "Xen",
|
|
419
|
+
"version" => "1.2.3" })
|
|
368
420
|
end
|
|
369
421
|
end
|
|
370
422
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Author:: Phil Dibowitz <phil@ipom.com>
|
|
3
|
+
# Copyright:: Copyright (c) 2017 Facebook, Inc.
|
|
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
|
+
require_relative "../../../spec_helper.rb"
|
|
20
|
+
|
|
21
|
+
describe Ohai::System, "Linux lspci plugin" do
|
|
22
|
+
let (:plugin) { get_plugin("linux/lspci") }
|
|
23
|
+
|
|
24
|
+
before(:each) do
|
|
25
|
+
@stdout = <<LSPCI
|
|
26
|
+
Device: 00:1f.3
|
|
27
|
+
Class: Audio device [0403]
|
|
28
|
+
Vendor: Intel Corporation [8086]
|
|
29
|
+
Device: Sunrise Point-LP HD Audio [9d71]
|
|
30
|
+
SVendor: Lenovo [17aa]
|
|
31
|
+
SDevice: Sunrise Point-LP HD Audio [224e]
|
|
32
|
+
Rev: 21
|
|
33
|
+
Driver: snd_hda_intel
|
|
34
|
+
Module: snd_hda_intel
|
|
35
|
+
Module: snd_soc_skl
|
|
36
|
+
|
|
37
|
+
Device: 00:1f.4
|
|
38
|
+
Class: SMBus [0c05]
|
|
39
|
+
Vendor: Intel Corporation [8086]
|
|
40
|
+
Device: Sunrise Point-LP SMBus [9d23]
|
|
41
|
+
SVendor: Lenovo [17aa]
|
|
42
|
+
SDevice: Sunrise Point-LP SMBus [224e]
|
|
43
|
+
Rev: 21
|
|
44
|
+
Driver: i801_smbus
|
|
45
|
+
Module: i2c_i801
|
|
46
|
+
|
|
47
|
+
Device: 00:1f.6
|
|
48
|
+
Class: Ethernet controller [0200]
|
|
49
|
+
Vendor: Intel Corporation [8086]
|
|
50
|
+
Device: Ethernet Connection (4) I219-LM [15d7]
|
|
51
|
+
SVendor: Lenovo [17aa]
|
|
52
|
+
SDevice: Ethernet Connection (4) I219-LM [224e]
|
|
53
|
+
Rev: 21
|
|
54
|
+
Driver: e1000e
|
|
55
|
+
Module: e1000e
|
|
56
|
+
|
|
57
|
+
Device: 02:00.0
|
|
58
|
+
Class: Unassigned class [ff00]
|
|
59
|
+
Vendor: Realtek Semiconductor Co., Ltd. [10ec]
|
|
60
|
+
Device: RTS525A PCI Express Card Reader [525a]
|
|
61
|
+
SVendor: Lenovo [17aa]
|
|
62
|
+
SDevice: RTS525A PCI Express Card Reader [224e]
|
|
63
|
+
Rev: 01
|
|
64
|
+
Driver: rtsx_pci
|
|
65
|
+
Module: rtsx_pci
|
|
66
|
+
|
|
67
|
+
Device: 04:00.0
|
|
68
|
+
Class: Network controller [0280]
|
|
69
|
+
Vendor: Intel Corporation [8086]
|
|
70
|
+
Device: Wireless 8265 / 8275 [24fd]
|
|
71
|
+
SVendor: Intel Corporation [8086]
|
|
72
|
+
SDevice: Wireless 8265 / 8275 [0130]
|
|
73
|
+
Rev: 88
|
|
74
|
+
Driver: iwlwifi
|
|
75
|
+
Module: iwlwifi
|
|
76
|
+
|
|
77
|
+
Device: 05:00.0
|
|
78
|
+
Class: Non-Volatile memory controller [0108]
|
|
79
|
+
Vendor: Toshiba America Info Systems [1179]
|
|
80
|
+
Device: Device [0115]
|
|
81
|
+
SVendor: Toshiba America Info Systems [1179]
|
|
82
|
+
SDevice: Device [0001]
|
|
83
|
+
Rev: 01
|
|
84
|
+
ProgIf: 02
|
|
85
|
+
Driver: nvme
|
|
86
|
+
Module: nvme
|
|
87
|
+
NUMANode: 0
|
|
88
|
+
LSPCI
|
|
89
|
+
allow(plugin).to receive(:shell_out).with("lspci -vnnmk").and_return(
|
|
90
|
+
mock_shell_out(0, @stdout, ""))
|
|
91
|
+
|
|
92
|
+
allow(plugin).to receive(:collect_os).and_return(:linux)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "when gathering data from lspci" do
|
|
96
|
+
it "lists all devices" do
|
|
97
|
+
plugin.run
|
|
98
|
+
expect(plugin[:pci].keys).to eq(
|
|
99
|
+
["00:1f.3", "00:1f.4", "00:1f.6", "02:00.0", "04:00.0", "05:00.0"]
|
|
100
|
+
)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "parses out device name vs id" do
|
|
104
|
+
plugin.run
|
|
105
|
+
expect(plugin[:pci]["04:00.0"]["device_name"]).to eq("Wireless 8265 / 8275")
|
|
106
|
+
expect(plugin[:pci]["04:00.0"]["device_id"]).to eq("24fd")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "parses out sdevice name vs id" do
|
|
110
|
+
plugin.run
|
|
111
|
+
expect(plugin[:pci]["04:00.0"]["sdevice_name"]).to eq("Wireless 8265 / 8275")
|
|
112
|
+
expect(plugin[:pci]["04:00.0"]["sdevice_id"]).to eq("0130")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "parses out class name vs id" do
|
|
116
|
+
plugin.run
|
|
117
|
+
expect(plugin[:pci]["04:00.0"]["class_name"]).to eq("Network controller")
|
|
118
|
+
expect(plugin[:pci]["04:00.0"]["class_id"]).to eq("0280")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "parses out vendor name vs id" do
|
|
122
|
+
plugin.run
|
|
123
|
+
expect(plugin[:pci]["04:00.0"]["vendor_name"]).to eq("Intel Corporation")
|
|
124
|
+
expect(plugin[:pci]["04:00.0"]["vendor_id"]).to eq("8086")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "provides drivers and modules" do
|
|
128
|
+
plugin.run
|
|
129
|
+
expect(plugin[:pci]["04:00.0"]["driver"]).to eq(["iwlwifi"])
|
|
130
|
+
expect(plugin[:pci]["04:00.0"]["module"]).to eq(["iwlwifi"])
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -142,8 +142,29 @@ MD
|
|
|
142
142
|
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
|
|
143
143
|
|
|
144
144
|
@plugin.run
|
|
145
|
-
expect(@plugin[:mdadm][:md0][:
|
|
145
|
+
expect(@plugin[:mdadm][:md0][:spares]).to eq(%w{nvme2n1p3})
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "should report journal devices" do
|
|
149
|
+
new_mdstat = double("/proc/mdstat_journal")
|
|
150
|
+
allow(new_mdstat).to receive(:each).
|
|
151
|
+
and_yield("Personalies : [raid6]").
|
|
152
|
+
and_yield("md0 : active (somecraphere) <morestuff raid6 sdbc1[7] sdd1[6] sde1[5] sdd1[4] sde1[3] sdf1[2] sdg1[1] nvme2n1p3[0](J)")
|
|
153
|
+
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
|
|
154
|
+
|
|
155
|
+
@plugin.run
|
|
156
|
+
expect(@plugin[:mdadm][:md0][:journal]).to eq("nvme2n1p3")
|
|
146
157
|
end
|
|
147
|
-
end
|
|
148
158
|
|
|
159
|
+
it "should report spare devices" do
|
|
160
|
+
new_mdstat = double("/proc/mdstat_spare")
|
|
161
|
+
allow(new_mdstat).to receive(:each).
|
|
162
|
+
and_yield("Personalies : [raid6]").
|
|
163
|
+
and_yield("md0 : active (somecraphere) <morestuff raid6 sdbc1[7] sdd1[6] sde1[5] sdd1[4] sde1[3] sdf1[2] sdg1[1] sdh1[0](S)")
|
|
164
|
+
allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat)
|
|
165
|
+
|
|
166
|
+
@plugin.run
|
|
167
|
+
expect(@plugin[:mdadm][:md0][:spares]).to eq(%w{sdh1})
|
|
168
|
+
end
|
|
169
|
+
end
|
|
149
170
|
end
|
|
@@ -240,6 +240,10 @@ EOM
|
|
|
240
240
|
valid_lft forever preferred_lft forever
|
|
241
241
|
13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
|
|
242
242
|
link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff
|
|
243
|
+
14: ip6tnl0@NONE: <NOARP,UP,LOWER_UP> mtu 1452 qdisc noqueue state UNKNOWN group default qlen 1
|
|
244
|
+
link/tunnel6 :: brd ::
|
|
245
|
+
inet6 fe80::f47a:2aff:fef0:c6ef/64 scope link
|
|
246
|
+
valid_lft forever preferred_lft forever
|
|
243
247
|
EOM
|
|
244
248
|
end
|
|
245
249
|
|
|
@@ -300,6 +304,13 @@ EOM
|
|
|
300
304
|
0 0 0 0 0 0
|
|
301
305
|
TX: bytes packets errors dropped carrier collsns
|
|
302
306
|
140 2 0 1 0 0
|
|
307
|
+
14: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1
|
|
308
|
+
link/tunnel6 :: brd :: promiscuity 0
|
|
309
|
+
ip6tnl ip6ip6 remote :: local :: encaplimit 0 hoplimit 0 tclass 0x00 flowlabel 0x00000 (flowinfo 0x00000000) addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
|
|
310
|
+
RX: bytes packets errors dropped overrun mcast
|
|
311
|
+
0 0 0 0 0 0
|
|
312
|
+
TX: bytes packets errors dropped carrier collsns
|
|
313
|
+
0 0 0 0 0 0
|
|
303
314
|
EOM
|
|
304
315
|
end
|
|
305
316
|
|
|
@@ -572,7 +583,11 @@ EOM
|
|
|
572
583
|
end
|
|
573
584
|
|
|
574
585
|
it "detects the interfaces" do
|
|
575
|
-
|
|
586
|
+
if network_method == "iproute2"
|
|
587
|
+
expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "ip6tnl0", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
|
|
588
|
+
else
|
|
589
|
+
expect(plugin["network"]["interfaces"].keys.sort).to eq(["eth0", "eth0.11", "eth0.151", "eth0.152", "eth0.153", "eth0:5", "eth3", "foo:veth0@eth0", "fwdintf", "lo", "ovs-system", "tun0", "venet0", "venet0:0", "xapi1"])
|
|
590
|
+
end
|
|
576
591
|
end
|
|
577
592
|
|
|
578
593
|
it "detects the layer one details of an ethernet interface" do
|
|
@@ -676,6 +691,26 @@ EOM
|
|
|
676
691
|
expect(plugin["network"]["interfaces"]["eth0"]["arp"]["10.116.201.1"]).to eq("fe:ff:ff:ff:ff:ff")
|
|
677
692
|
end
|
|
678
693
|
|
|
694
|
+
if network_method == "iproute2"
|
|
695
|
+
it "detects the tunnel information" do
|
|
696
|
+
expect(plugin["network"]["interfaces"]["ip6tnl0"]["tunnel_info"]).to eq(
|
|
697
|
+
{
|
|
698
|
+
"proto" => "ip6ip6",
|
|
699
|
+
"remote" => "::",
|
|
700
|
+
"local" => "::",
|
|
701
|
+
"encaplimit" => "0",
|
|
702
|
+
"hoplimit" => "0",
|
|
703
|
+
"tclass" => "0x00",
|
|
704
|
+
"flowlabel" => "0x00000",
|
|
705
|
+
"addrgenmode" => "eui64",
|
|
706
|
+
"numtxqueues" => "1",
|
|
707
|
+
"numrxqueues" => "1",
|
|
708
|
+
"gso_max_size" => "65536",
|
|
709
|
+
"gso_max_segs" => "65535",
|
|
710
|
+
}
|
|
711
|
+
)
|
|
712
|
+
end
|
|
713
|
+
end
|
|
679
714
|
end
|
|
680
715
|
|
|
681
716
|
describe "gathering interface counters via #{network_method}" do
|
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: 8.
|
|
4
|
+
version: 8.26.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: 2018-01-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: systemu
|
|
@@ -275,6 +275,7 @@ files:
|
|
|
275
275
|
- lib/ohai/plugins/linux/fips.rb
|
|
276
276
|
- lib/ohai/plugins/linux/hostnamectl.rb
|
|
277
277
|
- lib/ohai/plugins/linux/lsb.rb
|
|
278
|
+
- lib/ohai/plugins/linux/lspci.rb
|
|
278
279
|
- lib/ohai/plugins/linux/machineid.rb
|
|
279
280
|
- lib/ohai/plugins/linux/mdadm.rb
|
|
280
281
|
- lib/ohai/plugins/linux/memory.rb
|
|
@@ -463,6 +464,7 @@ files:
|
|
|
463
464
|
- spec/unit/plugins/linux/hostnamectl_spec.rb
|
|
464
465
|
- spec/unit/plugins/linux/kernel_spec.rb
|
|
465
466
|
- spec/unit/plugins/linux/lsb_spec.rb
|
|
467
|
+
- spec/unit/plugins/linux/lspci_spec.rb
|
|
466
468
|
- spec/unit/plugins/linux/machineid_spec.rb
|
|
467
469
|
- spec/unit/plugins/linux/mdadm_spec.rb
|
|
468
470
|
- spec/unit/plugins/linux/memory_spec.rb
|
|
@@ -546,7 +548,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
546
548
|
version: '0'
|
|
547
549
|
requirements: []
|
|
548
550
|
rubyforge_project:
|
|
549
|
-
rubygems_version: 2.
|
|
551
|
+
rubygems_version: 2.7.3
|
|
550
552
|
signing_key:
|
|
551
553
|
specification_version: 4
|
|
552
554
|
summary: Ohai profiles your system and emits JSON
|