ohai 16.4.12 → 16.7.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +11 -11
- data/bin/ohai +2 -1
- data/lib/ohai.rb +2 -1
- data/lib/ohai/application.rb +40 -0
- data/lib/ohai/common/dmi.rb +8 -3
- data/lib/ohai/config.rb +3 -3
- data/lib/ohai/dsl.rb +2 -1
- data/lib/ohai/dsl/plugin.rb +13 -5
- data/lib/ohai/dsl/plugin/versionvii.rb +29 -16
- data/lib/ohai/exception.rb +2 -1
- data/lib/ohai/hints.rb +2 -1
- data/lib/ohai/loader.rb +1 -1
- data/lib/ohai/log.rb +2 -1
- data/lib/ohai/mash.rb +1 -0
- data/lib/ohai/mixin/azure_metadata.rb +3 -2
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -0
- data/lib/ohai/mixin/command.rb +4 -54
- data/lib/ohai/mixin/constant_helper.rb +2 -1
- data/lib/ohai/mixin/dmi_decode.rb +2 -1
- data/lib/ohai/mixin/do_metadata.rb +4 -3
- data/lib/ohai/mixin/ec2_metadata.rb +5 -4
- data/lib/ohai/mixin/gce_metadata.rb +3 -2
- data/lib/ohai/mixin/http_helper.rb +2 -1
- data/lib/ohai/mixin/network_helper.rb +2 -1
- data/lib/ohai/mixin/os.rb +68 -2
- data/lib/ohai/mixin/scaleway_metadata.rb +4 -3
- data/lib/ohai/mixin/seconds_to_human.rb +2 -1
- data/lib/ohai/mixin/shell_out.rb +51 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
- data/lib/ohai/mixin/string.rb +2 -1
- data/lib/ohai/mixin/train_helpers.rb +36 -0
- data/lib/ohai/mixin/which.rb +39 -0
- data/lib/ohai/plugin_config.rb +2 -1
- data/lib/ohai/plugins/aix/kernel.rb +2 -1
- data/lib/ohai/plugins/aix/memory.rb +4 -3
- data/lib/ohai/plugins/aix/network.rb +3 -2
- data/lib/ohai/plugins/aix/platform.rb +2 -1
- data/lib/ohai/plugins/aix/uptime.rb +4 -3
- data/lib/ohai/plugins/aix/virtualization.rb +1 -1
- data/lib/ohai/plugins/azure.rb +26 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +4 -3
- data/lib/ohai/plugins/c.rb +1 -0
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +2 -1
- data/lib/ohai/plugins/command.rb +2 -1
- data/lib/ohai/plugins/cpu.rb +8 -9
- data/lib/ohai/plugins/darwin/hardware.rb +1 -0
- data/lib/ohai/plugins/darwin/memory.rb +3 -4
- data/lib/ohai/plugins/darwin/network.rb +2 -1
- data/lib/ohai/plugins/darwin/platform.rb +3 -2
- data/lib/ohai/plugins/darwin/virtualization.rb +3 -2
- data/lib/ohai/plugins/digital_ocean.rb +1 -0
- data/lib/ohai/plugins/dmi.rb +2 -1
- data/lib/ohai/plugins/docker.rb +2 -1
- data/lib/ohai/plugins/dragonflybsd/memory.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +1 -0
- data/lib/ohai/plugins/ec2.rb +16 -9
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +2 -1
- data/lib/ohai/plugins/eucalyptus.rb +5 -2
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/fips.rb +2 -1
- data/lib/ohai/plugins/freebsd/memory.rb +1 -0
- data/lib/ohai/plugins/freebsd/network.rb +1 -0
- data/lib/ohai/plugins/freebsd/platform.rb +1 -0
- data/lib/ohai/plugins/gce.rb +3 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/haskell.rb +1 -0
- data/lib/ohai/plugins/hostname.rb +2 -1
- data/lib/ohai/plugins/init_package.rb +3 -2
- data/lib/ohai/plugins/java.rb +2 -1
- data/lib/ohai/plugins/joyent.rb +3 -2
- data/lib/ohai/plugins/kernel.rb +11 -6
- data/lib/ohai/plugins/keys.rb +2 -1
- data/lib/ohai/plugins/languages.rb +2 -1
- data/lib/ohai/plugins/libvirt.rb +2 -1
- data/lib/ohai/plugins/linode.rb +2 -1
- data/lib/ohai/plugins/linux/block_device.rb +10 -9
- data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
- data/lib/ohai/plugins/linux/interrupts.rb +4 -3
- data/lib/ohai/plugins/linux/ipc.rb +2 -1
- data/lib/ohai/plugins/linux/lsb.rb +8 -21
- data/lib/ohai/plugins/linux/lspci.rb +1 -0
- data/lib/ohai/plugins/linux/machineid.rb +5 -4
- data/lib/ohai/plugins/linux/mdadm.rb +3 -2
- data/lib/ohai/plugins/linux/memory.rb +39 -38
- data/lib/ohai/plugins/linux/network.rb +14 -13
- data/lib/ohai/plugins/linux/platform.rb +32 -31
- data/lib/ohai/plugins/linux/selinux.rb +1 -0
- data/lib/ohai/plugins/linux/sessions.rb +1 -0
- data/lib/ohai/plugins/linux/sysctl.rb +1 -0
- data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
- data/lib/ohai/plugins/linux/virtualization.rb +25 -24
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/memory.rb +1 -0
- data/lib/ohai/plugins/netbsd/network.rb +1 -0
- data/lib/ohai/plugins/netbsd/platform.rb +1 -0
- data/lib/ohai/plugins/network.rb +2 -1
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +1 -0
- data/lib/ohai/plugins/ohai_time.rb +3 -2
- data/lib/ohai/plugins/openbsd/memory.rb +1 -0
- data/lib/ohai/plugins/openbsd/network.rb +1 -0
- data/lib/ohai/plugins/openbsd/platform.rb +1 -0
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/os.rb +6 -1
- data/lib/ohai/plugins/packages.rb +21 -0
- data/lib/ohai/plugins/passwd.rb +58 -1
- data/lib/ohai/plugins/perl.rb +2 -2
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/platform.rb +2 -1
- data/lib/ohai/plugins/powershell.rb +2 -2
- data/lib/ohai/plugins/ps.rb +2 -1
- data/lib/ohai/plugins/python.rb +2 -2
- data/lib/ohai/plugins/rackspace.rb +4 -3
- data/lib/ohai/plugins/root_group.rb +1 -0
- data/lib/ohai/plugins/ruby.rb +3 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -0
- data/lib/ohai/plugins/scaleway.rb +2 -1
- data/lib/ohai/plugins/scsi.rb +1 -0
- data/lib/ohai/plugins/shard.rb +2 -2
- data/lib/ohai/plugins/shells.rb +4 -3
- data/lib/ohai/plugins/softlayer.rb +2 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
- data/lib/ohai/plugins/solaris2/memory.rb +1 -0
- data/lib/ohai/plugins/solaris2/network.rb +7 -8
- data/lib/ohai/plugins/solaris2/platform.rb +9 -15
- data/lib/ohai/plugins/solaris2/virtualization.rb +4 -3
- data/lib/ohai/plugins/ssh_host_key.rb +14 -13
- data/lib/ohai/plugins/sysconf.rb +1 -0
- data/lib/ohai/plugins/timezone.rb +1 -0
- data/lib/ohai/plugins/train.rb +36 -0
- data/lib/ohai/plugins/uptime.rb +3 -2
- data/lib/ohai/plugins/virtualbox.rb +2 -1
- data/lib/ohai/plugins/vmware.rb +3 -2
- data/lib/ohai/plugins/windows/dmi.rb +1 -0
- data/lib/ohai/plugins/windows/drivers.rb +2 -1
- data/lib/ohai/plugins/windows/memory.rb +1 -0
- data/lib/ohai/plugins/windows/network.rb +3 -2
- data/lib/ohai/plugins/windows/platform.rb +2 -1
- data/lib/ohai/plugins/windows/system_enclosure.rb +2 -1
- data/lib/ohai/plugins/windows/virtualization.rb +2 -1
- data/lib/ohai/plugins/zpools.rb +6 -3
- data/lib/ohai/provides_map.rb +2 -1
- data/lib/ohai/runner.rb +8 -5
- data/lib/ohai/system.rb +35 -7
- data/lib/ohai/train_transport.rb +29 -0
- data/lib/ohai/util/file_helper.rb +5 -37
- data/lib/ohai/util/ip_helper.rb +1 -0
- data/lib/ohai/util/win32.rb +2 -1
- data/lib/ohai/version.rb +4 -3
- data/ohai.gemspec +8 -7
- metadata +80 -60
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
3
4
|
# Copyright:: Copyright (c) 2016 Facebook
|
@@ -20,10 +21,10 @@ Ohai.plugin(:Machineid) do
|
|
20
21
|
provides "machine_id"
|
21
22
|
|
22
23
|
collect_data(:linux) do
|
23
|
-
if
|
24
|
-
mid =
|
25
|
-
elsif
|
26
|
-
mid =
|
24
|
+
if file_exist?("/etc/machine-id")
|
25
|
+
mid = file_read("/etc/machine-id").chomp
|
26
|
+
elsif file_exist?("/var/lib/dbus/machine-id")
|
27
|
+
mid = file_read("/var/lib/dbus/machine-id").chomp
|
27
28
|
else
|
28
29
|
mid = nil
|
29
30
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Smith <tsmith@limelight.com>
|
3
4
|
# Author:: Phil Dibowitz <phild@ipomc.com>
|
@@ -53,9 +54,9 @@ Ohai.plugin(:Mdadm) do
|
|
53
54
|
|
54
55
|
collect_data(:linux) do
|
55
56
|
# gather a list of all raid arrays
|
56
|
-
if
|
57
|
+
if file_exist?("/proc/mdstat")
|
57
58
|
devices = {}
|
58
|
-
|
59
|
+
file_open("/proc/mdstat").each do |line|
|
59
60
|
if line =~ /(md[0-9]+)/
|
60
61
|
device = Regexp.last_match[1]
|
61
62
|
pieces = line.split(/\s+/)
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -25,79 +26,79 @@ Ohai.plugin(:Memory) do
|
|
25
26
|
memory[:hugepages] = Mash.new
|
26
27
|
memory[:directmap] = Mash.new
|
27
28
|
|
28
|
-
|
29
|
+
file_open("/proc/meminfo").each do |line|
|
29
30
|
case line
|
30
|
-
when /^MemTotal:\s+(\d+) (.+)
|
31
|
+
when /^MemTotal:\s+(\d+) (.+)/
|
31
32
|
memory[:total] = "#{$1}#{$2}"
|
32
|
-
when /^MemFree:\s+(\d+) (.+)
|
33
|
+
when /^MemFree:\s+(\d+) (.+)/
|
33
34
|
memory[:free] = "#{$1}#{$2}"
|
34
|
-
when /^MemAvailable:\s+(\d+) (.+)
|
35
|
+
when /^MemAvailable:\s+(\d+) (.+)/
|
35
36
|
memory[:available] = "#{$1}#{$2}"
|
36
|
-
when /^Buffers:\s+(\d+) (.+)
|
37
|
+
when /^Buffers:\s+(\d+) (.+)/
|
37
38
|
memory[:buffers] = "#{$1}#{$2}"
|
38
|
-
when /^Cached:\s+(\d+) (.+)
|
39
|
+
when /^Cached:\s+(\d+) (.+)/
|
39
40
|
memory[:cached] = "#{$1}#{$2}"
|
40
|
-
when /^Active:\s+(\d+) (.+)
|
41
|
+
when /^Active:\s+(\d+) (.+)/
|
41
42
|
memory[:active] = "#{$1}#{$2}"
|
42
|
-
when /^Inactive:\s+(\d+) (.+)
|
43
|
+
when /^Inactive:\s+(\d+) (.+)/
|
43
44
|
memory[:inactive] = "#{$1}#{$2}"
|
44
|
-
when /^HighTotal:\s+(\d+) (.+)
|
45
|
+
when /^HighTotal:\s+(\d+) (.+)/
|
45
46
|
memory[:high_total] = "#{$1}#{$2}"
|
46
|
-
when /^HighFree:\s+(\d+) (.+)
|
47
|
+
when /^HighFree:\s+(\d+) (.+)/
|
47
48
|
memory[:high_free] = "#{$1}#{$2}"
|
48
|
-
when /^LowTotal:\s+(\d+) (.+)
|
49
|
+
when /^LowTotal:\s+(\d+) (.+)/
|
49
50
|
memory[:low_total] = "#{$1}#{$2}"
|
50
|
-
when /^LowFree:\s+(\d+) (.+)
|
51
|
+
when /^LowFree:\s+(\d+) (.+)/
|
51
52
|
memory[:low_free] = "#{$1}#{$2}"
|
52
|
-
when /^Dirty:\s+(\d+) (.+)
|
53
|
+
when /^Dirty:\s+(\d+) (.+)/
|
53
54
|
memory[:dirty] = "#{$1}#{$2}"
|
54
|
-
when /^Writeback:\s+(\d+) (.+)
|
55
|
+
when /^Writeback:\s+(\d+) (.+)/
|
55
56
|
memory[:writeback] = "#{$1}#{$2}"
|
56
|
-
when /^AnonPages:\s+(\d+) (.+)
|
57
|
+
when /^AnonPages:\s+(\d+) (.+)/
|
57
58
|
memory[:anon_pages] = "#{$1}#{$2}"
|
58
|
-
when /^Mapped:\s+(\d+) (.+)
|
59
|
+
when /^Mapped:\s+(\d+) (.+)/
|
59
60
|
memory[:mapped] = "#{$1}#{$2}"
|
60
|
-
when /^Slab:\s+(\d+) (.+)
|
61
|
+
when /^Slab:\s+(\d+) (.+)/
|
61
62
|
memory[:slab] = "#{$1}#{$2}"
|
62
|
-
when /^SReclaimable:\s+(\d+) (.+)
|
63
|
+
when /^SReclaimable:\s+(\d+) (.+)/
|
63
64
|
memory[:slab_reclaimable] = "#{$1}#{$2}"
|
64
|
-
when /^SUnreclaim:\s+(\d+) (.+)
|
65
|
+
when /^SUnreclaim:\s+(\d+) (.+)/
|
65
66
|
memory[:slab_unreclaim] = "#{$1}#{$2}"
|
66
|
-
when /^PageTables:\s+(\d+) (.+)
|
67
|
+
when /^PageTables:\s+(\d+) (.+)/
|
67
68
|
memory[:page_tables] = "#{$1}#{$2}"
|
68
|
-
when /^NFS_Unstable:\s+(\d+) (.+)
|
69
|
+
when /^NFS_Unstable:\s+(\d+) (.+)/
|
69
70
|
memory[:nfs_unstable] = "#{$1}#{$2}"
|
70
|
-
when /^Bounce:\s+(\d+) (.+)
|
71
|
+
when /^Bounce:\s+(\d+) (.+)/
|
71
72
|
memory[:bounce] = "#{$1}#{$2}"
|
72
|
-
when /^CommitLimit:\s+(\d+) (.+)
|
73
|
+
when /^CommitLimit:\s+(\d+) (.+)/
|
73
74
|
memory[:commit_limit] = "#{$1}#{$2}"
|
74
|
-
when /^Committed_AS:\s+(\d+) (.+)
|
75
|
+
when /^Committed_AS:\s+(\d+) (.+)/
|
75
76
|
memory[:committed_as] = "#{$1}#{$2}"
|
76
|
-
when /^VmallocTotal:\s+(\d+) (.+)
|
77
|
+
when /^VmallocTotal:\s+(\d+) (.+)/
|
77
78
|
memory[:vmalloc_total] = "#{$1}#{$2}"
|
78
|
-
when /^VmallocUsed:\s+(\d+) (.+)
|
79
|
+
when /^VmallocUsed:\s+(\d+) (.+)/
|
79
80
|
memory[:vmalloc_used] = "#{$1}#{$2}"
|
80
|
-
when /^VmallocChunk:\s+(\d+) (.+)
|
81
|
+
when /^VmallocChunk:\s+(\d+) (.+)/
|
81
82
|
memory[:vmalloc_chunk] = "#{$1}#{$2}"
|
82
|
-
when /^SwapCached:\s+(\d+) (.+)
|
83
|
+
when /^SwapCached:\s+(\d+) (.+)/
|
83
84
|
memory[:swap][:cached] = "#{$1}#{$2}"
|
84
|
-
when /^SwapTotal:\s+(\d+) (.+)
|
85
|
+
when /^SwapTotal:\s+(\d+) (.+)/
|
85
86
|
memory[:swap][:total] = "#{$1}#{$2}"
|
86
|
-
when /^SwapFree:\s+(\d+) (.+)
|
87
|
+
when /^SwapFree:\s+(\d+) (.+)/
|
87
88
|
memory[:swap][:free] = "#{$1}#{$2}"
|
88
|
-
when /^HugePages_Total:\s+(\d+)
|
89
|
+
when /^HugePages_Total:\s+(\d+)/
|
89
90
|
memory[:hugepages][:total] = $1.to_s
|
90
|
-
when /^HugePages_Free:\s+(\d+)
|
91
|
+
when /^HugePages_Free:\s+(\d+)/
|
91
92
|
memory[:hugepages][:free] = $1.to_s
|
92
|
-
when /^HugePages_Rsvd:\s+(\d+)
|
93
|
+
when /^HugePages_Rsvd:\s+(\d+)/
|
93
94
|
memory[:hugepages][:reserved] = $1.to_s
|
94
|
-
when /^HugePages_Surp:\s+(\d+)
|
95
|
+
when /^HugePages_Surp:\s+(\d+)/
|
95
96
|
memory[:hugepages][:surplus] = $1.to_s
|
96
|
-
when /^Hugepagesize:\s+(\d+) (.+)
|
97
|
+
when /^Hugepagesize:\s+(\d+) (.+)/
|
97
98
|
memory[:hugepage_size] = "#{$1}#{$2}"
|
98
|
-
when /^Hugetlb:\s+(\d+) (.+)
|
99
|
+
when /^Hugetlb:\s+(\d+) (.+)/
|
99
100
|
memory[:hugetlb] = "#{$1}#{$2}"
|
100
|
-
when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)
|
101
|
+
when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)/
|
101
102
|
memory[:directmap][$1.to_sym] = "#{$2}#{$3}"
|
102
103
|
end
|
103
104
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Chris Read <chris.read@gmail.com>
|
4
|
-
# Copyright:: Copyright (c)
|
5
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
6
|
# License:: Apache License, Version 2.0
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -35,7 +36,7 @@ Ohai.plugin(:Network) do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def ipv6_enabled?
|
38
|
-
|
39
|
+
file_exist? "/proc/net/if_inet6"
|
39
40
|
end
|
40
41
|
|
41
42
|
def ethtool_binary_path
|
@@ -43,11 +44,11 @@ Ohai.plugin(:Network) do
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def is_openvz?
|
46
|
-
@openvz ||=
|
47
|
+
@openvz ||= file_directory?("/proc/vz")
|
47
48
|
end
|
48
49
|
|
49
50
|
def is_openvz_host?
|
50
|
-
is_openvz? &&
|
51
|
+
is_openvz? && file_directory?("/proc/bc")
|
51
52
|
end
|
52
53
|
|
53
54
|
def extract_neighbors(family, iface, neigh_attr)
|
@@ -141,12 +142,12 @@ Ohai.plugin(:Network) do
|
|
141
142
|
# using a temporary var to hold routes and their interface name
|
142
143
|
def parse_routes(family, iface)
|
143
144
|
iface.collect do |i, iv|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
end.compact.flatten
|
145
|
+
next unless iv[:routes]
|
146
|
+
|
147
|
+
iv[:routes].collect do |r|
|
148
|
+
r.merge(dev: i) if r[:family] == family[:name]
|
149
|
+
end.compact # @todo: when we drop ruby 2.6 this should be a filter_map
|
150
|
+
end.compact.flatten # @todo: when we drop ruby 2.6 this should be a filter_map
|
150
151
|
end
|
151
152
|
|
152
153
|
# determine layer 1 details for the interface using ethtool
|
@@ -264,7 +265,7 @@ Ohai.plugin(:Network) do
|
|
264
265
|
end
|
265
266
|
key, val = line.split(/:\s+/)
|
266
267
|
if val
|
267
|
-
coalesce_key =
|
268
|
+
coalesce_key = key.downcase.tr(" ", "_").to_s
|
268
269
|
iface[tmp_int]["coalesce_params"][coalesce_key] = val.to_i
|
269
270
|
end
|
270
271
|
end
|
@@ -289,7 +290,7 @@ Ohai.plugin(:Network) do
|
|
289
290
|
if val.nil?
|
290
291
|
val = ""
|
291
292
|
end
|
292
|
-
driver_key =
|
293
|
+
driver_key = key.downcase.tr(" ", "_").to_s
|
293
294
|
iface[tmp_int]["driver_info"][driver_key] = val.chomp
|
294
295
|
end
|
295
296
|
end
|
@@ -646,7 +647,7 @@ Ohai.plugin(:Network) do
|
|
646
647
|
logger.trace("Plugin Network: #{default_prefix}_interface set to #{default_route[:dev]}")
|
647
648
|
|
648
649
|
# setting gateway to 0.0.0.0 or :: if the default route is a link level one
|
649
|
-
network["#{default_prefix}_gateway"] = default_route[:via]
|
650
|
+
network["#{default_prefix}_gateway"] = default_route[:via] || family[:default_route].chomp("/0")
|
650
651
|
logger.trace("Plugin Network: #{default_prefix}_gateway set to #{network["#{default_prefix}_gateway"]}")
|
651
652
|
|
652
653
|
# deduce the default route the user most likely cares about to pick {ip,mac,ip6}address below
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -43,9 +44,9 @@ Ohai.plugin(:Platform) do
|
|
43
44
|
# @returns [Hash] the file parsed into a Hash or nil
|
44
45
|
#
|
45
46
|
def read_os_release_info(file)
|
46
|
-
return nil unless
|
47
|
+
return nil unless file_exist?(file)
|
47
48
|
|
48
|
-
|
49
|
+
file_read(file).split.inject({}) do |map, line|
|
49
50
|
key, value = line.split("=")
|
50
51
|
map[key] = value.gsub(/\A"|"\Z/, "") if value
|
51
52
|
map
|
@@ -64,7 +65,7 @@ Ohai.plugin(:Platform) do
|
|
64
65
|
begin
|
65
66
|
os_release_info = read_os_release_info("/etc/os-release")
|
66
67
|
cisco_release_info = os_release_info["CISCO_RELEASE_INFO"] if os_release_info
|
67
|
-
if cisco_release_info &&
|
68
|
+
if cisco_release_info && file_exist?(cisco_release_info)
|
68
69
|
os_release_info.merge!(read_os_release_info(cisco_release_info))
|
69
70
|
end
|
70
71
|
os_release_info
|
@@ -77,7 +78,7 @@ Ohai.plugin(:Platform) do
|
|
77
78
|
# @returns [Boolean] if we are Cisco according to /etc/os-release
|
78
79
|
#
|
79
80
|
def os_release_file_is_cisco?
|
80
|
-
|
81
|
+
file_exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
|
81
82
|
end
|
82
83
|
|
83
84
|
#
|
@@ -88,7 +89,7 @@ Ohai.plugin(:Platform) do
|
|
88
89
|
# @returns [String] bigip Linux version from /etc/f5-release
|
89
90
|
#
|
90
91
|
def bigip_version
|
91
|
-
release_contents =
|
92
|
+
release_contents = file_read("/etc/f5-release")
|
92
93
|
release_contents.match(/BIG-IP release (\S*)/)[1] # http://rubular.com/r/O8nlrBVqSb
|
93
94
|
rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
|
94
95
|
logger.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version")
|
@@ -132,7 +133,7 @@ Ohai.plugin(:Platform) do
|
|
132
133
|
#
|
133
134
|
def platform_family_from_platform(plat)
|
134
135
|
case plat
|
135
|
-
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/
|
136
|
+
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/, /pop/
|
136
137
|
# apt-get+dpkg almost certainly goes here
|
137
138
|
"debian"
|
138
139
|
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xcp/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
@@ -178,18 +179,18 @@ Ohai.plugin(:Platform) do
|
|
178
179
|
# @deprecated
|
179
180
|
def legacy_platform_detection
|
180
181
|
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
181
|
-
if
|
182
|
-
contents =
|
182
|
+
if file_exist?("/etc/oracle-release")
|
183
|
+
contents = file_read("/etc/oracle-release").chomp
|
183
184
|
platform "oracle"
|
184
185
|
platform_version get_redhatish_version(contents)
|
185
|
-
elsif
|
186
|
-
contents =
|
186
|
+
elsif file_exist?("/etc/enterprise-release")
|
187
|
+
contents = file_read("/etc/enterprise-release").chomp
|
187
188
|
platform "oracle"
|
188
189
|
platform_version get_redhatish_version(contents)
|
189
|
-
elsif
|
190
|
+
elsif file_exist?("/etc/f5-release")
|
190
191
|
platform "bigip"
|
191
192
|
platform_version bigip_version
|
192
|
-
elsif
|
193
|
+
elsif file_exist?("/etc/debian_version")
|
193
194
|
# Ubuntu and Debian both have /etc/debian_version
|
194
195
|
# Ubuntu should always have a working lsb, debian does not by default
|
195
196
|
if /Ubuntu/i.match?(lsb[:id])
|
@@ -197,25 +198,25 @@ Ohai.plugin(:Platform) do
|
|
197
198
|
platform_version lsb[:release]
|
198
199
|
else
|
199
200
|
platform "debian"
|
200
|
-
platform_version
|
201
|
+
platform_version file_read("/etc/debian_version").chomp
|
201
202
|
end
|
202
|
-
elsif
|
203
|
-
contents =
|
203
|
+
elsif file_exist?("/etc/parallels-release")
|
204
|
+
contents = file_read("/etc/parallels-release").chomp
|
204
205
|
platform get_redhatish_platform(contents)
|
205
206
|
platform_version contents.match(/(\d\.\d\.\d)/)[0]
|
206
|
-
elsif
|
207
|
+
elsif file_exist?("/etc/Eos-release")
|
207
208
|
platform "arista_eos"
|
208
|
-
platform_version
|
209
|
-
elsif
|
210
|
-
contents =
|
209
|
+
platform_version file_read("/etc/Eos-release").strip.split[-1]
|
210
|
+
elsif file_exist?("/etc/redhat-release")
|
211
|
+
contents = file_read("/etc/redhat-release").chomp
|
211
212
|
platform get_redhatish_platform(contents)
|
212
213
|
platform_version get_redhatish_version(contents)
|
213
|
-
elsif
|
214
|
-
contents =
|
214
|
+
elsif file_exist?("/etc/system-release")
|
215
|
+
contents = file_read("/etc/system-release").chomp
|
215
216
|
platform get_redhatish_platform(contents)
|
216
217
|
platform_version get_redhatish_version(contents)
|
217
|
-
elsif
|
218
|
-
suse_release =
|
218
|
+
elsif file_exist?("/etc/SuSE-release")
|
219
|
+
suse_release = file_read("/etc/SuSE-release")
|
219
220
|
suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
220
221
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
221
222
|
platform_version suse_version
|
@@ -243,16 +244,16 @@ Ohai.plugin(:Platform) do
|
|
243
244
|
end
|
244
245
|
|
245
246
|
platform_version os_release_info["VERSION"]
|
246
|
-
elsif
|
247
|
+
elsif file_exist?("/etc/slackware-version")
|
247
248
|
platform "slackware"
|
248
|
-
platform_version
|
249
|
-
elsif
|
249
|
+
platform_version file_read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
250
|
+
elsif file_exist?("/etc/exherbo-release")
|
250
251
|
platform "exherbo"
|
251
252
|
# no way to determine platform_version in a rolling release distribution
|
252
253
|
# kernel release will be used - ex. 3.13
|
253
254
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
254
|
-
elsif
|
255
|
-
contents =
|
255
|
+
elsif file_exist?("/usr/lib/os-release")
|
256
|
+
contents = file_read("/usr/lib/os-release")
|
256
257
|
if /clear-linux-os/.match?(contents) # Clear Linux https://clearlinux.org/
|
257
258
|
platform "clearlinux"
|
258
259
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
@@ -285,14 +286,14 @@ Ohai.plugin(:Platform) do
|
|
285
286
|
def determine_os_version
|
286
287
|
# centos only includes the major version in os-release for some reason
|
287
288
|
if os_release_info["ID"] == "centos"
|
288
|
-
get_redhatish_version(
|
289
|
+
get_redhatish_version(file_read("/etc/redhat-release").chomp)
|
289
290
|
else
|
290
291
|
os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
|
291
292
|
end
|
292
293
|
end
|
293
294
|
|
294
295
|
collect_data(:linux) do
|
295
|
-
if
|
296
|
+
if file_exist?("/etc/os-release")
|
296
297
|
logger.trace("Plugin platform: Using /etc/os-release for platform detection")
|
297
298
|
|
298
299
|
# fixup os-release names to ohai platform names
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Thom May (<thom@clearairturbulence.org>)
|
3
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -51,15 +52,15 @@ Ohai.plugin(:Virtualization) do
|
|
51
52
|
# - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
|
52
53
|
# - Additional edge cases likely should not change the above assumptions
|
53
54
|
# but rather be additive - btm
|
54
|
-
if
|
55
|
+
if file_exist?("/proc/xen")
|
55
56
|
virtualization[:system] = "xen"
|
56
57
|
# Assume guest
|
57
58
|
virtualization[:role] = "guest"
|
58
59
|
virtualization[:systems][:xen] = "guest"
|
59
60
|
|
60
61
|
# This file should exist on most Xen systems, normally empty for guests
|
61
|
-
if
|
62
|
-
if /control_d/i.match?(
|
62
|
+
if file_exist?("/proc/xen/capabilities")
|
63
|
+
if /control_d/i.match?(file_read("/proc/xen/capabilities"))
|
63
64
|
logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
|
64
65
|
virtualization[:role] = "host"
|
65
66
|
virtualization[:systems][:xen] = "host"
|
@@ -68,8 +69,8 @@ Ohai.plugin(:Virtualization) do
|
|
68
69
|
end
|
69
70
|
|
70
71
|
# Detect Virtualbox from kernel module
|
71
|
-
if
|
72
|
-
modules =
|
72
|
+
if file_exist?("/proc/modules")
|
73
|
+
modules = file_read("/proc/modules")
|
73
74
|
if /^vboxdrv/.match?(modules)
|
74
75
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
|
75
76
|
virtualization[:system] = "vbox"
|
@@ -92,8 +93,8 @@ Ohai.plugin(:Virtualization) do
|
|
92
93
|
end
|
93
94
|
|
94
95
|
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
95
|
-
if
|
96
|
-
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(
|
96
|
+
if file_exist?("/proc/cpuinfo")
|
97
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(file_read("/proc/cpuinfo"))
|
97
98
|
logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
|
98
99
|
virtualization[:system] = "kvm"
|
99
100
|
virtualization[:role] = "guest"
|
@@ -103,9 +104,9 @@ Ohai.plugin(:Virtualization) do
|
|
103
104
|
|
104
105
|
# Detect KVM systems via /sys
|
105
106
|
# guests will have the hypervisor cpu feature that hosts don't have
|
106
|
-
if
|
107
|
+
if file_exist?("/sys/devices/virtual/misc/kvm")
|
107
108
|
virtualization[:system] = "kvm"
|
108
|
-
if /hypervisor/.match?(
|
109
|
+
if /hypervisor/.match?(file_read("/proc/cpuinfo"))
|
109
110
|
logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
|
110
111
|
virtualization[:role] = "guest"
|
111
112
|
virtualization[:systems][:kvm] = "guest"
|
@@ -129,12 +130,12 @@ Ohai.plugin(:Virtualization) do
|
|
129
130
|
|
130
131
|
# Detect OpenVZ / Virtuozzo.
|
131
132
|
# http://wiki.openvz.org/BC_proc_entries
|
132
|
-
if
|
133
|
+
if file_exist?("/proc/bc/0")
|
133
134
|
logger.trace("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
|
134
135
|
virtualization[:system] = "openvz"
|
135
136
|
virtualization[:role] = "host"
|
136
137
|
virtualization[:systems][:openvz] = "host"
|
137
|
-
elsif
|
138
|
+
elsif file_exist?("/proc/vz")
|
138
139
|
logger.trace("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
|
139
140
|
virtualization[:system] = "openvz"
|
140
141
|
virtualization[:role] = "guest"
|
@@ -142,9 +143,9 @@ Ohai.plugin(:Virtualization) do
|
|
142
143
|
end
|
143
144
|
|
144
145
|
# Detect Hyper-V guest and the hostname of the host
|
145
|
-
if
|
146
|
+
if file_exist?("/var/lib/hyperv/.kvp_pool_3")
|
146
147
|
logger.trace("Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest")
|
147
|
-
data =
|
148
|
+
data = file_read("/var/lib/hyperv/.kvp_pool_3")
|
148
149
|
hyperv_host = data[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join.downcase
|
149
150
|
virtualization[:system] = "hyperv"
|
150
151
|
virtualization[:role] = "guest"
|
@@ -153,8 +154,8 @@ Ohai.plugin(:Virtualization) do
|
|
153
154
|
end
|
154
155
|
|
155
156
|
# Detect Linux-VServer
|
156
|
-
if
|
157
|
-
proc_self_status =
|
157
|
+
if file_exist?("/proc/self/status")
|
158
|
+
proc_self_status = file_read("/proc/self/status")
|
158
159
|
vxid = proc_self_status.match(/^(s_context|VxID):\s*(\d+)$/)
|
159
160
|
if vxid && vxid[2]
|
160
161
|
virtualization[:system] = "linux-vserver"
|
@@ -188,8 +189,8 @@ Ohai.plugin(:Virtualization) do
|
|
188
189
|
#
|
189
190
|
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
190
191
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
191
|
-
if
|
192
|
-
cgroup_content =
|
192
|
+
if file_exist?("/proc/self/cgroup")
|
193
|
+
cgroup_content = file_read("/proc/self/cgroup")
|
193
194
|
# These two REs catch many different examples. Here's a specific one
|
194
195
|
# from when it is docker and there is no subsystem name.
|
195
196
|
# https://rubular.com/r/dV13hiU9KxmiWB
|
@@ -199,17 +200,17 @@ Ohai.plugin(:Virtualization) do
|
|
199
200
|
virtualization[:system] = $1
|
200
201
|
virtualization[:role] = "guest"
|
201
202
|
virtualization[:systems][$1.to_sym] = "guest"
|
202
|
-
elsif /container=lxc/.match?(
|
203
|
+
elsif /container=lxc/.match?(file_read("/proc/1/environ"))
|
203
204
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
|
204
205
|
virtualization[:system] = "lxc"
|
205
206
|
virtualization[:role] = "guest"
|
206
207
|
virtualization[:systems][:lxc] = "guest"
|
207
|
-
elsif /container=systemd-nspawn/.match?(
|
208
|
+
elsif /container=systemd-nspawn/.match?(file_read("/proc/1/environ"))
|
208
209
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
|
209
210
|
virtualization[:system] = "nspawn"
|
210
211
|
virtualization[:role] = "guest"
|
211
212
|
virtualization[:systems][:nspawn] = "guest"
|
212
|
-
elsif lxc_version_exists? &&
|
213
|
+
elsif lxc_version_exists? && file_read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
|
213
214
|
# lxc-version shouldn't be installed by default
|
214
215
|
# Even so, it is likely we are on an LXC capable host that is not being used as such
|
215
216
|
# So we're cautious here to not overwrite other existing values (OHAI-573)
|
@@ -224,7 +225,7 @@ Ohai.plugin(:Virtualization) do
|
|
224
225
|
# If so, we may need to look further for a differentiator (OHAI-573)
|
225
226
|
virtualization[:systems][:lxc] = "host"
|
226
227
|
end
|
227
|
-
elsif
|
228
|
+
elsif file_exist?("/.dockerenv") || file_exist?("/.dockerinit")
|
228
229
|
logger.trace("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
|
229
230
|
virtualization[:system] = "docker"
|
230
231
|
virtualization[:role] = "guest"
|
@@ -233,7 +234,7 @@ Ohai.plugin(:Virtualization) do
|
|
233
234
|
|
234
235
|
# Detect LXD
|
235
236
|
# See https://github.com/lxc/lxd/blob/master/doc/dev-lxd.md
|
236
|
-
if
|
237
|
+
if file_exist?("/dev/lxd/sock")
|
237
238
|
logger.trace("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
|
238
239
|
virtualization[:system] = "lxd"
|
239
240
|
virtualization[:role] = "guest"
|
@@ -248,7 +249,7 @@ Ohai.plugin(:Virtualization) do
|
|
248
249
|
# Snap based installations utilize '/var/snap/lxd/common/lxd/'
|
249
250
|
# - includes all future releases starting with 2.21, and will be the only source of 3.1+ feature releases post-bionic
|
250
251
|
["/var/lib/lxd/devlxd", "/var/snap/lxd/common/lxd/devlxd"].each do |devlxd|
|
251
|
-
if
|
252
|
+
if file_exist?(devlxd)
|
252
253
|
logger.trace("Plugin Virtualization: #{devlxd} exists. Detecting as lxd host")
|
253
254
|
virtualization[:system] = "lxd"
|
254
255
|
virtualization[:role] = "host"
|