ohai 16.1.1 → 16.3.2
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 +4 -4
- data/Gemfile +1 -1
- data/bin/ohai +0 -2
- data/lib/ohai/dsl/plugin.rb +1 -1
- data/lib/ohai/mixin/command.rb +1 -1
- data/lib/ohai/mixin/dmi_decode.rb +2 -2
- data/lib/ohai/plugins/aix/memory.rb +3 -3
- data/lib/ohai/plugins/aix/uptime.rb +1 -1
- data/lib/ohai/plugins/aix/virtualization.rb +5 -5
- data/lib/ohai/plugins/azure.rb +1 -1
- data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
- data/lib/ohai/plugins/c.rb +2 -2
- data/lib/ohai/plugins/cpu.rb +1 -1
- data/lib/ohai/plugins/darwin/hardware.rb +2 -2
- data/lib/ohai/plugins/darwin/network.rb +3 -3
- data/lib/ohai/plugins/darwin/platform.rb +3 -6
- data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +5 -5
- data/lib/ohai/plugins/eucalyptus.rb +1 -1
- data/lib/ohai/plugins/filesystem.rb +4 -4
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +12 -12
- data/lib/ohai/plugins/kernel.rb +8 -7
- data/lib/ohai/plugins/linux/interrupts.rb +1 -1
- data/lib/ohai/plugins/linux/mdadm.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +8 -6
- data/lib/ohai/plugins/linux/platform.rb +8 -8
- data/lib/ohai/plugins/linux/virtualization.rb +12 -9
- data/lib/ohai/plugins/network.rb +1 -1
- data/lib/ohai/plugins/openstack.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +2 -2
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +1 -1
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/network.rb +2 -2
- data/lib/ohai/plugins/windows/platform.rb +1 -1
- data/lib/ohai/provides_map.rb +2 -2
- data/lib/ohai/util/win32.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7be1477adf0e463ac6149e5e3bb02ea983b8ea39197a84baf414472071b9f829
|
4
|
+
data.tar.gz: a928b3b5b11a6230bed0a235cd06210c1d98c1c08f347d85390270d02123cdd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4033840091985804ad19aab09e79c516e2811149f4165d3b904cb497743e552757bf32b0d32f574c2451866f8267bf451c12f8f993677b509c7ab71d0446c9dd
|
7
|
+
data.tar.gz: 4b889129b7d4838410f936182615ef4b071ca4edd53fbfd8a374a349f39d6a2e6e842499167fd39aa5ae38b5bd7ebf2d64d25b6564c5fbf8dbbc4b16b40d91c3
|
data/Gemfile
CHANGED
data/bin/ohai
CHANGED
data/lib/ohai/dsl/plugin.rb
CHANGED
data/lib/ohai/mixin/command.rb
CHANGED
@@ -30,7 +30,7 @@ module Ohai
|
|
30
30
|
options = options.dup
|
31
31
|
# unless specified by the caller timeout after configured timeout (default 30 seconds)
|
32
32
|
options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout]
|
33
|
-
unless RUBY_PLATFORM
|
33
|
+
unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
34
34
|
options[:env] = options.key?(:env) ? options[:env].dup : {}
|
35
35
|
options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
|
36
36
|
end
|
@@ -26,7 +26,7 @@ module ::Ohai::Mixin::DmiDecode
|
|
26
26
|
when /VMware/
|
27
27
|
return "vmware"
|
28
28
|
when /Microsoft/
|
29
|
-
return "hyperv" if
|
29
|
+
return "hyperv" if /Virtual Machine/.match?(product)
|
30
30
|
when /Amazon EC2/
|
31
31
|
return "amazonec2"
|
32
32
|
when /QEMU/
|
@@ -40,7 +40,7 @@ module ::Ohai::Mixin::DmiDecode
|
|
40
40
|
case product
|
41
41
|
when /VirtualBox/
|
42
42
|
return "vbox"
|
43
|
-
when /OpenStack/ # yes this is here twice. Product catches
|
43
|
+
when /OpenStack/ # yes this is here twice. Product catches Red Hat's version
|
44
44
|
return "openstack"
|
45
45
|
when /(KVM|RHEV)/
|
46
46
|
return "kvm"
|
@@ -29,8 +29,8 @@ Ohai.plugin(:Memory) do
|
|
29
29
|
memory[:total] = "#{total_in_mb.to_i * 1024}kB"
|
30
30
|
memory[:free] = "#{free_in_mb.to_i * 1024}kB"
|
31
31
|
|
32
|
-
|
33
|
-
memory[:swap]["total"] = "#{(
|
34
|
-
memory[:swap]["free"] = "#{(
|
32
|
+
swap_info = shell_out("swap -s").stdout.split # returns swap info in 4K blocks
|
33
|
+
memory[:swap]["total"] = "#{(swap_info[2].to_i) * 4}kB"
|
34
|
+
memory[:swap]["free"] = "#{(swap_info[10].to_i) * 4}kB"
|
35
35
|
end
|
36
36
|
end
|
@@ -30,7 +30,7 @@ Ohai.plugin(:Uptime) do
|
|
30
30
|
so = shell_out("LC_ALL=POSIX ps -o etime= -p 1").stdout.strip
|
31
31
|
|
32
32
|
# Here we'll check our shell_out for a dash, which indicates there is a # of days involved
|
33
|
-
# We'll chunk off the days, hours (where applicable), minutes, seconds into
|
33
|
+
# We'll chunk off the days, hours (where applicable), minutes, seconds into separate vars
|
34
34
|
# We also need to do this because ps -o etime= will not display days if the machine has been up for less than 24 hours
|
35
35
|
# If the machine has been up for less than one hour, the shell_out will not output hours hence our else
|
36
36
|
# see here: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.cmds4/ps.htm#ps__row-d3e109655
|
@@ -57,7 +57,7 @@ Ohai.plugin(:Virtualization) do
|
|
57
57
|
sections.each do |line|
|
58
58
|
case title
|
59
59
|
when "network"
|
60
|
-
next if
|
60
|
+
next if /^Interface|^---/.match?(line)
|
61
61
|
|
62
62
|
splat = line.strip.split
|
63
63
|
key = splat[0].downcase
|
@@ -68,7 +68,7 @@ Ohai.plugin(:Virtualization) do
|
|
68
68
|
}
|
69
69
|
wpars[wpar_name][title][key] = value
|
70
70
|
when "user-specified routes"
|
71
|
-
next if
|
71
|
+
next if /^Type|^---/.match?(line)
|
72
72
|
|
73
73
|
splat = line.strip.split
|
74
74
|
key = splat[2].downcase
|
@@ -78,7 +78,7 @@ Ohai.plugin(:Virtualization) do
|
|
78
78
|
}
|
79
79
|
wpars[wpar_name][title][key] = value
|
80
80
|
when "file systems"
|
81
|
-
next if
|
81
|
+
next if /^MountPoint|^---/.match?(line)
|
82
82
|
|
83
83
|
splat = line.strip.split
|
84
84
|
key = splat[1].downcase
|
@@ -93,7 +93,7 @@ Ohai.plugin(:Virtualization) do
|
|
93
93
|
privileges ||= ""
|
94
94
|
wpars[wpar_name][title]["Privileges"] ||= []
|
95
95
|
|
96
|
-
if
|
96
|
+
if /^Privileges/.match?(line)
|
97
97
|
privileges << line.split(":")[1].strip
|
98
98
|
else
|
99
99
|
privileges << line.strip
|
@@ -101,7 +101,7 @@ Ohai.plugin(:Virtualization) do
|
|
101
101
|
|
102
102
|
wpars[wpar_name][title]["Privileges"] += privileges.split(",")
|
103
103
|
when "device exports"
|
104
|
-
next if
|
104
|
+
next if /^Name|^---/.match?(line)
|
105
105
|
|
106
106
|
splat = line.strip.split
|
107
107
|
key = splat[0].downcase
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -57,7 +57,7 @@ Ohai.plugin(:Azure) do
|
|
57
57
|
has_245 = false
|
58
58
|
if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
|
59
59
|
File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
|
60
|
-
if
|
60
|
+
if /unknown-245/.match?(line)
|
61
61
|
logger.trace("Plugin Azure: Found unknown-245 DHCP option used by Azure.")
|
62
62
|
has_245 = true
|
63
63
|
break
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Virtualization) do
|
|
76
76
|
# Detect KVM/QEMU paravirt guests from cpu, report as KVM
|
77
77
|
# hw.model: QEMU Virtual CPU version 0.9.1
|
78
78
|
so = shell_out("sysctl -n hw.model")
|
79
|
-
if
|
79
|
+
if /QEMU Virtual CPU|KVM processor/.match?(so.stdout)
|
80
80
|
virtualization[:system] = "kvm"
|
81
81
|
virtualization[:role] = "guest"
|
82
82
|
virtualization[:systems][:kvm] = "guest"
|
@@ -96,7 +96,7 @@ Ohai.plugin(:Virtualization) do
|
|
96
96
|
"xen"
|
97
97
|
when /kvm/
|
98
98
|
so = shell_out("sysctl -n kern.hostuuid")
|
99
|
-
so.stdout
|
99
|
+
/^ec2/.match?(so.stdout) ? "amazonec2" : "kvm"
|
100
100
|
when /bhyve/
|
101
101
|
"bhyve"
|
102
102
|
end
|
data/lib/ohai/plugins/c.rb
CHANGED
@@ -137,7 +137,7 @@ Ohai.plugin(:C) do
|
|
137
137
|
logger.trace("Plugin C: 'xlc' binary could not be found. Skipping data.")
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
140
|
+
def collect_sun_pro
|
141
141
|
# sun pro
|
142
142
|
collect("cc -V -flags") do |so|
|
143
143
|
output = so.stderr.split
|
@@ -173,7 +173,7 @@ Ohai.plugin(:C) do
|
|
173
173
|
@c = Mash.new
|
174
174
|
collect_gcc
|
175
175
|
collect_glibc
|
176
|
-
|
176
|
+
collect_sun_pro
|
177
177
|
languages[:c] = @c unless @c.empty?
|
178
178
|
end
|
179
179
|
end
|
data/lib/ohai/plugins/cpu.rb
CHANGED
@@ -305,7 +305,7 @@ Ohai.plugin(:CPU) do
|
|
305
305
|
cpu[index] = Mash.new
|
306
306
|
cpu[index][:status] = status
|
307
307
|
cpu[index][:location] = location
|
308
|
-
if
|
308
|
+
if /Available/.match?(status)
|
309
309
|
cpu[:available] += 1
|
310
310
|
lsattr = shell_out("lsattr -El #{name}").stdout.lines
|
311
311
|
lsattr.each do |attribute|
|
@@ -41,8 +41,8 @@ Ohai.plugin(:Hardware) do
|
|
41
41
|
hardware.merge!(hw_hash[0]["_items"][0])
|
42
42
|
|
43
43
|
# ProductName: Mac OS X
|
44
|
-
# ProductVersion: 10.
|
45
|
-
# BuildVersion:
|
44
|
+
# ProductVersion: 10.15.6
|
45
|
+
# BuildVersion: 19G46c
|
46
46
|
shell_out("sw_vers").stdout.lines.each do |line|
|
47
47
|
case line
|
48
48
|
when /^ProductName:\s*(.*)$/
|
@@ -66,8 +66,8 @@ Ohai.plugin(:Network) do
|
|
66
66
|
|
67
67
|
def scope_lookup(scope)
|
68
68
|
return "Node" if scope.eql?("::1")
|
69
|
-
return "Link" if
|
70
|
-
return "Site" if
|
69
|
+
return "Link" if /^fe80\:/.match?(scope)
|
70
|
+
return "Site" if /^fec0\:/.match?(scope)
|
71
71
|
|
72
72
|
"Global"
|
73
73
|
end
|
@@ -79,7 +79,7 @@ Ohai.plugin(:Network) do
|
|
79
79
|
def locate_interface(ifaces, ifname, mac)
|
80
80
|
return ifname unless ifaces[ifname].nil?
|
81
81
|
# oh well, time to go hunting!
|
82
|
-
return ifname.chop if ifname
|
82
|
+
return ifname.chop if /\*$/.match?(ifname)
|
83
83
|
|
84
84
|
ifaces.each_key do |ifc|
|
85
85
|
ifaces[ifc][:addresses].each_key do |addr|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -23,11 +23,6 @@ Ohai.plugin(:Platform) do
|
|
23
23
|
so = shell_out((Ohai.abs_path( "/usr/bin/sw_vers" )).to_s)
|
24
24
|
so.stdout.lines do |line|
|
25
25
|
case line
|
26
|
-
when /^ProductName:\s+(.+)$/
|
27
|
-
macname = $1
|
28
|
-
macname.downcase!
|
29
|
-
macname.tr!(" ", "_")
|
30
|
-
platform macname
|
31
26
|
when /^ProductVersion:\s+(.+)$/
|
32
27
|
platform_version $1
|
33
28
|
when /^BuildVersion:\s+(.+)$/
|
@@ -35,6 +30,8 @@ Ohai.plugin(:Platform) do
|
|
35
30
|
end
|
36
31
|
end
|
37
32
|
|
33
|
+
# if we're on darwin assume we're on mac_os_x
|
34
|
+
platform "mac_os_x"
|
38
35
|
platform_family "mac_os_x"
|
39
36
|
end
|
40
37
|
end
|
@@ -82,7 +82,7 @@ Ohai.plugin(:Virtualization) do
|
|
82
82
|
virtualization[:systems][:parallels] = "host"
|
83
83
|
elsif ioreg_exists?
|
84
84
|
so = shell_out("ioreg -l")
|
85
|
-
if
|
85
|
+
if /pci1ab8,4000/.match?(so.stdout)
|
86
86
|
virtualization[:system] = "parallels"
|
87
87
|
virtualization[:role] = "guest"
|
88
88
|
virtualization[:systems][:parallels] = "guest"
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -41,7 +41,7 @@ Ohai.plugin(:EC2) do
|
|
41
41
|
# @return [Boolean] do we have Amazon DMI data?
|
42
42
|
def has_ec2_amazon_dmi?
|
43
43
|
# detect a version of '4.2.amazon'
|
44
|
-
if file_val_if_exists("/sys/class/dmi/id/bios_vendor")
|
44
|
+
if /Amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_vendor"))
|
45
45
|
logger.trace("Plugin EC2: has_ec2_amazon_dmi? == true")
|
46
46
|
true
|
47
47
|
else
|
@@ -56,7 +56,7 @@ Ohai.plugin(:EC2) do
|
|
56
56
|
# @return [Boolean] do we have Amazon DMI data?
|
57
57
|
def has_ec2_xen_dmi?
|
58
58
|
# detect a version of '4.2.amazon'
|
59
|
-
if file_val_if_exists("/sys/class/dmi/id/bios_version")
|
59
|
+
if /amazon/.match?(file_val_if_exists("/sys/class/dmi/id/bios_version"))
|
60
60
|
logger.trace("Plugin EC2: has_ec2_xen_dmi? == true")
|
61
61
|
true
|
62
62
|
else
|
@@ -68,7 +68,7 @@ Ohai.plugin(:EC2) do
|
|
68
68
|
# looks for a xen UUID that starts with ec2 from within the Linux sys tree
|
69
69
|
# @return [Boolean] do we have a Xen UUID or not?
|
70
70
|
def has_ec2_xen_uuid?
|
71
|
-
if file_val_if_exists("/sys/hypervisor/uuid")
|
71
|
+
if /^ec2/.match?(file_val_if_exists("/sys/hypervisor/uuid"))
|
72
72
|
logger.trace("Plugin EC2: has_ec2_xen_uuid? == true")
|
73
73
|
return true
|
74
74
|
end
|
@@ -81,10 +81,10 @@ Ohai.plugin(:EC2) do
|
|
81
81
|
# linux hosts
|
82
82
|
# @return [Boolean] do we have a Xen Identifying Number or not?
|
83
83
|
def has_ec2_identifying_number?
|
84
|
-
if RUBY_PLATFORM
|
84
|
+
if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
85
85
|
require "wmi-lite/wmi"
|
86
86
|
wmi = WmiLite::Wmi.new
|
87
|
-
if wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"]
|
87
|
+
if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"])
|
88
88
|
logger.trace("Plugin EC2: has_ec2_identifying_number? == true")
|
89
89
|
true
|
90
90
|
end
|
@@ -42,7 +42,7 @@ Ohai.plugin(:Eucalyptus) do
|
|
42
42
|
def has_euca_mac?
|
43
43
|
network[:interfaces].each_value do |iface|
|
44
44
|
mac = get_mac_address(iface[:addresses])
|
45
|
-
if
|
45
|
+
if /^[dD]0:0[dD]:/.match?(mac)
|
46
46
|
logger.trace("Plugin Eucalyptus: has_euca_mac? == true (#{mac})")
|
47
47
|
return true
|
48
48
|
end
|
@@ -590,16 +590,16 @@ Ohai.plugin(:Filesystem) do
|
|
590
590
|
end
|
591
591
|
end
|
592
592
|
|
593
|
-
zfs.each do |
|
593
|
+
zfs.each do |fs_name, attributes|
|
594
594
|
mountpoint = attributes[:mountpoint][:value] if attributes[:mountpoint]
|
595
|
-
key = "#{
|
595
|
+
key = "#{fs_name},#{mountpoint}"
|
596
596
|
fs[key] ||= Mash.new
|
597
597
|
fs[key][:fs_type] = "zfs"
|
598
598
|
fs[key][:mount] = mountpoint if mountpoint
|
599
|
-
fs[key][:device] =
|
599
|
+
fs[key][:device] = fs_name
|
600
600
|
fs[key][:zfs_properties] = attributes
|
601
601
|
# find all zfs parents
|
602
|
-
parents =
|
602
|
+
parents = fs_name.split("/")
|
603
603
|
zfs_parents = []
|
604
604
|
(0..parents.length - 1).to_a.each do |parent_index|
|
605
605
|
next_parent = parents[0..parent_index].join("/")
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -27,7 +27,7 @@ Ohai.plugin(:GCE) do
|
|
27
27
|
# this works even if the system lacks dmidecode use by the Dmi plugin
|
28
28
|
# @return [Boolean] do we have Google Compute Engine DMI data?
|
29
29
|
def has_gce_dmi?
|
30
|
-
if file_val_if_exists("/sys/class/dmi/id/product_name")
|
30
|
+
if /Google Compute Engine/.match?(file_val_if_exists("/sys/class/dmi/id/product_name"))
|
31
31
|
logger.trace("Plugin GCE: has_gce_dmi? == true")
|
32
32
|
true
|
33
33
|
else
|
@@ -48,7 +48,7 @@ Ohai.plugin(:GCE) do
|
|
48
48
|
# looks at the Manufacturer and Model WMI values to see if they starts with Google.
|
49
49
|
# @return [Boolean] Are the manufacturer and model Google?
|
50
50
|
def has_gce_system_info?
|
51
|
-
if RUBY_PLATFORM
|
51
|
+
if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
52
52
|
require "wmi-lite/wmi"
|
53
53
|
wmi = WmiLite::Wmi.new
|
54
54
|
computer_system = wmi.first_of("Win32_ComputerSystem")
|
@@ -99,19 +99,19 @@ Ohai.plugin(:Hostname) do
|
|
99
99
|
hostname from_cmd("hostname -s")
|
100
100
|
machinename from_cmd("hostname")
|
101
101
|
begin
|
102
|
-
|
102
|
+
our_fqdn = resolve_fqdn
|
103
103
|
# Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
|
104
104
|
# returns a blank string. WTF.
|
105
|
-
if
|
105
|
+
if our_fqdn.nil? || our_fqdn.empty?
|
106
106
|
logger.trace("Plugin Hostname: hostname returned an empty string, retrying once.")
|
107
|
-
|
107
|
+
our_fqdn = resolve_fqdn
|
108
108
|
end
|
109
109
|
|
110
|
-
if
|
110
|
+
if our_fqdn.nil? || our_fqdn.empty?
|
111
111
|
logger.trace("Plugin Hostname: hostname returned an empty string twice and will" +
|
112
112
|
"not be set.")
|
113
113
|
else
|
114
|
-
fqdn
|
114
|
+
fqdn our_fqdn
|
115
115
|
end
|
116
116
|
rescue
|
117
117
|
logger.trace(
|
@@ -132,20 +132,20 @@ Ohai.plugin(:Hostname) do
|
|
132
132
|
hostname from_cmd("hostname -s")
|
133
133
|
machinename from_cmd("hostname")
|
134
134
|
begin
|
135
|
-
|
135
|
+
our_fqdn = from_cmd("hostname --fqdn")
|
136
136
|
# Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
|
137
137
|
# returns a blank string. WTF.
|
138
|
-
if
|
138
|
+
if our_fqdn.nil? || our_fqdn.empty?
|
139
139
|
logger.trace("Plugin Hostname: hostname --fqdn returned an empty string, retrying " +
|
140
140
|
"once.")
|
141
|
-
|
141
|
+
our_fqdn = from_cmd("hostname --fqdn")
|
142
142
|
end
|
143
143
|
|
144
|
-
if
|
144
|
+
if our_fqdn.nil? || our_fqdn.empty?
|
145
145
|
logger.trace("Plugin Hostname: hostname --fqdn returned an empty string twice and " +
|
146
146
|
"will not be set.")
|
147
147
|
else
|
148
|
-
fqdn
|
148
|
+
fqdn our_fqdn
|
149
149
|
end
|
150
150
|
rescue
|
151
151
|
logger.trace("Plugin Hostname: hostname --fqdn returned an error, probably no domain set")
|
@@ -171,14 +171,14 @@ Ohai.plugin(:Hostname) do
|
|
171
171
|
machinename host["name"].to_s
|
172
172
|
|
173
173
|
info = Socket.gethostbyname(Socket.gethostname)
|
174
|
-
if
|
174
|
+
if /.+?\.(.*)/.match?(info.first)
|
175
175
|
fqdn info.first
|
176
176
|
else
|
177
177
|
# host is not in dns. optionally use:
|
178
178
|
# C:\WINDOWS\system32\drivers\etc\hosts
|
179
179
|
info[3..info.length].reverse_each do |addr|
|
180
180
|
hostent = Socket.gethostbyaddr(addr)
|
181
|
-
if
|
181
|
+
if /.+?\.(.*)/.match?(hostent.first)
|
182
182
|
fqdn hostent.first
|
183
183
|
break
|
184
184
|
end
|
data/lib/ohai/plugins/kernel.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: Bryan McLellan (<btm@loftninjas.org>)
|
5
5
|
# Author:: Claire McQuin (<claire@chef.io>)
|
6
6
|
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
7
|
-
# Copyright:: Copyright (c)
|
7
|
+
# Copyright:: Copyright (c) Chef Software, Inc.
|
8
8
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
9
9
|
# License:: Apache License, Version 2.0
|
10
10
|
#
|
@@ -137,11 +137,12 @@ Ohai.plugin(:Kernel) do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
# see if a WMI name is
|
141
|
-
# useless data to ohai
|
140
|
+
# see if a WMI name is in the blocked list so we can avoid writing
|
141
|
+
# out useless data to ohai
|
142
|
+
#
|
142
143
|
# @param [String] name the wmi name to check
|
143
|
-
# @return [Boolean] is the wmi name
|
144
|
-
def
|
144
|
+
# @return [Boolean] is the wmi name in the blocked list
|
145
|
+
def blocked_wmi_name?(name)
|
145
146
|
[
|
146
147
|
"creation_class_name", # this is just the wmi name
|
147
148
|
"cs_creation_class_name", # this is just the wmi name
|
@@ -262,7 +263,7 @@ Ohai.plugin(:Kernel) do
|
|
262
263
|
host = wmi.first_of("Win32_OperatingSystem")
|
263
264
|
kernel[:os_info] = Mash.new
|
264
265
|
host.wmi_ole_object.properties_.each do |p|
|
265
|
-
next if
|
266
|
+
next if blocked_wmi_name?(p.name.wmi_underscore)
|
266
267
|
|
267
268
|
kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
268
269
|
end
|
@@ -277,7 +278,7 @@ Ohai.plugin(:Kernel) do
|
|
277
278
|
kernel[:cs_info] = Mash.new
|
278
279
|
host = wmi.first_of("Win32_ComputerSystem")
|
279
280
|
host.wmi_ole_object.properties_.each do |p|
|
280
|
-
next if
|
281
|
+
next if blocked_wmi_name?(p.name.wmi_underscore)
|
281
282
|
|
282
283
|
kernel[:cs_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase]
|
283
284
|
end
|
@@ -65,7 +65,7 @@ Ohai.plugin(:Interrupts) do
|
|
65
65
|
interrupts[:irq][irqn][:events_by_cpu][cpu] = fields[cpu].to_i
|
66
66
|
end
|
67
67
|
# Only regular IRQs have extra fields and affinity settings
|
68
|
-
if /^\d+$/.match(irqn)
|
68
|
+
if /^\d+$/.match?(irqn)
|
69
69
|
interrupts[:irq][irqn][:type],
|
70
70
|
interrupts[:irq][irqn][:vector],
|
71
71
|
interrupts[:irq][irqn][:device] =
|
@@ -105,7 +105,7 @@ Ohai.plugin(:Mdadm) do
|
|
105
105
|
# gather detailed information on the array
|
106
106
|
so = shell_out("mdadm --detail /dev/#{device}")
|
107
107
|
|
108
|
-
# if the mdadm command was
|
108
|
+
# if the mdadm command was successful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
109
109
|
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
110
110
|
mdadm[device]["members"] = devices[device]["active"]
|
111
111
|
mdadm[device]["spares"] = devices[device]["spare"]
|
@@ -78,7 +78,7 @@ Ohai.plugin(:Network) do
|
|
78
78
|
so.stdout.lines do |line|
|
79
79
|
line.strip!
|
80
80
|
logger.trace("Plugin Network: Parsing #{line}")
|
81
|
-
if line
|
81
|
+
if /\\/.match?(line)
|
82
82
|
parts = line.split('\\')
|
83
83
|
route_dest = parts.shift.strip
|
84
84
|
route_endings = parts
|
@@ -108,6 +108,8 @@ Ohai.plugin(:Network) do
|
|
108
108
|
# http://rubular.com/r/pwTNp65VFf
|
109
109
|
route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)/
|
110
110
|
end
|
111
|
+
# https://rubular.com/r/k1sMrRn5yLjgVi
|
112
|
+
route_entry["via"] = $1 if route_ending =~ /\bvia\s+inet6\s+([^\s]+)/
|
111
113
|
|
112
114
|
# a sanity check, especially for Linux-VServer, OpenVZ and LXC:
|
113
115
|
# don't report the route entry if the src address isn't set on the node
|
@@ -189,11 +191,11 @@ Ohai.plugin(:Network) do
|
|
189
191
|
next if line.start_with?("Ring parameters for")
|
190
192
|
next if line.strip.nil?
|
191
193
|
|
192
|
-
if
|
194
|
+
if /Pre-set maximums/.match?(line)
|
193
195
|
type = "max"
|
194
196
|
next
|
195
197
|
end
|
196
|
-
if
|
198
|
+
if /Current hardware settings/.match?(line)
|
197
199
|
type = "current"
|
198
200
|
next
|
199
201
|
end
|
@@ -222,11 +224,11 @@ Ohai.plugin(:Network) do
|
|
222
224
|
next if line.start_with?("Channel parameters for")
|
223
225
|
next if line.strip.nil?
|
224
226
|
|
225
|
-
if
|
227
|
+
if /Pre-set maximums/.match?(line)
|
226
228
|
type = "max"
|
227
229
|
next
|
228
230
|
end
|
229
|
-
if
|
231
|
+
if /Current hardware settings/.match?(line)
|
230
232
|
type = "current"
|
231
233
|
next
|
232
234
|
end
|
@@ -306,7 +308,7 @@ Ohai.plugin(:Network) do
|
|
306
308
|
net_counters[tmp_int] ||= Mash.new
|
307
309
|
end
|
308
310
|
|
309
|
-
if
|
311
|
+
if /^\s+(ip6tnl|ipip)/.match?(line)
|
310
312
|
iface[tmp_int][:tunnel_info] = {}
|
311
313
|
words = line.split
|
312
314
|
words.each_with_index do |word, index|
|
@@ -195,7 +195,7 @@ Ohai.plugin(:Platform) do
|
|
195
195
|
elsif File.exist?("/etc/debian_version")
|
196
196
|
# Ubuntu and Debian both have /etc/debian_version
|
197
197
|
# Ubuntu should always have a working lsb, debian does not by default
|
198
|
-
if lsb[:id]
|
198
|
+
if /Ubuntu/i.match?(lsb[:id])
|
199
199
|
platform "ubuntu"
|
200
200
|
platform_version lsb[:release]
|
201
201
|
else
|
@@ -222,7 +222,7 @@ Ohai.plugin(:Platform) do
|
|
222
222
|
suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
223
223
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
224
224
|
platform_version suse_version
|
225
|
-
if
|
225
|
+
if /^openSUSE/.match?(suse_release)
|
226
226
|
# opensuse releases >= 42 are openSUSE Leap
|
227
227
|
if platform_version.to_i < 42
|
228
228
|
platform "opensuse"
|
@@ -256,23 +256,23 @@ Ohai.plugin(:Platform) do
|
|
256
256
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
257
257
|
elsif File.exist?("/usr/lib/os-release")
|
258
258
|
contents = File.read("/usr/lib/os-release")
|
259
|
-
if /clear-linux-os
|
259
|
+
if /clear-linux-os/.match?(contents) # Clear Linux https://clearlinux.org/
|
260
260
|
platform "clearlinux"
|
261
261
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
262
262
|
end
|
263
|
-
elsif lsb[:id]
|
263
|
+
elsif /RedHat/i.match?(lsb[:id])
|
264
264
|
platform "redhat"
|
265
265
|
platform_version lsb[:release]
|
266
|
-
elsif lsb[:id]
|
266
|
+
elsif /Amazon/i.match?(lsb[:id])
|
267
267
|
platform "amazon"
|
268
268
|
platform_version lsb[:release]
|
269
|
-
elsif lsb[:id]
|
269
|
+
elsif /ScientificSL/i.match?(lsb[:id])
|
270
270
|
platform "scientific"
|
271
271
|
platform_version lsb[:release]
|
272
|
-
elsif lsb[:id]
|
272
|
+
elsif /XenServer/i.match?(lsb[:id])
|
273
273
|
platform "xenserver"
|
274
274
|
platform_version lsb[:release]
|
275
|
-
elsif lsb[:id]
|
275
|
+
elsif /XCP/i.match?(lsb[:id])
|
276
276
|
platform "xcp"
|
277
277
|
platform_version lsb[:release]
|
278
278
|
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties
|
@@ -59,7 +59,7 @@ Ohai.plugin(:Virtualization) do
|
|
59
59
|
|
60
60
|
# This file should exist on most Xen systems, normally empty for guests
|
61
61
|
if File.exist?("/proc/xen/capabilities")
|
62
|
-
if File.read("/proc/xen/capabilities")
|
62
|
+
if /control_d/i.match?(File.read("/proc/xen/capabilities"))
|
63
63
|
logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
|
64
64
|
virtualization[:role] = "host"
|
65
65
|
virtualization[:systems][:xen] = "host"
|
@@ -70,12 +70,12 @@ Ohai.plugin(:Virtualization) do
|
|
70
70
|
# Detect Virtualbox from kernel module
|
71
71
|
if File.exist?("/proc/modules")
|
72
72
|
modules = File.read("/proc/modules")
|
73
|
-
if
|
73
|
+
if /^vboxdrv/.match?(modules)
|
74
74
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
|
75
75
|
virtualization[:system] = "vbox"
|
76
76
|
virtualization[:role] = "host"
|
77
77
|
virtualization[:systems][:vbox] = "host"
|
78
|
-
elsif
|
78
|
+
elsif /^vboxguest/.match?(modules)
|
79
79
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxguest. Detecting as vbox guest")
|
80
80
|
virtualization[:system] = "vbox"
|
81
81
|
virtualization[:role] = "guest"
|
@@ -93,7 +93,7 @@ Ohai.plugin(:Virtualization) do
|
|
93
93
|
|
94
94
|
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
95
95
|
if File.exist?("/proc/cpuinfo")
|
96
|
-
if
|
96
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(File.read("/proc/cpuinfo"))
|
97
97
|
logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
|
98
98
|
virtualization[:system] = "kvm"
|
99
99
|
virtualization[:role] = "guest"
|
@@ -105,7 +105,7 @@ Ohai.plugin(:Virtualization) do
|
|
105
105
|
# guests will have the hypervisor cpu feature that hosts don't have
|
106
106
|
if File.exist?("/sys/devices/virtual/misc/kvm")
|
107
107
|
virtualization[:system] = "kvm"
|
108
|
-
if File.read("/proc/cpuinfo")
|
108
|
+
if /hypervisor/.match?(File.read("/proc/cpuinfo"))
|
109
109
|
logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
|
110
110
|
virtualization[:role] = "guest"
|
111
111
|
virtualization[:systems][:kvm] = "guest"
|
@@ -190,18 +190,21 @@ Ohai.plugin(:Virtualization) do
|
|
190
190
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
191
191
|
if File.exist?("/proc/self/cgroup")
|
192
192
|
cgroup_content = File.read("/proc/self/cgroup")
|
193
|
-
|
194
|
-
|
193
|
+
# These two REs catch many different examples. Here's a specific one
|
194
|
+
# from when it is docker and there is no subsystem name.
|
195
|
+
# https://rubular.com/r/dV13hiU9KxmiWB
|
196
|
+
if cgroup_content =~ %r{^\d+:[^:]*:/(lxc|docker)/.+$} ||
|
197
|
+
cgroup_content =~ %r{^\d+:[^:]*:/[^/]+/(lxc|docker)-?.+$}
|
195
198
|
logger.trace("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
|
196
199
|
virtualization[:system] = $1
|
197
200
|
virtualization[:role] = "guest"
|
198
201
|
virtualization[:systems][$1.to_sym] = "guest"
|
199
|
-
elsif File.read("/proc/1/environ")
|
202
|
+
elsif /container=lxc/.match?(File.read("/proc/1/environ"))
|
200
203
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
|
201
204
|
virtualization[:system] = "lxc"
|
202
205
|
virtualization[:role] = "guest"
|
203
206
|
virtualization[:systems][:lxc] = "guest"
|
204
|
-
elsif File.read("/proc/1/environ")
|
207
|
+
elsif /container=systemd-nspawn/.match?(File.read("/proc/1/environ"))
|
205
208
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
|
206
209
|
virtualization[:system] = "nspawn"
|
207
210
|
virtualization[:role] = "guest"
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -54,7 +54,7 @@ Ohai.plugin(:NetworkAddresses) do
|
|
54
54
|
ipaddresses.sort_by do |v|
|
55
55
|
[ ( scope_prio.index(v[:scope]) || 999999 ),
|
56
56
|
128 - v[:ipaddress].prefix.to_i,
|
57
|
-
|
57
|
+
v[:ipaddress].to_i,
|
58
58
|
]
|
59
59
|
end
|
60
60
|
end
|
@@ -49,7 +49,7 @@ Ohai.plugin(:Openstack) do
|
|
49
49
|
# https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image
|
50
50
|
def openstack_provider
|
51
51
|
# dream host doesn't support windows so bail early if we're on windows
|
52
|
-
return "openstack" if RUBY_PLATFORM
|
52
|
+
return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
53
53
|
|
54
54
|
if Etc::Passwd.entries.map(&:name).include?("dhc-user")
|
55
55
|
"dreamhost"
|
@@ -48,7 +48,7 @@ Ohai.plugin(:Rackspace) do
|
|
48
48
|
# true:: If the rackspace cloud can be identified
|
49
49
|
# false:: Otherwise
|
50
50
|
def has_rackspace_manufacturer?
|
51
|
-
return false unless RUBY_PLATFORM
|
51
|
+
return false unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
|
52
52
|
|
53
53
|
require "wmi-lite/wmi"
|
54
54
|
wmi = WmiLite::Wmi.new
|
@@ -102,7 +102,7 @@ Ohai.plugin(:Rackspace) do
|
|
102
102
|
so = shell_out("xenstore-ls vm-data/provider_data")
|
103
103
|
if so.exitstatus == 0
|
104
104
|
so.stdout.split("\n").each do |line|
|
105
|
-
rackspace[:region] = line.split[2].delete('\"') if
|
105
|
+
rackspace[:region] = line.split[2].delete('\"') if /^region/.match?(line)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
rescue Ohai::Exceptions::Exec
|
@@ -38,7 +38,7 @@ Ohai.plugin(:Virtualization) do
|
|
38
38
|
psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
|
39
39
|
if File.exist?(psrinfo_path)
|
40
40
|
so = shell_out("#{psrinfo_path} -pv")
|
41
|
-
if
|
41
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
|
42
42
|
virtualization[:system] = "kvm"
|
43
43
|
virtualization[:role] = "guest"
|
44
44
|
virtualization[:systems][:kvm] = "guest"
|
@@ -51,7 +51,7 @@ Ohai.plugin(:SSHHostKey) do
|
|
51
51
|
if sshd_config
|
52
52
|
File.open(sshd_config) do |conf|
|
53
53
|
conf.each_line do |line|
|
54
|
-
if
|
54
|
+
if /^hostkey\s/i.match?(line)
|
55
55
|
pub_file = "#{line.split[1]}.pub"
|
56
56
|
content = IO.read(pub_file).split
|
57
57
|
key_type, key_subtype = extract_keytype?(content)
|
data/lib/ohai/plugins/vmware.rb
CHANGED
@@ -51,12 +51,12 @@ Ohai.plugin(:VMware) do
|
|
51
51
|
# to attribute "vmware[:<parameter>]"
|
52
52
|
%w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
|
53
53
|
vmware[param] = from_cmd("#{vmtools_path} stat #{param}")
|
54
|
-
if vmware[param]
|
54
|
+
if /UpdateInfo failed/.match?(vmware[param])
|
55
55
|
vmware[param] = nil
|
56
56
|
end
|
57
57
|
end
|
58
58
|
# vmware-toolbox-cmd <param> status commands
|
59
|
-
# Iterate through each parameter supported by the "
|
59
|
+
# Iterate through each parameter supported by the "vmware-toolbox-cmd status" command, assign value
|
60
60
|
# to attribute "vmware[:<parameter>]"
|
61
61
|
%w{upgrade timesync}.each do |param|
|
62
62
|
vmware[param] = from_cmd("#{vmtools_path} #{param} status")
|
@@ -93,7 +93,7 @@ Ohai.plugin(:Network) do
|
|
93
93
|
|
94
94
|
# Selects default interface and returns its information
|
95
95
|
#
|
96
|
-
# @note Interface with least metric value should be
|
96
|
+
# @note Interface with least metric value should be preferred as default_route
|
97
97
|
#
|
98
98
|
# @param configuration [Mash] Configuration of interfaces as iface_config
|
99
99
|
# [<interface_index> => {<interface_configurations>}]
|
@@ -171,7 +171,7 @@ Ohai.plugin(:Network) do
|
|
171
171
|
iface[cint][:addresses][ip] = Mash.new(prefixlen: ip2.prefix)
|
172
172
|
if ip2.ipv6?
|
173
173
|
iface[cint][:addresses][ip][:family] = "inet6"
|
174
|
-
iface[cint][:addresses][ip][:scope] = "Link" if
|
174
|
+
iface[cint][:addresses][ip][:scope] = "Link" if /^fe80/i.match?(ip)
|
175
175
|
else
|
176
176
|
if iface[cint][:configuration][:ip_subnet]
|
177
177
|
iface[cint][:addresses][ip][:netmask] = ip2.netmask.to_s
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
# After long discussion in IRC the "powers that be" have come to a
|
19
|
+
# After long discussion in IRC the "powers that be" have come to a consensus
|
20
20
|
# that there is no other Windows platforms exist that were not based on the
|
21
21
|
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
22
22
|
# platforms built upon the Windows_NT kernel and have access to win32 or win64
|
data/lib/ohai/provides_map.rb
CHANGED
@@ -136,8 +136,8 @@ module Ohai
|
|
136
136
|
private
|
137
137
|
|
138
138
|
def normalize_and_validate(attribute)
|
139
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if
|
140
|
-
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if
|
139
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if %r{//+}.match?(attribute)
|
140
|
+
raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if %r{/$}.match?(attribute)
|
141
141
|
|
142
142
|
parts = attribute.split("/")
|
143
143
|
parts.shift if parts.length != 0 && parts[0].length == 0 # attribute begins with a '/'
|
data/lib/ohai/util/win32.rb
CHANGED
data/lib/ohai/version.rb
CHANGED
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: 16.
|
4
|
+
version: 16.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|