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
data/lib/ohai/plugin_config.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Joshua Timberman <joshua@chef.io>
|
3
4
|
# Author:: Isa Farnik (<isa@chef.io>)
|
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");
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Joshua Timberman <joshua@chef.io>
|
3
4
|
# Author:: Isa Farnik (<isa@chef.io>)
|
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");
|
@@ -30,7 +31,7 @@ Ohai.plugin(:Memory) do
|
|
30
31
|
memory[:free] = "#{free_in_mb.to_i * 1024}kB"
|
31
32
|
|
32
33
|
swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
|
33
|
-
memory[:swap]["total"] = "#{
|
34
|
-
memory[:swap]["free"] = "#{
|
34
|
+
memory[:swap]["total"] = "#{swap_info[2].to_i * 4}kB"
|
35
|
+
memory[:swap]["free"] = "#{swap_info[10].to_i * 4}kB"
|
35
36
|
end
|
36
37
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
|
3
4
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
4
5
|
# Author:: Isa Farnik (<isa@chef.io>)
|
5
|
-
# Copyright:: Copyright (c)
|
6
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
7
|
# License:: Apache License, Version 2.0
|
7
8
|
#
|
8
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -92,7 +93,7 @@ Ohai.plugin(:Network) do
|
|
92
93
|
if lin =~ /broadcast\s(\S+)\s/
|
93
94
|
iface[interface][:addresses][tmp_addr][:broadcast] = $1
|
94
95
|
end
|
95
|
-
elsif lin =~ %r{inet6 ([a-f0-9\:]+)%?(
|
96
|
+
elsif lin =~ %r{inet6 ([a-f0-9\:]+)%?(\d*)/?(\d*)?}
|
96
97
|
# TODO do we have more properties on inet6 in aix? broadcast
|
97
98
|
iface[interface][:addresses] ||= Mash.new
|
98
99
|
iface[interface][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Joshua Timberman <joshua@chef.io>
|
3
4
|
# Author:: Isa Farnik (<isa@chef.io>)
|
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");
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
|
3
4
|
# Author:: Isa Farnik (<isa@chef.io>)
|
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");
|
@@ -40,9 +41,9 @@ Ohai.plugin(:Uptime) do
|
|
40
41
|
when /^\d+-\d/
|
41
42
|
(d, h, m, s) = so.split(/[-:]/)
|
42
43
|
when /^\d+:\d+:\d/
|
43
|
-
(h, m, s) = so.split(
|
44
|
+
(h, m, s) = so.split(":")
|
44
45
|
else
|
45
|
-
(m, s) = so.split(
|
46
|
+
(m, s) = so.split(":")
|
46
47
|
end
|
47
48
|
elapsed_seconds = ((d.to_i * 86400) + (h.to_i * 3600) + (m.to_i * 60) + s.to_i)
|
48
49
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Julian C. Dunn (<jdunn@chef.io>)
|
3
3
|
# Author:: Isa Farnik (<isa@chef.io>)
|
4
|
-
# Copyright:: Copyright (c)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
2
3
|
# License:: Apache License, Version 2.0
|
3
4
|
#
|
4
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -34,7 +35,7 @@ Ohai.plugin(:Azure) do
|
|
34
35
|
azure Mash.new
|
35
36
|
azure_metadata_from_hints.each { |k, v| azure[k] = v }
|
36
37
|
azure["metadata"] = parse_metadata
|
37
|
-
elsif has_waagent? || has_dhcp_option_245?
|
38
|
+
elsif has_waagent? || has_dhcp_option_245? || has_reddog_dhcp_domain?
|
38
39
|
logger.trace("Plugin Azure: No hints present, but system appears to be on Azure.")
|
39
40
|
azure Mash.new
|
40
41
|
azure["metadata"] = parse_metadata
|
@@ -47,7 +48,7 @@ Ohai.plugin(:Azure) do
|
|
47
48
|
# check for either the waagent or the unknown-245 DHCP option that Azure uses
|
48
49
|
# http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/
|
49
50
|
def has_waagent?
|
50
|
-
if
|
51
|
+
if file_exist?("/usr/sbin/waagent") || dir_exist?('C:\WindowsAzure')
|
51
52
|
logger.trace("Plugin Azure: Found waagent used by Azure.")
|
52
53
|
true
|
53
54
|
end
|
@@ -55,8 +56,8 @@ Ohai.plugin(:Azure) do
|
|
55
56
|
|
56
57
|
def has_dhcp_option_245?
|
57
58
|
has_245 = false
|
58
|
-
if
|
59
|
-
|
59
|
+
if file_exist?("/var/lib/dhcp/dhclient.eth0.leases")
|
60
|
+
file_open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
|
60
61
|
if /unknown-245/.match?(line)
|
61
62
|
logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
|
62
63
|
has_245 = true
|
@@ -67,6 +68,26 @@ Ohai.plugin(:Azure) do
|
|
67
68
|
has_245
|
68
69
|
end
|
69
70
|
|
71
|
+
def has_reddog_dhcp_domain?
|
72
|
+
tcp_ip_dhcp_domain == "reddog.microsoft.com"
|
73
|
+
end
|
74
|
+
|
75
|
+
def tcp_ip_dhcp_domain
|
76
|
+
return unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
77
|
+
|
78
|
+
require "win32/registry" unless defined?(Win32::Registry)
|
79
|
+
|
80
|
+
begin
|
81
|
+
key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters")
|
82
|
+
dhcp_domain = key["DhcpDomain"]
|
83
|
+
Ohai::Log.trace("Plugin Azure: DhcpDomain registry value is #{dhcp_domain}")
|
84
|
+
rescue Win32::Registry::Error
|
85
|
+
Ohai::Log.trace("Plugin Azure: DhcpDomain registry value cannot be found")
|
86
|
+
end
|
87
|
+
|
88
|
+
dhcp_domain
|
89
|
+
end
|
90
|
+
|
70
91
|
# create the basic structure we'll store our data in
|
71
92
|
def initialize_metadata_mash_compute
|
72
93
|
metadata = Mash.new
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
4
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
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");
|
@@ -49,7 +50,7 @@ Ohai.plugin(:Virtualization) do
|
|
49
50
|
end
|
50
51
|
|
51
52
|
# detect from modules
|
52
|
-
so = shell_out(
|
53
|
+
so = shell_out(Ohai.abs_path("/sbin/kldstat").to_s)
|
53
54
|
so.stdout.lines do |line|
|
54
55
|
case line
|
55
56
|
when /vboxdrv/
|
@@ -66,7 +67,7 @@ Ohai.plugin(:Virtualization) do
|
|
66
67
|
end
|
67
68
|
|
68
69
|
# Detect bhyve by presence of /dev/vmm
|
69
|
-
if
|
70
|
+
if file_exist?("/dev/vmm")
|
70
71
|
virtualization[:system] = "bhyve"
|
71
72
|
virtualization[:role] = "host"
|
72
73
|
virtualization[:systems][:bhyve] = "host"
|
data/lib/ohai/plugins/c.rb
CHANGED
data/lib/ohai/plugins/chef.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tollef Fog Heen <tfheen@err.no>
|
3
4
|
# Copyright:: Copyright (c) 2010 Tollef Fog Heen
|
@@ -19,7 +20,7 @@
|
|
19
20
|
Ohai.plugin(:Chef) do
|
20
21
|
provides "chef_packages/chef"
|
21
22
|
|
22
|
-
collect_data do
|
23
|
+
collect_data(:default, :target) do
|
23
24
|
begin
|
24
25
|
require "chef/version"
|
25
26
|
rescue Gem::LoadError
|
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Cary Penniman (<cary@rightscale.com>)
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -100,7 +101,7 @@ Ohai.plugin(:Cloud) do
|
|
100
101
|
@cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs]
|
101
102
|
|
102
103
|
# if empty, return nil
|
103
|
-
|
104
|
+
@cloud.empty? ? nil : @cloud
|
104
105
|
end
|
105
106
|
|
106
107
|
private
|
data/lib/ohai/plugins/command.rb
CHANGED
@@ -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");
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
@@ -8,7 +9,7 @@
|
|
8
9
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
9
10
|
# Author:: Isa Farnik (<isa@chef.io>)
|
10
11
|
# Author:: Doug MacEachern <dougm@vmware.com>
|
11
|
-
# Copyright:: Copyright (c)
|
12
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
12
13
|
# License:: Apache License, Version 2.0
|
13
14
|
#
|
14
15
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -30,16 +31,14 @@ Ohai.plugin(:CPU) do
|
|
30
31
|
def parse_bsd_dmesg(&block)
|
31
32
|
cpuinfo = Mash.new
|
32
33
|
cpuinfo["flags"] = []
|
33
|
-
|
34
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
34
35
|
case line
|
35
36
|
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
36
37
|
cpuinfo["model_name"] = $1
|
37
38
|
cpuinfo["mhz"] = $2
|
38
|
-
when /Features=.+<(.+)>/
|
39
|
+
when /Features=.+<(.+)>/, /Features2=[a-f\dx]+<(.+)>/
|
39
40
|
cpuinfo["flags"].concat($1.downcase.split(","))
|
40
41
|
# Features2=0x80000001<SSE3,<b31>>
|
41
|
-
when /Features2=[a-f\dx]+<(.+)>/
|
42
|
-
cpuinfo["flags"].concat($1.downcase.split(","))
|
43
42
|
else
|
44
43
|
yield(cpuinfo, line)
|
45
44
|
end
|
@@ -53,7 +52,7 @@ Ohai.plugin(:CPU) do
|
|
53
52
|
cpu_number = 0
|
54
53
|
current_cpu = nil
|
55
54
|
|
56
|
-
|
55
|
+
file_open("/proc/cpuinfo").each do |line|
|
57
56
|
case line
|
58
57
|
when /processor\s+:\s(.+)/
|
59
58
|
cpuinfo[$1] = Mash.new
|
@@ -61,7 +60,7 @@ Ohai.plugin(:CPU) do
|
|
61
60
|
cpu_number += 1
|
62
61
|
when /vendor_id\s+:\s(.+)/
|
63
62
|
vendor_id = $1
|
64
|
-
if vendor_id
|
63
|
+
if vendor_id.include?("IBM/S390")
|
65
64
|
cpuinfo["vendor_id"] = vendor_id
|
66
65
|
else
|
67
66
|
cpuinfo[current_cpu]["vendor_id"] = vendor_id
|
@@ -212,7 +211,7 @@ Ohai.plugin(:CPU) do
|
|
212
211
|
# to scrape from dmesg.boot is the cpu feature list.
|
213
212
|
# cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
|
214
213
|
|
215
|
-
|
214
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
216
215
|
case line
|
217
216
|
when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
|
218
217
|
cpuinfo["flags"] = $1.downcase.split(",")
|
@@ -235,7 +234,7 @@ Ohai.plugin(:CPU) do
|
|
235
234
|
# available instruction set
|
236
235
|
# cpu0 at mainbus0 apid 0: Intel 686-class, 2134MHz, id 0x6f6
|
237
236
|
|
238
|
-
|
237
|
+
file_open("/var/run/dmesg.boot").each do |line|
|
239
238
|
case line
|
240
239
|
when /cpu[\d\w\s]+:\s([\w\s\-]+),\s+(\w+),/
|
241
240
|
cpuinfo[:model_name] = $1
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Patrick Collins (<pat@burned.com>)
|
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,7 @@ Ohai.plugin(:Memory) do
|
|
43
44
|
megabyte_val = (pages * page_size) / 1024 / 1024.0
|
44
45
|
total_consumed += megabyte_val
|
45
46
|
case match
|
46
|
-
when "wired down"
|
47
|
-
active += megabyte_val.to_i
|
48
|
-
when "active"
|
47
|
+
when "wired down", "active"
|
49
48
|
active += megabyte_val.to_i
|
50
49
|
when "inactive"
|
51
50
|
inactive += megabyte_val.to_i
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Benjamin Black (<bb@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");
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) Chef Software
|
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");
|
@@ -20,7 +21,7 @@ Ohai.plugin(:Platform) do
|
|
20
21
|
provides "platform", "platform_version", "platform_build", "platform_family"
|
21
22
|
|
22
23
|
collect_data(:darwin) do
|
23
|
-
so = shell_out(
|
24
|
+
so = shell_out(Ohai.abs_path( "/usr/bin/sw_vers" ).to_s)
|
24
25
|
so.stdout.lines do |line|
|
25
26
|
case line
|
26
27
|
when /^ProductVersion:\s+(.+)$/
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Pavel Yudin (<pyudin@parallels.com>)
|
3
4
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
5
|
# Copyright:: Copyright (c) 2015 Pavel Yudin
|
5
|
-
# Copyright:: Copyright (c)
|
6
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
6
7
|
# License:: Apache License, Version 2.0
|
7
8
|
#
|
8
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -35,7 +36,7 @@ Ohai.plugin(:Virtualization) do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def fusion_exists?
|
38
|
-
|
39
|
+
file_exist?("/Applications/VMware\ Fusion.app/")
|
39
40
|
end
|
40
41
|
|
41
42
|
def docker_exists?
|
data/lib/ohai/plugins/dmi.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Kurt Yoder (ktyopscode@yoderhome.com)
|
3
4
|
# Copyright:: Copyright (c) 2010 Kurt Yoder
|
@@ -76,7 +77,7 @@ Ohai.plugin(:DMI) do
|
|
76
77
|
dmi[:table_location] = table_location[1]
|
77
78
|
|
78
79
|
elsif ( handle = handle_line.match(line) )
|
79
|
-
unless Ohai::Common::DMI.
|
80
|
+
unless Ohai::Common::DMI.allowlisted_ids.include?(handle[2].to_i)
|
80
81
|
dmi_record = nil
|
81
82
|
next
|
82
83
|
end
|
data/lib/ohai/plugins/docker.rb
CHANGED
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
4
|
# Author:: Benjamin Black (<bb@chef.io>)
|
4
5
|
# Author:: Christopher Brown (<cb@chef.io>)
|
5
6
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
6
|
-
# Copyright:: Copyright (c)
|
7
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
7
8
|
# License:: Apache License, Version 2.0
|
8
9
|
#
|
9
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -97,8 +98,8 @@ Ohai.plugin(:EC2) do
|
|
97
98
|
# @param path[String] abs path to the file
|
98
99
|
# @return [String] contents of the file if it exists
|
99
100
|
def file_val_if_exists(path)
|
100
|
-
if
|
101
|
-
|
101
|
+
if file_exist?(path)
|
102
|
+
file_read(path)
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
@@ -114,7 +115,7 @@ Ohai.plugin(:EC2) do
|
|
114
115
|
end
|
115
116
|
|
116
117
|
collect_data do
|
117
|
-
require "base64"
|
118
|
+
require "base64" unless defined?(Base64)
|
118
119
|
|
119
120
|
if looks_like_ec2?
|
120
121
|
logger.trace("Plugin EC2: looks_like_ec2? == true")
|
@@ -122,11 +123,17 @@ Ohai.plugin(:EC2) do
|
|
122
123
|
fetch_metadata.each do |k, v|
|
123
124
|
# fetch_metadata returns IAM security credentials, including the IAM user's
|
124
125
|
# secret access key. We'd rather not have ohai send this information
|
125
|
-
# to the server.
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
# to the server. If the instance is associated with an IAM role we grab
|
127
|
+
# only the "info" key and the IAM role name.
|
128
|
+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
|
129
|
+
if k == "iam" && !hint?("iam")
|
130
|
+
ec2[:iam] = v.select { |key, value| key == "info" }
|
131
|
+
if v["security-credentials"] && v["security-credentials"].keys.length == 1
|
132
|
+
ec2[:iam]["role_name"] = v["security-credentials"].keys[0]
|
133
|
+
end
|
134
|
+
else
|
135
|
+
ec2[k] = v
|
136
|
+
end
|
130
137
|
end
|
131
138
|
ec2[:userdata] = fetch_userdata
|
132
139
|
ec2[:account_id] = fetch_dynamic_data["accountId"]
|