ohai 8.10.0 → 8.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Rakefile +13 -4
- data/bin/ohai +3 -4
- data/lib/ohai.rb +4 -4
- data/lib/ohai/application.rb +7 -6
- data/lib/ohai/common/dmi.rb +56 -56
- data/lib/ohai/config.rb +12 -8
- data/lib/ohai/dsl.rb +3 -3
- data/lib/ohai/dsl/plugin.rb +5 -5
- data/lib/ohai/dsl/plugin/versionvi.rb +0 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +1 -0
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +7 -7
- data/lib/ohai/log.rb +1 -1
- data/lib/ohai/mash.rb +3 -2
- data/lib/ohai/mixin/command.rb +25 -23
- data/lib/ohai/mixin/dmi_decode.rb +10 -10
- data/lib/ohai/mixin/ec2_metadata.rb +40 -39
- data/lib/ohai/mixin/gce_metadata.rb +9 -9
- data/lib/ohai/mixin/network_constants.rb +1 -1
- data/lib/ohai/mixin/os.rb +3 -3
- data/lib/ohai/mixin/seconds_to_human.rb +0 -2
- data/lib/ohai/mixin/softlayer_metadata.rb +10 -10
- data/lib/ohai/mixin/string.rb +2 -2
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/cpu.rb +2 -2
- data/lib/ohai/plugins/aix/filesystem.rb +2 -2
- data/lib/ohai/plugins/aix/memory.rb +2 -2
- data/lib/ohai/plugins/aix/network.rb +9 -10
- data/lib/ohai/plugins/aix/os.rb +2 -2
- data/lib/ohai/plugins/aix/uptime.rb +3 -3
- data/lib/ohai/plugins/aix/virtualization.rb +23 -23
- data/lib/ohai/plugins/azure.rb +32 -5
- data/lib/ohai/plugins/bsd/virtualization.rb +22 -22
- data/lib/ohai/plugins/c.rb +3 -3
- data/lib/ohai/plugins/chef.rb +1 -1
- data/lib/ohai/plugins/cloud.rb +59 -60
- data/lib/ohai/plugins/cloud_v2.rb +37 -39
- data/lib/ohai/plugins/darwin/cpu.rb +1 -1
- data/lib/ohai/plugins/darwin/filesystem2.rb +5 -5
- data/lib/ohai/plugins/darwin/memory.rb +5 -6
- data/lib/ohai/plugins/darwin/network.rb +7 -7
- data/lib/ohai/plugins/darwin/system_profiler.rb +32 -33
- data/lib/ohai/plugins/darwin/virtualization.rb +9 -9
- data/lib/ohai/plugins/digital_ocean.rb +16 -16
- data/lib/ohai/plugins/dmi.rb +6 -6
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +2 -2
- data/lib/ohai/plugins/dragonflybsd/memory.rb +0 -1
- data/lib/ohai/plugins/dragonflybsd/network.rb +4 -4
- data/lib/ohai/plugins/dragonflybsd/os.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +39 -15
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +3 -3
- data/lib/ohai/plugins/eucalyptus.rb +16 -12
- data/lib/ohai/plugins/freebsd/cpu.rb +2 -2
- data/lib/ohai/plugins/freebsd/memory.rb +0 -1
- data/lib/ohai/plugins/freebsd/network.rb +4 -4
- data/lib/ohai/plugins/freebsd/os.rb +1 -1
- data/lib/ohai/plugins/gce.rb +6 -6
- data/lib/ohai/plugins/hostname.rb +7 -7
- data/lib/ohai/plugins/init_package.rb +1 -1
- data/lib/ohai/plugins/ip_scopes.rb +9 -9
- data/lib/ohai/plugins/java.rb +1 -1
- data/lib/ohai/plugins/joyent.rb +7 -7
- data/lib/ohai/plugins/kernel.rb +8 -8
- data/lib/ohai/plugins/linode.rb +7 -4
- data/lib/ohai/plugins/linux/cpu.rb +5 -5
- data/lib/ohai/plugins/linux/filesystem.rb +16 -16
- data/lib/ohai/plugins/linux/filesystem2.rb +15 -15
- data/lib/ohai/plugins/linux/mdadm.rb +3 -3
- data/lib/ohai/plugins/linux/network.rb +85 -51
- data/lib/ohai/plugins/linux/platform.rb +24 -24
- data/lib/ohai/plugins/linux/virtualization.rb +8 -8
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/cpu.rb +1 -1
- data/lib/ohai/plugins/netbsd/network.rb +2 -2
- data/lib/ohai/plugins/network.rb +11 -11
- data/lib/ohai/plugins/network_listeners.rb +30 -26
- data/lib/ohai/plugins/ohai.rb +3 -3
- data/lib/ohai/plugins/openbsd/cpu.rb +4 -4
- data/lib/ohai/plugins/openbsd/memory.rb +4 -4
- data/lib/ohai/plugins/openbsd/network.rb +3 -3
- data/lib/ohai/plugins/openstack.rb +12 -12
- data/lib/ohai/plugins/os.rb +2 -2
- data/lib/ohai/plugins/packages.rb +22 -22
- data/lib/ohai/plugins/passwd.rb +4 -4
- data/lib/ohai/plugins/powershell.rb +9 -9
- data/lib/ohai/plugins/ps.rb +2 -2
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +13 -13
- data/lib/ohai/plugins/root_group.rb +4 -4
- data/lib/ohai/plugins/ruby.rb +6 -6
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/sigar/cpu.rb +1 -1
- data/lib/ohai/plugins/sigar/filesystem.rb +1 -1
- data/lib/ohai/plugins/sigar/network.rb +13 -13
- data/lib/ohai/plugins/sigar/network_route.rb +34 -29
- data/lib/ohai/plugins/softlayer.rb +8 -7
- data/lib/ohai/plugins/solaris2/cpu.rb +19 -19
- data/lib/ohai/plugins/solaris2/dmi.rb +63 -63
- data/lib/ohai/plugins/solaris2/filesystem.rb +13 -13
- data/lib/ohai/plugins/solaris2/memory.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +5 -5
- data/lib/ohai/plugins/solaris2/virtualization.rb +18 -18
- data/lib/ohai/plugins/solaris2/zpools.rb +1 -1
- data/lib/ohai/plugins/ssh_host_key.rb +2 -2
- data/lib/ohai/plugins/uptime.rb +4 -5
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/virtualization.rb +17 -17
- data/lib/ohai/plugins/vmware.rb +2 -2
- data/lib/ohai/plugins/windows/cpu.rb +14 -14
- data/lib/ohai/plugins/windows/drivers.rb +8 -8
- data/lib/ohai/plugins/windows/filesystem.rb +4 -4
- data/lib/ohai/plugins/windows/memory.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +10 -10
- data/lib/ohai/plugins/windows/platform.rb +1 -2
- data/lib/ohai/plugins/windows/virtualization.rb +17 -17
- data/lib/ohai/provides_map.rb +7 -7
- data/lib/ohai/runner.rb +3 -3
- data/lib/ohai/system.rb +21 -20
- data/lib/ohai/util/file_helper.rb +1 -2
- data/lib/ohai/util/ip_helper.rb +4 -4
- data/lib/ohai/util/win32.rb +5 -5
- data/lib/ohai/util/win32/group_helper.rb +4 -5
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +7 -5
- data/spec/functional/application_spec.rb +23 -23
- data/spec/functional/loader_spec.rb +1 -1
- data/spec/functional/plugins/powershell_spec.rb +13 -13
- data/spec/functional/plugins/root_group_spec.rb +5 -5
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +9 -9
- data/spec/support/integration_helper.rb +7 -7
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/unit/application_spec.rb +17 -17
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/dsl/plugin_spec.rb +28 -28
- data/spec/unit/hints_spec.rb +3 -3
- data/spec/unit/loader_spec.rb +9 -9
- data/spec/unit/mixin/command_spec.rb +5 -5
- data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
- data/spec/unit/mixin/softlayer_metadata_spec.rb +19 -23
- data/spec/unit/plugin_config_spec.rb +5 -5
- data/spec/unit/plugins/abort_spec.rb +3 -3
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +25 -25
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -2
- data/spec/unit/plugins/aix/kernel_spec.rb +3 -3
- data/spec/unit/plugins/aix/memory_spec.rb +8 -8
- data/spec/unit/plugins/aix/network_spec.rb +38 -38
- data/spec/unit/plugins/aix/os_spec.rb +1 -2
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +11 -11
- data/spec/unit/plugins/azure_spec.rb +118 -20
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +4 -4
- data/spec/unit/plugins/c_spec.rb +12 -12
- data/spec/unit/plugins/chef_spec.rb +2 -2
- data/spec/unit/plugins/cloud_spec.rb +37 -37
- data/spec/unit/plugins/cloud_v2_spec.rb +64 -65
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -2
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -4
- data/spec/unit/plugins/darwin/kernel_spec.rb +6 -10
- data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
- data/spec/unit/plugins/darwin/network_spec.rb +352 -353
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -2
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +3 -3
- data/spec/unit/plugins/darwin/virtualization_spec.rb +6 -6
- data/spec/unit/plugins/digital_ocean_spec.rb +38 -37
- data/spec/unit/plugins/dmi_spec.rb +3 -3
- data/spec/unit/plugins/ec2_spec.rb +97 -88
- data/spec/unit/plugins/elixir_spec.rb +1 -2
- data/spec/unit/plugins/erlang_spec.rb +2 -2
- data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
- data/spec/unit/plugins/fail_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/cpu_spec.rb +14 -14
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -3
- data/spec/unit/plugins/freebsd/os_spec.rb +4 -5
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/gce_spec.rb +9 -9
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -2
- data/spec/unit/plugins/hostname_spec.rb +1 -2
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +38 -38
- data/spec/unit/plugins/java_spec.rb +52 -1
- data/spec/unit/plugins/joyent_spec.rb +9 -11
- data/spec/unit/plugins/kernel_spec.rb +11 -12
- data/spec/unit/plugins/linode_spec.rb +29 -29
- data/spec/unit/plugins/linux/block_device_spec.rb +21 -21
- data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
- data/spec/unit/plugins/linux/filesystem2_spec.rb +7 -7
- data/spec/unit/plugins/linux/filesystem_spec.rb +85 -86
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -3
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -2
- data/spec/unit/plugins/linux/mdadm_spec.rb +4 -4
- data/spec/unit/plugins/linux/memory_spec.rb +29 -33
- data/spec/unit/plugins/linux/network_spec.rb +463 -245
- data/spec/unit/plugins/linux/platform_spec.rb +64 -65
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -2
- data/spec/unit/plugins/linux/virtualization_spec.rb +42 -42
- data/spec/unit/plugins/lua_spec.rb +1 -2
- data/spec/unit/plugins/mono_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +118 -118
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -2
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -2
- data/spec/unit/plugins/openstack_spec.rb +35 -37
- data/spec/unit/plugins/os_spec.rb +7 -8
- data/spec/unit/plugins/packages_spec.rb +118 -118
- data/spec/unit/plugins/passwd_spec.rb +18 -18
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +4 -4
- data/spec/unit/plugins/platform_spec.rb +8 -9
- data/spec/unit/plugins/powershell_spec.rb +3 -3
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +66 -68
- data/spec/unit/plugins/root_group_spec.rb +26 -26
- data/spec/unit/plugins/ruby_spec.rb +14 -15
- data/spec/unit/plugins/rust_spec.rb +2 -2
- data/spec/unit/plugins/sigar/network_route_spec.rb +36 -36
- data/spec/unit/plugins/softlayer_spec.rb +10 -10
- data/spec/unit/plugins/solaris2/cpu_spec.rb +20 -21
- data/spec/unit/plugins/solaris2/dmi_spec.rb +5 -6
- data/spec/unit/plugins/solaris2/filesystem.rb +5 -5
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +3 -3
- data/spec/unit/plugins/solaris2/memory_spec.rb +5 -5
- data/spec/unit/plugins/solaris2/network_spec.rb +7 -8
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +3 -5
- data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +19 -19
- data/spec/unit/plugins/vmware_spec.rb +28 -28
- data/spec/unit/plugins/windows/cpu_spec.rb +46 -48
- data/spec/unit/plugins/windows/memory_spec.rb +5 -5
- data/spec/unit/plugins/windows/virtualization_spec.rb +163 -163
- data/spec/unit/provides_map_spec.rb +10 -10
- data/spec/unit/runner_spec.rb +10 -10
- data/spec/unit/system_spec.rb +19 -19
- data/spec/unit/util/file_helper_spec.rb +5 -6
- data/spec/unit/util/ip_helper_spec.rb +39 -39
- metadata +31 -4
data/lib/ohai/plugins/dmi.rb
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -22,7 +22,7 @@ Ohai.plugin(:DMI) do
|
|
22
22
|
# dmidecode does not return data without access to /dev/mem (or its equivalent)
|
23
23
|
|
24
24
|
collect_data do
|
25
|
-
require
|
25
|
+
require "ohai/common/dmi"
|
26
26
|
dmi Mash.new
|
27
27
|
|
28
28
|
# all output lines should fall within one of these patterns
|
@@ -49,7 +49,7 @@ Ohai.plugin(:DMI) do
|
|
49
49
|
#Handle 0x0000, DMI type 0, 24 bytes
|
50
50
|
#BIOS Information
|
51
51
|
# Vendor: American Megatrends Inc.
|
52
|
-
# Version: 080012
|
52
|
+
# Version: 080012
|
53
53
|
# ... similar lines trimmed
|
54
54
|
# Characteristics:
|
55
55
|
# ISA is supported
|
@@ -80,7 +80,7 @@ Ohai.plugin(:DMI) do
|
|
80
80
|
next
|
81
81
|
end
|
82
82
|
|
83
|
-
dmi_record = {:type => Ohai::Common::DMI.id_lookup(handle[2])}
|
83
|
+
dmi_record = { :type => Ohai::Common::DMI.id_lookup(handle[2]) }
|
84
84
|
|
85
85
|
dmi[dmi_record[:type]] = Mash.new unless dmi.has_key?(dmi_record[:type])
|
86
86
|
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].has_key?(:all_records)
|
@@ -115,7 +115,7 @@ Ohai.plugin(:DMI) do
|
|
115
115
|
next
|
116
116
|
end
|
117
117
|
# overwrite "raw" value with a new Mash
|
118
|
-
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s ==
|
118
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == "Mash"
|
119
119
|
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = nil
|
120
120
|
|
121
121
|
else
|
@@ -44,10 +44,10 @@ Ohai.plugin(:CPU) do
|
|
44
44
|
cpuinfo["stepping"] = $3
|
45
45
|
# These _should_ match /AMD Features2?/ lines as well
|
46
46
|
when /Features=.+<(.+)>/
|
47
|
-
cpuinfo["flags"].concat($1.downcase.split(
|
47
|
+
cpuinfo["flags"].concat($1.downcase.split(","))
|
48
48
|
# Features2=0x80000001<SSE3,<b31>>
|
49
49
|
when /Features2=[a-f\dx]+<(.+)>/
|
50
|
-
cpuinfo["flags"].concat($1.downcase.split(
|
50
|
+
cpuinfo["flags"].concat($1.downcase.split(","))
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -58,7 +58,7 @@ Ohai.plugin(:Network) do
|
|
58
58
|
if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
|
59
59
|
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
60
60
|
# convert the netmask to decimal for consistency
|
61
|
-
netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
|
61
|
+
netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
|
62
62
|
if $3.empty?
|
63
63
|
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
|
64
64
|
else
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
if line =~ /flags=\d+<(.+)>/
|
79
|
-
flags = $1.split(
|
79
|
+
flags = $1.split(",")
|
80
80
|
iface[cint][:flags] = flags if flags.length > 0
|
81
81
|
end
|
82
82
|
if line =~ /metric: (\d+) mtu: (\d+)/
|
@@ -100,11 +100,11 @@ Ohai.plugin(:Network) do
|
|
100
100
|
# From netstat(1), not sure of the implications:
|
101
101
|
# Show the state of all network interfaces or a single interface
|
102
102
|
# which have been auto-configured (interfaces statically configured
|
103
|
-
# into a system, but not located at boot time are not shown).
|
103
|
+
# into a system, but not located at boot time are not shown).
|
104
104
|
so = shell_out("netstat -ibdn")
|
105
105
|
so.stdout.lines do |line|
|
106
106
|
# Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
107
|
-
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
107
|
+
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
108
108
|
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
|
109
109
|
if line =~ /^([\w\.\*]+)\s+\d+\s+<Link#\d+>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
110
110
|
net_counters[$1] = Mash.new unless net_counters[$1]
|
data/lib/ohai/plugins/ec2.rb
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
20
|
+
require "ohai/mixin/ec2_metadata"
|
21
|
+
require "base64"
|
22
22
|
|
23
23
|
Ohai.plugin(:EC2) do
|
24
24
|
include Ohai::Mixin::Ec2Metadata
|
@@ -28,17 +28,34 @@ Ohai.plugin(:EC2) do
|
|
28
28
|
depends "network/interfaces"
|
29
29
|
depends "dmi"
|
30
30
|
|
31
|
+
# look for ec2metadata which is included on paravirt / hvm AMIs
|
32
|
+
def has_ec2metadata_bin?
|
33
|
+
if File.exist?("/usr/bin/ec2metadata")
|
34
|
+
Ohai::Log.debug("ec2 plugin: has_ec2metadata_bin? == true")
|
35
|
+
true
|
36
|
+
else
|
37
|
+
Ohai::Log.debug("ec2 plugin: has_ec2metadata_bin? == false")
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
31
42
|
# look for arp address that non-VPC hosts will have
|
32
|
-
def
|
43
|
+
def has_xen_mac?
|
33
44
|
network[:interfaces].values.each do |iface|
|
34
45
|
unless iface[:arp].nil?
|
35
46
|
if iface[:arp].value?("fe:ff:ff:ff:ff:ff")
|
36
|
-
|
47
|
+
# using MAC addresses from ARP is unreliable because they could time-out from the table
|
48
|
+
# fe:ff:ff:ff:ff:ff is actually a sign of Xen, not specifically EC2
|
49
|
+
deprecation_message <<-EOM
|
50
|
+
ec2 plugin: Detected EC2 by the presence of fe:ff:ff:ff:ff:ff in the ARP table. This method is unreliable and will be removed in a future version of ohai. Bootstrap using knife-ec2 or create "/etc/chef/ohai/hints/ec2.json" instead.
|
51
|
+
EOM
|
52
|
+
Ohai::Log.warn(deprecation_message)
|
53
|
+
Ohai::Log.debug("ec2 plugin: has_xen_mac? == true")
|
37
54
|
return true
|
38
55
|
end
|
39
56
|
end
|
40
57
|
end
|
41
|
-
Ohai::Log.debug("
|
58
|
+
Ohai::Log.debug("ec2 plugin: has_xen_mac? == false")
|
42
59
|
false
|
43
60
|
end
|
44
61
|
|
@@ -48,42 +65,49 @@ Ohai.plugin(:EC2) do
|
|
48
65
|
begin
|
49
66
|
# detect a version of '4.2.amazon'
|
50
67
|
if dmi[:bios][:all_records][0][:Version] =~ /amazon/
|
51
|
-
Ohai::Log.debug("has_ec2_dmi? == true")
|
68
|
+
Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == true")
|
52
69
|
true
|
53
70
|
end
|
54
71
|
rescue NoMethodError
|
55
|
-
Ohai::Log.debug("has_ec2_dmi? == false")
|
72
|
+
Ohai::Log.debug("ec2 plugin: has_ec2_dmi? == false")
|
56
73
|
false
|
57
74
|
end
|
58
75
|
end
|
59
76
|
|
77
|
+
# rackspace systems look like ec2 so instead of timing out dig a bit deeper
|
78
|
+
def looks_like_rackspace?
|
79
|
+
return true if File.exist?("/usr/bin/rackspace-monitoring-agent")
|
80
|
+
end
|
60
81
|
|
61
82
|
def looks_like_ec2?
|
62
|
-
|
63
|
-
|
64
|
-
|
83
|
+
return true if hint?("ec2")
|
84
|
+
|
85
|
+
# Even if it looks like EC2 try to connect first
|
86
|
+
if has_ec2_dmi? || has_xen_mac? || (has_ec2metadata_bin? && !looks_like_rackspace?)
|
87
|
+
return true if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
|
88
|
+
end
|
65
89
|
end
|
66
90
|
|
67
91
|
collect_data do
|
68
92
|
if looks_like_ec2?
|
69
|
-
Ohai::Log.debug("looks_like_ec2? == true")
|
93
|
+
Ohai::Log.debug("ec2 plugin: looks_like_ec2? == true")
|
70
94
|
ec2 Mash.new
|
71
95
|
fetch_metadata.each do |k, v|
|
72
96
|
# fetch_metadata returns IAM security credentials, including the IAM user's
|
73
97
|
# secret access key. We'd rather not have ohai send this information
|
74
98
|
# to the server.
|
75
99
|
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories
|
76
|
-
next if k ==
|
100
|
+
next if k == "iam" && !hint?("iam")
|
77
101
|
ec2[k] = v
|
78
102
|
end
|
79
103
|
ec2[:userdata] = self.fetch_userdata
|
80
|
-
#ASCII-8BIT is equivalent to BINARY in this case
|
104
|
+
# ASCII-8BIT is equivalent to BINARY in this case
|
81
105
|
if ec2[:userdata] && ec2[:userdata].encoding.to_s == "ASCII-8BIT"
|
82
|
-
Ohai::Log.debug("Binary UserData Found. Storing in base64")
|
106
|
+
Ohai::Log.debug("ec2 plugin: Binary UserData Found. Storing in base64")
|
83
107
|
ec2[:userdata] = Base64.encode64(ec2[:userdata])
|
84
108
|
end
|
85
109
|
else
|
86
|
-
Ohai::Log.debug("looks_like_ec2? == false")
|
110
|
+
Ohai::Log.debug("ec2 plugin: looks_like_ec2? == false")
|
87
111
|
false
|
88
112
|
end
|
89
113
|
end
|
data/lib/ohai/plugins/elixir.rb
CHANGED
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -30,10 +30,10 @@ Ohai.plugin(:Erlang) do
|
|
30
30
|
output = so.stderr.split
|
31
31
|
if output.length >= 6
|
32
32
|
options = output[1]
|
33
|
-
options.gsub!(/(\(|\))/,
|
33
|
+
options.gsub!(/(\(|\))/, "")
|
34
34
|
erlang[:version] = output[5]
|
35
|
-
erlang[:options] = options.split(
|
36
|
-
erlang[:emulator] = output[2].gsub!(/(\(|\))/,
|
35
|
+
erlang[:options] = options.split(",")
|
36
|
+
erlang[:emulator] = output[2].gsub!(/(\(|\))/, "")
|
37
37
|
if erlang[:version] and erlang[:options] and erlang[:emulator]
|
38
38
|
languages[:erlang] = erlang
|
39
39
|
end
|
@@ -17,17 +17,18 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
|
20
|
+
# eucalyptus metadata service is compatible with the ec2 service calls
|
21
|
+
require "ohai/mixin/ec2_metadata"
|
21
22
|
|
22
23
|
Ohai.plugin(:Eucalyptus) do
|
23
24
|
include Ohai::Mixin::Ec2Metadata
|
24
25
|
|
25
26
|
provides "eucalyptus"
|
26
|
-
|
27
27
|
depends "network/interfaces"
|
28
28
|
|
29
|
+
# returns the mac address from the collection of all address types
|
29
30
|
def get_mac_address(addresses)
|
30
|
-
detected_addresses = addresses.detect { |address, keypair| keypair == {"family"=>"lladdr"} }
|
31
|
+
detected_addresses = addresses.detect { |address, keypair| keypair == { "family" => "lladdr" } }
|
31
32
|
if detected_addresses
|
32
33
|
return detected_addresses.first
|
33
34
|
else
|
@@ -35,26 +36,29 @@ Ohai.plugin(:Eucalyptus) do
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
# detect if the mac address starts with d0:0d
|
38
40
|
def has_euca_mac?
|
39
41
|
network[:interfaces].values.each do |iface|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
mac = get_mac_address(iface[:addresses])
|
43
|
+
if mac =~ /^[dD]0:0[dD]:/
|
44
|
+
Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == true (#{mac})")
|
45
|
+
return true
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
|
-
Ohai::Log.debug("has_euca_mac? == false")
|
49
|
+
Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == false")
|
46
50
|
false
|
47
51
|
end
|
48
52
|
|
49
53
|
def looks_like_euca?
|
50
54
|
# Try non-blocking connect so we don't "block" if
|
51
|
-
# the
|
52
|
-
hint?(
|
55
|
+
# the metadata service doesn't respond
|
56
|
+
hint?("eucalyptus") || has_euca_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
|
53
57
|
end
|
54
58
|
|
55
59
|
collect_data do
|
56
60
|
if looks_like_euca?
|
57
|
-
Ohai::Log.debug("looks_like_euca? == true")
|
61
|
+
Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == true")
|
58
62
|
eucalyptus Mash.new
|
59
63
|
self.fetch_metadata.each do |k, v|
|
60
64
|
# Eucalyptus 3.4+ supports IAM roles and Instance Profiles much like AWS
|
@@ -64,12 +68,12 @@ Ohai.plugin(:Eucalyptus) do
|
|
64
68
|
# secret access key. We'd rather not have ohai send this information
|
65
69
|
# to the server.
|
66
70
|
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories
|
67
|
-
next if k ==
|
71
|
+
next if k == "iam" && !hint?("iam")
|
68
72
|
eucalyptus[k] = v
|
69
73
|
end
|
70
74
|
eucalyptus[:userdata] = self.fetch_userdata
|
71
75
|
else
|
72
|
-
Ohai::Log.debug("looks_like_euca? == false")
|
76
|
+
Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == false")
|
73
77
|
false
|
74
78
|
end
|
75
79
|
end
|
@@ -53,10 +53,10 @@ Ohai.plugin(:CPU) do
|
|
53
53
|
cpuinfo["stepping"] = $4
|
54
54
|
# These _should_ match /AMD Features2?/ lines as well
|
55
55
|
when /Features=.+<(.+)>/
|
56
|
-
cpuinfo["flags"].concat($1.downcase.split(
|
56
|
+
cpuinfo["flags"].concat($1.downcase.split(","))
|
57
57
|
# Features2=0x80000001<SSE3,<b31>>
|
58
58
|
when /Features2=[a-f\dx]+<(.+)>/
|
59
|
-
cpuinfo["flags"].concat($1.downcase.split(
|
59
|
+
cpuinfo["flags"].concat($1.downcase.split(","))
|
60
60
|
when /FreeBSD\/SMP: Multiprocessor System Detected: (\d*) CPUs/
|
61
61
|
cpuinfo["total"] = $1.to_i
|
62
62
|
when /FreeBSD\/SMP: (\d*) package\(s\) x (\d*) core\(s\)/
|
@@ -58,7 +58,7 @@ Ohai.plugin(:Network) do
|
|
58
58
|
if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
|
59
59
|
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
60
60
|
# convert the netmask to decimal for consistency
|
61
|
-
netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
|
61
|
+
netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
|
62
62
|
if $3.empty?
|
63
63
|
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
|
64
64
|
else
|
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
if line =~ /flags=\d+<(.+)>/
|
79
|
-
flags = $1.split(
|
79
|
+
flags = $1.split(",")
|
80
80
|
iface[cint][:flags] = flags if flags.length > 0
|
81
81
|
end
|
82
82
|
if line =~ /metric: (\d+) mtu: (\d+)/
|
@@ -100,11 +100,11 @@ Ohai.plugin(:Network) do
|
|
100
100
|
# From netstat(1), not sure of the implications:
|
101
101
|
# Show the state of all network interfaces or a single interface
|
102
102
|
# which have been auto-configured (interfaces statically configured
|
103
|
-
# into a system, but not located at boot time are not shown).
|
103
|
+
# into a system, but not located at boot time are not shown).
|
104
104
|
so = shell_out("netstat -ibdn")
|
105
105
|
so.stdout.lines do |line|
|
106
106
|
# Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
107
|
-
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
107
|
+
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
108
108
|
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
|
109
109
|
if line =~ /^([\w\.\*]+)\s+\d+\s+<Link#\d+>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
110
110
|
net_counters[$1] = Mash.new unless net_counters[$1]
|
data/lib/ohai/plugins/gce.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
require
|
17
|
+
require "ohai/mixin/gce_metadata"
|
18
18
|
|
19
19
|
Ohai.plugin(:GCE) do
|
20
20
|
include Ohai::Mixin::GCEMetadata
|
@@ -27,7 +27,7 @@ Ohai.plugin(:GCE) do
|
|
27
27
|
# true:: If gce metadata server found
|
28
28
|
# false:: Otherwise
|
29
29
|
def has_gce_metadata?
|
30
|
-
can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)
|
30
|
+
can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
|
31
31
|
end
|
32
32
|
|
33
33
|
# Identifies gce
|
@@ -36,16 +36,16 @@ Ohai.plugin(:GCE) do
|
|
36
36
|
# true:: If gce can be identified
|
37
37
|
# false:: Otherwise
|
38
38
|
def looks_like_gce?
|
39
|
-
hint?(
|
39
|
+
hint?("gce") || has_gce_metadata?
|
40
40
|
end
|
41
41
|
|
42
42
|
collect_data do
|
43
43
|
if looks_like_gce?
|
44
|
-
Ohai::Log.debug("looks_like_gce? == true")
|
44
|
+
Ohai::Log.debug("gce plugin: looks_like_gce? == true")
|
45
45
|
gce Mash.new
|
46
|
-
fetch_metadata.each {|k, v| gce[k] = v }
|
46
|
+
fetch_metadata.each { |k, v| gce[k] = v }
|
47
47
|
else
|
48
|
-
Ohai::Log.debug("looks_like_gce? == false")
|
48
|
+
Ohai::Log.debug("gce plugin: looks_like_gce? == false")
|
49
49
|
false
|
50
50
|
end
|
51
51
|
end
|
@@ -25,8 +25,8 @@
|
|
25
25
|
# limitations under the License.
|
26
26
|
#
|
27
27
|
|
28
|
-
require
|
29
|
-
require
|
28
|
+
require "socket"
|
29
|
+
require "ipaddr"
|
30
30
|
|
31
31
|
Ohai.plugin(:Hostname) do
|
32
32
|
provides "domain", "hostname", "fqdn", "machinename"
|
@@ -77,14 +77,14 @@ Ohai.plugin(:Hostname) do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def get_fqdn_from_sigar
|
80
|
-
require
|
80
|
+
require "sigar"
|
81
81
|
sigar = Sigar.new
|
82
82
|
sigar.fqdn
|
83
83
|
end
|
84
84
|
|
85
85
|
def sigar_is_available?
|
86
86
|
begin
|
87
|
-
require
|
87
|
+
require "sigar"
|
88
88
|
true
|
89
89
|
rescue LoadError
|
90
90
|
false
|
@@ -153,11 +153,11 @@ Ohai.plugin(:Hostname) do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
collect_data(:windows) do
|
156
|
-
require
|
157
|
-
require
|
156
|
+
require "wmi-lite/wmi"
|
157
|
+
require "socket"
|
158
158
|
|
159
159
|
wmi = WmiLite::Wmi.new
|
160
|
-
host = wmi.first_of(
|
160
|
+
host = wmi.first_of("Win32_ComputerSystem")
|
161
161
|
|
162
162
|
hostname "#{host['dnshostname']}"
|
163
163
|
machinename "#{host['name']}"
|