ohai 13.7.0 → 13.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 29f7dbc2f6ba160d4cc5a90e112804e12338cb76
4
- data.tar.gz: 1a6a50e9261b97ea92348d64cbf3e2bdc97717ab
2
+ SHA256:
3
+ metadata.gz: be033e3e127c197d8ba5631d7450e95f977517a28b4abe709fc2aa1e4fa16100
4
+ data.tar.gz: 3d432ce1bee6075b6fdbf85f45bc5450946a77a6d6cf6725551fd70df4c727b6
5
5
  SHA512:
6
- metadata.gz: 35f52d079c7a4dc1b0dfaf70c8977b808c11d36d3069888a4967973d14d70326581a22539a7f3fee2b85345b325bfd78a91cfeb52792d64c5e98bcc30f8ace74
7
- data.tar.gz: 85006bb7724517c6edeed48cabffbb806b8d5e638fa5481d7f354965159e19c28778185bd282a184fa1f6e2498fdf566ed2a0319adfc1d89176f853e56fed58f
6
+ metadata.gz: 80fbebdb0709e28ddf1cec181c16998ca88d1d3d005cb4d9e0862ee1f825931636b1dd43994808a947043baad6b40f8a7fb221af31368c9c620739596b936218
7
+ data.tar.gz: 7305f343f7762d5a1b61cd01727a589a75e03305d34efb139618c08d94e9abf6b7ddd0b6a46a74c5476bcfd79575680740244e20fedf84bae6a0a535af757461
@@ -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
@@ -212,6 +212,31 @@ Ohai.plugin(:Network) do
212
212
  net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
213
213
  end
214
214
 
215
+ if line =~ /^\s+(ip6tnl|ipip)/
216
+ iface[tmp_int][:tunnel_info] = {}
217
+ words = line.split
218
+ words.each_with_index do |word, index|
219
+ case word
220
+ when "external"
221
+ iface[tmp_int][:tunnel_info][word] = true
222
+ when "any", "ipip6", "ip6ip6"
223
+ iface[tmp_int][:tunnel_info][:proto] = word
224
+ when "remote",
225
+ "local",
226
+ "encaplimit",
227
+ "hoplimit",
228
+ "tclass",
229
+ "flowlabel",
230
+ "addrgenmode",
231
+ "numtxqueues",
232
+ "numrxqueues",
233
+ "gso_max_size",
234
+ "gso_max_segs"
235
+ iface[tmp_int][:tunnel_info][word] = words[index + 1]
236
+ end
237
+ end
238
+ end
239
+
215
240
  if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
216
241
  int = on_rx ? :rx : :tx
217
242
  net_counters[tmp_int][int] = Mash.new unless net_counters[tmp_int][int]
@@ -119,14 +119,23 @@ Ohai.plugin(:Platform) do
119
119
  def determine_platform_family
120
120
  case platform
121
121
  when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/
122
+ # apt-get+dpkg almost certainly goes here
122
123
  "debian"
123
124
  when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
125
+ # NOTE: "rhel" should be reserved exclusively for recompiled rhel versions that are nearly perfectly compatible down to the platform_version.
126
+ # The operating systems that are "rhel" should all be as compatible as rhel7 = centos7 = oracle7 = scientific7 (98%-ish core RPM version compatibility
127
+ # and the version numbers MUST track the upstream). The appropriate EPEL version repo should work nearly perfectly. Some variation like the
128
+ # oracle kernel version differences and tuning and extra packages are clearly acceptable. Almost certainly some distros above (xenserver?)
129
+ # should not be in this list. Please use fedora, below, instead. Also note that this is the only platform_family with this strict of a rule,
130
+ # see the example of the debian platform family for how the rest of the platform_family designations should be used.
124
131
  "rhel"
125
132
  when /amazon/
126
133
  "amazon"
127
134
  when /suse/
128
135
  "suse"
129
136
  when /fedora/, /pidora/, /arista_eos/
137
+ # 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
138
+ # SuSE it probably goes here).
130
139
  "fedora"
131
140
  when /nexus/, /ios_xr/
132
141
  "wrlinux"
@@ -180,7 +180,7 @@ Ohai.plugin(:Virtualization) do
180
180
  if File.exist?("/proc/self/cgroup")
181
181
  cgroup_content = File.read("/proc/self/cgroup")
182
182
  if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
183
- cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
183
+ cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-?.+$}
184
184
  Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
185
185
  virtualization[:system] = $1
186
186
  virtualization[:role] = "guest"
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "13.7.0"
21
+ VERSION = "13.7.1"
22
22
  end
@@ -0,0 +1,131 @@
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
+ end
92
+
93
+ describe "when gathering data from lspci" do
94
+ it "lists all devices" do
95
+ plugin.run
96
+ expect(plugin[:pci].keys).to eq(
97
+ ["00:1f.3", "00:1f.4", "00:1f.6", "02:00.0", "04:00.0", "05:00.0"]
98
+ )
99
+ end
100
+
101
+ it "parses out device name vs id" do
102
+ plugin.run
103
+ expect(plugin[:pci]["04:00.0"]["device_name"]).to eq("Wireless 8265 / 8275")
104
+ expect(plugin[:pci]["04:00.0"]["device_id"]).to eq("24fd")
105
+ end
106
+
107
+ it "parses out sdevice name vs id" do
108
+ plugin.run
109
+ expect(plugin[:pci]["04:00.0"]["sdevice_name"]).to eq("Wireless 8265 / 8275")
110
+ expect(plugin[:pci]["04:00.0"]["sdevice_id"]).to eq("0130")
111
+ end
112
+
113
+ it "parses out class name vs id" do
114
+ plugin.run
115
+ expect(plugin[:pci]["04:00.0"]["class_name"]).to eq("Network controller")
116
+ expect(plugin[:pci]["04:00.0"]["class_id"]).to eq("0280")
117
+ end
118
+
119
+ it "parses out vendor name vs id" do
120
+ plugin.run
121
+ expect(plugin[:pci]["04:00.0"]["vendor_name"]).to eq("Intel Corporation")
122
+ expect(plugin[:pci]["04:00.0"]["vendor_id"]).to eq("8086")
123
+ end
124
+
125
+ it "provides drivers and modules" do
126
+ plugin.run
127
+ expect(plugin[:pci]["04:00.0"]["driver"]).to eq(["iwlwifi"])
128
+ expect(plugin[:pci]["04:00.0"]["module"]).to eq(["iwlwifi"])
129
+ end
130
+ end
131
+ end
@@ -234,6 +234,10 @@ EOM
234
234
  valid_lft forever preferred_lft forever
235
235
  13: fwdintf: <MULTICAST,NOARP,UP,LOWER_UP> mtu 1496 qdisc pfifo_fast state UNKNOWN group default qlen 1000
236
236
  link/ether 00:00:00:00:00:0a brd ff:ff:ff:ff:ff:ff
237
+ 14: ip6tnl0@NONE: <NOARP,UP,LOWER_UP> mtu 1452 qdisc noqueue state UNKNOWN group default qlen 1
238
+ link/tunnel6 :: brd ::
239
+ inet6 fe80::f47a:2aff:fef0:c6ef/64 scope link
240
+ valid_lft forever preferred_lft forever
237
241
  EOM
238
242
  end
239
243
 
@@ -294,6 +298,13 @@ EOM
294
298
  0 0 0 0 0 0
295
299
  TX: bytes packets errors dropped carrier collsns
296
300
  140 2 0 1 0 0
301
+ 14: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1
302
+ link/tunnel6 :: brd :: promiscuity 0
303
+ 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
304
+ RX: bytes packets errors dropped overrun mcast
305
+ 0 0 0 0 0 0
306
+ TX: bytes packets errors dropped carrier collsns
307
+ 0 0 0 0 0 0
297
308
  EOM
298
309
  end
299
310
 
@@ -546,7 +557,11 @@ EOM
546
557
  end
547
558
 
548
559
  it "detects the interfaces" do
549
- 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"])
560
+ if network_method == "iproute2"
561
+ 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"])
562
+ else
563
+ 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"])
564
+ end
550
565
  end
551
566
 
552
567
  it "detects the layer one details of an ethernet interface" do
@@ -650,6 +665,26 @@ EOM
650
665
  expect(plugin["network"]["interfaces"]["eth0"]["arp"]["10.116.201.1"]).to eq("fe:ff:ff:ff:ff:ff")
651
666
  end
652
667
 
668
+ if network_method == "iproute2"
669
+ it "detects the tunnel information" do
670
+ expect(plugin["network"]["interfaces"]["ip6tnl0"]["tunnel_info"]).to eq(
671
+ {
672
+ "proto" => "ip6ip6",
673
+ "remote" => "::",
674
+ "local" => "::",
675
+ "encaplimit" => "0",
676
+ "hoplimit" => "0",
677
+ "tclass" => "0x00",
678
+ "flowlabel" => "0x00000",
679
+ "addrgenmode" => "eui64",
680
+ "numtxqueues" => "1",
681
+ "numrxqueues" => "1",
682
+ "gso_max_size" => "65536",
683
+ "gso_max_segs" => "65535",
684
+ }
685
+ )
686
+ end
687
+ end
653
688
  end
654
689
 
655
690
  describe "gathering interface counters via #{network_method}" do
@@ -679,6 +679,30 @@ CGROUP
679
679
  expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
680
680
  end
681
681
 
682
+ it "sets docker guest if /proc/self/cgroup exist and there are /docker/docker-ce/<hexadecimal> mounts" do
683
+ self_cgroup = <<-CGROUP
684
+ 13:name=systemd:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
685
+ 12:pids:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
686
+ 11:hugetlb:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
687
+ 10:net_prio:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
688
+ 9:perf_event:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
689
+ 8:net_cls:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
690
+ 7:freezer:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
691
+ 6:devices:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
692
+ 5:memory:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
693
+ 4:blkio:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
694
+ 3:cpuacct:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
695
+ 2:cpu:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
696
+ 1:cpuset:/docker-ce/docker/b15b85d19304436488a78d06afeb108d94b20bb6898d852b65cad51bd7dc9468
697
+ CGROUP
698
+ allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true)
699
+ allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup)
700
+ plugin.run
701
+ expect(plugin[:virtualization][:system]).to eq("docker")
702
+ expect(plugin[:virtualization][:role]).to eq("guest")
703
+ expect(plugin[:virtualization][:systems][:docker]).to eq("guest")
704
+ end
705
+
682
706
  # Relevant at least starting docker 1.6.2, kernel 4.0.5 & systemd 224-1.
683
707
  # Doi not exactly know which software/version really matters here.
684
708
  it "should set docker guest if /proc/self/cgroup exists and there are /system.slice/docker-<hexadecimal> mounts (systemd managed cgroup)" 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: 13.7.0
4
+ version: 13.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-05 00:00:00.000000000 Z
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
@@ -456,6 +457,7 @@ files:
456
457
  - spec/unit/plugins/linux/hostnamectl_spec.rb
457
458
  - spec/unit/plugins/linux/kernel_spec.rb
458
459
  - spec/unit/plugins/linux/lsb_spec.rb
460
+ - spec/unit/plugins/linux/lspci_spec.rb
459
461
  - spec/unit/plugins/linux/machineid_spec.rb
460
462
  - spec/unit/plugins/linux/mdadm_spec.rb
461
463
  - spec/unit/plugins/linux/memory_spec.rb
@@ -539,7 +541,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
539
541
  version: '0'
540
542
  requirements: []
541
543
  rubyforge_project:
542
- rubygems_version: 2.6.13
544
+ rubygems_version: 2.7.3
543
545
  signing_key:
544
546
  specification_version: 4
545
547
  summary: Ohai profiles your system and emits JSON