ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -16,98 +16,100 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
Ohai.plugin(:Platform) do
|
20
|
+
provides "platform", "platform_version", "platform_family"
|
21
|
+
depends "lsb"
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
end
|
23
|
+
def get_redhatish_platform(contents)
|
24
|
+
contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
|
25
|
+
end
|
26
26
|
|
27
|
-
|
27
|
+
def get_redhatish_version(contents)
|
28
|
+
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
|
29
|
+
end
|
28
30
|
|
29
|
-
|
31
|
+
collect_data(:linux) do
|
32
|
+
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
33
|
+
if File.exists?("/etc/oracle-release")
|
34
|
+
contents = File.read("/etc/oracle-release").chomp
|
35
|
+
platform "oracle"
|
36
|
+
platform_version get_redhatish_version(contents)
|
37
|
+
elsif File.exists?("/etc/enterprise-release")
|
38
|
+
contents = File.read("/etc/enterprise-release").chomp
|
39
|
+
platform "oracle"
|
40
|
+
platform_version get_redhatish_version(contents)
|
41
|
+
elsif File.exists?("/etc/debian_version")
|
42
|
+
# Ubuntu and Debian both have /etc/debian_version
|
43
|
+
# Ubuntu should always have a working lsb, debian does not by default
|
44
|
+
if lsb[:id] =~ /Ubuntu/i
|
45
|
+
platform "ubuntu"
|
46
|
+
platform_version lsb[:release]
|
47
|
+
elsif lsb[:id] =~ /LinuxMint/i
|
48
|
+
platform "linuxmint"
|
49
|
+
platform_version lsb[:release]
|
50
|
+
else
|
51
|
+
if File.exists?("/usr/bin/raspi-config")
|
52
|
+
platform "raspbian"
|
53
|
+
else
|
54
|
+
platform "debian"
|
55
|
+
end
|
56
|
+
platform_version File.read("/etc/debian_version").chomp
|
57
|
+
end
|
58
|
+
elsif File.exists?("/etc/redhat-release")
|
59
|
+
contents = File.read("/etc/redhat-release").chomp
|
60
|
+
platform get_redhatish_platform(contents)
|
61
|
+
platform_version get_redhatish_version(contents)
|
62
|
+
elsif File.exists?("/etc/system-release")
|
63
|
+
contents = File.read("/etc/system-release").chomp
|
64
|
+
platform get_redhatish_platform(contents)
|
65
|
+
platform_version get_redhatish_version(contents)
|
66
|
+
elsif File.exists?('/etc/gentoo-release')
|
67
|
+
platform "gentoo"
|
68
|
+
platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
|
69
|
+
elsif File.exists?('/etc/SuSE-release')
|
70
|
+
platform "suse"
|
71
|
+
suse_release = File.read("/etc/SuSE-release")
|
72
|
+
platform_version suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
73
|
+
platform_version suse_release.scan(/VERSION = ([\d\.]{2,})/).flatten.join(".") if platform_version == ""
|
74
|
+
elsif File.exists?('/etc/slackware-version')
|
75
|
+
platform "slackware"
|
76
|
+
platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
77
|
+
elsif File.exists?('/etc/arch-release')
|
78
|
+
platform "arch"
|
79
|
+
# no way to determine platform_version in a rolling release distribution
|
80
|
+
# kernel release will be used - ex. 2.6.32-ARCH
|
81
|
+
elsif lsb[:id] =~ /RedHat/i
|
82
|
+
platform "redhat"
|
83
|
+
platform_version lsb[:release]
|
84
|
+
elsif lsb[:id] =~ /Amazon/i
|
85
|
+
platform "amazon"
|
86
|
+
platform_version lsb[:release]
|
87
|
+
elsif lsb[:id] =~ /ScientificSL/i
|
88
|
+
platform "scientific"
|
89
|
+
platform_version lsb[:release]
|
90
|
+
elsif lsb[:id] =~ /XenServer/i
|
91
|
+
platform "xenserver"
|
92
|
+
platform_version lsb[:release]
|
93
|
+
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
|
94
|
+
platform lsb[:id].downcase
|
95
|
+
platform_version lsb[:release]
|
96
|
+
end
|
30
97
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
elsif lsb[:id] =~ /LinuxMint/i
|
47
|
-
platform "linuxmint"
|
48
|
-
platform_version lsb[:release]
|
49
|
-
else
|
50
|
-
if File.exists?("/usr/bin/raspi-config")
|
51
|
-
platform "raspbian"
|
52
|
-
else
|
53
|
-
platform "debian"
|
98
|
+
case platform
|
99
|
+
when /debian/, /ubuntu/, /linuxmint/, /raspbian/
|
100
|
+
platform_family "debian"
|
101
|
+
when /fedora/
|
102
|
+
platform_family "fedora"
|
103
|
+
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
104
|
+
platform_family "rhel"
|
105
|
+
when /suse/
|
106
|
+
platform_family "suse"
|
107
|
+
when /gentoo/
|
108
|
+
platform_family "gentoo"
|
109
|
+
when /slackware/
|
110
|
+
platform_family "slackware"
|
111
|
+
when /arch/
|
112
|
+
platform_family "arch"
|
54
113
|
end
|
55
|
-
platform_version File.read("/etc/debian_version").chomp
|
56
114
|
end
|
57
|
-
elsif File.exists?("/etc/redhat-release")
|
58
|
-
contents = File.read("/etc/redhat-release").chomp
|
59
|
-
platform get_redhatish_platform(contents)
|
60
|
-
platform_version get_redhatish_version(contents)
|
61
|
-
elsif File.exists?("/etc/system-release")
|
62
|
-
contents = File.read("/etc/system-release").chomp
|
63
|
-
platform get_redhatish_platform(contents)
|
64
|
-
platform_version get_redhatish_version(contents)
|
65
|
-
elsif File.exists?('/etc/gentoo-release')
|
66
|
-
platform "gentoo"
|
67
|
-
platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
|
68
|
-
elsif File.exists?('/etc/SuSE-release')
|
69
|
-
platform "suse"
|
70
|
-
suse_release = File.read("/etc/SuSE-release")
|
71
|
-
platform_version suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
72
|
-
platform_version suse_release.scan(/VERSION = ([\d\.]{2,})/).flatten.join(".") if platform_version == ""
|
73
|
-
elsif File.exists?('/etc/slackware-version')
|
74
|
-
platform "slackware"
|
75
|
-
platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
76
|
-
elsif File.exists?('/etc/arch-release')
|
77
|
-
platform "arch"
|
78
|
-
# no way to determine platform_version in a rolling release distribution
|
79
|
-
# kernel release will be used - ex. 2.6.32-ARCH
|
80
|
-
elsif lsb[:id] =~ /RedHat/i
|
81
|
-
platform "redhat"
|
82
|
-
platform_version lsb[:release]
|
83
|
-
elsif lsb[:id] =~ /Amazon/i
|
84
|
-
platform "amazon"
|
85
|
-
platform_version lsb[:release]
|
86
|
-
elsif lsb[:id] =~ /ScientificSL/i
|
87
|
-
platform "scientific"
|
88
|
-
platform_version lsb[:release]
|
89
|
-
elsif lsb[:id] =~ /XenServer/i
|
90
|
-
platform "xenserver"
|
91
|
-
platform_version lsb[:release]
|
92
|
-
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
|
93
|
-
platform lsb[:id].downcase
|
94
|
-
platform_version lsb[:release]
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
case platform
|
99
|
-
when /debian/, /ubuntu/, /linuxmint/, /raspbian/
|
100
|
-
platform_family "debian"
|
101
|
-
when /fedora/
|
102
|
-
platform_family "fedora"
|
103
|
-
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
104
|
-
platform_family "rhel"
|
105
|
-
when /suse/
|
106
|
-
platform_family "suse"
|
107
|
-
when /gentoo/
|
108
|
-
platform_family "gentoo"
|
109
|
-
when /slackware/
|
110
|
-
platform_family "slackware"
|
111
|
-
when /arch/
|
112
|
-
platform_family "arch"
|
113
115
|
end
|
@@ -16,110 +16,115 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Virtualization) do
|
20
|
+
provides "virtualization"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:linux) do
|
23
|
+
virtualization Mash.new
|
22
24
|
|
23
|
-
# if it is possible to detect paravirt vs hardware virt, it should be put in
|
24
|
-
# virtualization[:mechanism]
|
25
|
+
# if it is possible to detect paravirt vs hardware virt, it should be put in
|
26
|
+
# virtualization[:mechanism]
|
25
27
|
|
26
|
-
## Xen
|
27
|
-
# /proc/xen is an empty dir for EL6 + Linode Guests
|
28
|
-
if File.exists?("/proc/xen")
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
## Xen
|
29
|
+
# /proc/xen is an empty dir for EL6 + Linode Guests
|
30
|
+
if File.exists?("/proc/xen")
|
31
|
+
virtualization[:system] = "xen"
|
32
|
+
# Assume guest
|
33
|
+
virtualization[:role] = "guest"
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
# This file should exist on most Xen systems, normally empty for guests
|
36
|
+
if File.exists?("/proc/xen/capabilities")
|
37
|
+
if File.read("/proc/xen/capabilities") =~ /control_d/i
|
38
|
+
virtualization[:role] = "host"
|
39
|
+
end
|
40
|
+
end
|
37
41
|
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Xen Notes:
|
42
|
-
# - cpuid of guests, if we could get it, would also be a clue
|
43
|
-
# - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
|
44
|
-
# - EL6 guests carry a 'hypervisor' cpu flag
|
45
|
-
# - Additional edge cases likely should not change the above assumptions
|
46
|
-
# but rather be additive - btm
|
47
|
-
|
48
|
-
# Detect from kernel module
|
49
|
-
if File.exists?("/proc/modules")
|
50
|
-
modules = File.read("/proc/modules")
|
51
|
-
if modules =~ /^kvm/
|
52
|
-
virtualization[:system] = "kvm"
|
53
|
-
virtualization[:role] = "host"
|
54
|
-
elsif modules =~ /^vboxdrv/
|
55
|
-
virtualization[:system] = "vbox"
|
56
|
-
virtualization[:role] = "host"
|
57
|
-
elsif modules =~ /^vboxguest/
|
58
|
-
virtualization[:system] = "vbox"
|
59
|
-
virtualization[:role] = "guest"
|
60
|
-
end
|
61
|
-
end
|
62
42
|
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
|
69
|
-
if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU/
|
70
|
-
virtualization[:system] = "kvm"
|
71
|
-
virtualization[:role] = "guest"
|
72
|
-
end
|
73
|
-
end
|
43
|
+
# Xen Notes:
|
44
|
+
# - cpuid of guests, if we could get it, would also be a clue
|
45
|
+
# - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
|
46
|
+
# - EL6 guests carry a 'hypervisor' cpu flag
|
47
|
+
# - Additional edge cases likely should not change the above assumptions
|
48
|
+
# but rather be additive - btm
|
74
49
|
|
75
|
-
# Detect
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if File.exists?("/usr/sbin/dmidecode")
|
87
|
-
popen4("dmidecode") do |pid, stdin, stdout, stderr|
|
88
|
-
stdin.close
|
89
|
-
dmi_info = stdout.read
|
90
|
-
case dmi_info
|
91
|
-
when /Manufacturer: Microsoft/
|
92
|
-
if dmi_info =~ /Product Name: Virtual Machine/
|
93
|
-
virtualization[:system] = "virtualpc"
|
50
|
+
# Detect from kernel module
|
51
|
+
if File.exists?("/proc/modules")
|
52
|
+
modules = File.read("/proc/modules")
|
53
|
+
if modules =~ /^kvm/
|
54
|
+
virtualization[:system] = "kvm"
|
55
|
+
virtualization[:role] = "host"
|
56
|
+
elsif modules =~ /^vboxdrv/
|
57
|
+
virtualization[:system] = "vbox"
|
58
|
+
virtualization[:role] = "host"
|
59
|
+
elsif modules =~ /^vboxguest/
|
60
|
+
virtualization[:system] = "vbox"
|
94
61
|
virtualization[:role] = "guest"
|
95
62
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
63
|
+
end
|
64
|
+
|
65
|
+
# Detect KVM/QEMU from cpuinfo, report as KVM
|
66
|
+
# We could pick KVM from 'Booting paravirtualized kernel on KVM' in dmesg
|
67
|
+
# 2.6.27-9-server (intrepid) has this / 2.6.18-6-amd64 (etch) does not
|
68
|
+
# It would be great if we could read pv_info in the kernel
|
69
|
+
# Wait for reply to: http://article.gmane.org/gmane.comp.emulators.kvm.devel/27885
|
70
|
+
if File.exists?("/proc/cpuinfo")
|
71
|
+
if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
|
72
|
+
virtualization[:system] = "kvm"
|
104
73
|
virtualization[:role] = "guest"
|
105
74
|
end
|
106
|
-
else
|
107
|
-
nil
|
108
75
|
end
|
109
76
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
if File.exists?("/proc/self/status")
|
115
|
-
proc_self_status = File.read("/proc/self/status")
|
116
|
-
vxid = proc_self_status.match(/^(s_context|VxID): (\d+)$/)
|
117
|
-
if vxid and vxid[2]
|
118
|
-
virtualization[:system] = "linux-vserver"
|
119
|
-
if vxid[2] == "0"
|
77
|
+
# Detect OpenVZ / Virtuozzo.
|
78
|
+
# http://wiki.openvz.org/BC_proc_entries
|
79
|
+
if File.exists?("/proc/bc/0")
|
80
|
+
virtualization[:system] = "openvz"
|
120
81
|
virtualization[:role] = "host"
|
121
|
-
|
82
|
+
elsif File.exists?("/proc/vz")
|
83
|
+
virtualization[:system] = "openvz"
|
122
84
|
virtualization[:role] = "guest"
|
123
|
-
|
85
|
+
end
|
86
|
+
|
87
|
+
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
88
|
+
if File.exists?("/usr/sbin/dmidecode")
|
89
|
+
so = shell_out("dmidecode")
|
90
|
+
case so.stdout
|
91
|
+
when /Manufacturer: Microsoft/
|
92
|
+
if so.stdout =~ /Product Name: Virtual Machine/
|
93
|
+
virtualization[:system] = "virtualpc"
|
94
|
+
virtualization[:role] = "guest"
|
95
|
+
end
|
96
|
+
when /Manufacturer: VMware/
|
97
|
+
if so.stdout =~ /Product Name: VMware Virtual Platform/
|
98
|
+
virtualization[:system] = "vmware"
|
99
|
+
virtualization[:role] = "guest"
|
100
|
+
end
|
101
|
+
when /Manufacturer: Xen/
|
102
|
+
if so.stdout =~ /Product Name: HVM domU/
|
103
|
+
virtualization[:system] = "xen"
|
104
|
+
virtualization[:role] = "guest"
|
105
|
+
end
|
106
|
+
when /Manufacturer: Oracle Corporation/
|
107
|
+
if so.stdout =~ /Product Name: VirtualBox/
|
108
|
+
virtualization[:system] = "vbox"
|
109
|
+
virtualization[:role] = "guest"
|
110
|
+
end
|
111
|
+
else
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Detect Linux-VServer
|
117
|
+
if File.exists?("/proc/self/status")
|
118
|
+
proc_self_status = File.read("/proc/self/status")
|
119
|
+
vxid = proc_self_status.match(/^(s_context|VxID): (\d+)$/)
|
120
|
+
if vxid and vxid[2]
|
121
|
+
virtualization[:system] = "linux-vserver"
|
122
|
+
if vxid[2] == "0"
|
123
|
+
virtualization[:role] = "host"
|
124
|
+
else
|
125
|
+
virtualization[:role] = "guest"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
124
129
|
end
|
125
130
|
end
|
data/lib/ohai/plugins/lua.rb
CHANGED
@@ -16,19 +16,23 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Lua) do
|
20
|
+
provides "languages/lua"
|
20
21
|
|
21
|
-
|
22
|
+
depends "languages"
|
22
23
|
|
23
|
-
|
24
|
+
collect_data do
|
25
|
+
output = nil
|
24
26
|
|
25
|
-
lua = Mash.new
|
27
|
+
lua = Mash.new
|
26
28
|
|
27
|
-
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
so = shell_out("lua -v")
|
30
|
+
if so.exitstatus == 0
|
31
|
+
output = so.stderr.split
|
32
|
+
if output.length >= 1
|
33
|
+
lua[:version] = output[1]
|
34
|
+
end
|
35
|
+
languages[:lua] = lua if lua[:version]
|
36
|
+
end
|
32
37
|
end
|
33
|
-
languages[:lua] = lua if lua[:version]
|
34
38
|
end
|
data/lib/ohai/plugins/mono.rb
CHANGED
@@ -16,22 +16,26 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Mono) do
|
20
|
+
provides "languages/mono"
|
20
21
|
|
21
|
-
|
22
|
+
depends "languages"
|
22
23
|
|
23
|
-
|
24
|
+
collect_data do
|
25
|
+
output = nil
|
24
26
|
|
25
|
-
mono = Mash.new
|
27
|
+
mono = Mash.new
|
26
28
|
|
27
|
-
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
so = shell_out("mono -V")
|
30
|
+
if so.exitstatus == 0
|
31
|
+
output = so.stdout.split
|
32
|
+
if output.length >= 4
|
33
|
+
mono[:version] = output[4]
|
34
|
+
end
|
35
|
+
if output.length >= 11
|
36
|
+
mono[:builddate] = "%s %s %s %s" % [output[6],output[7],output[8],output[11].gsub!(/\)/,'')]
|
37
|
+
end
|
38
|
+
languages[:mono] = mono if mono[:version]
|
39
|
+
end
|
32
40
|
end
|
33
|
-
if output.length >= 11
|
34
|
-
mono[:builddate] = "%s %s %s %s" % [output[6],output[7],output[8],output[11].gsub!(/\)/,'')]
|
35
|
-
end
|
36
|
-
languages[:mono] = mono if mono[:version]
|
37
41
|
end
|