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
@@ -14,96 +14,101 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
|
17
|
+
Ohai.plugin(:Rackspace) do
|
18
|
+
provides "rackspace"
|
18
19
|
|
19
|
-
|
20
|
-
require_plugin "network"
|
20
|
+
depends "kernel", "network/interfaces"
|
21
21
|
|
22
|
-
# Checks for matching rackspace kernel name
|
23
|
-
#
|
24
|
-
# === Return
|
25
|
-
# true:: If kernel name matches
|
26
|
-
# false:: Otherwise
|
27
|
-
def has_rackspace_kernel?
|
28
|
-
|
29
|
-
end
|
22
|
+
# Checks for matching rackspace kernel name
|
23
|
+
#
|
24
|
+
# === Return
|
25
|
+
# true:: If kernel name matches
|
26
|
+
# false:: Otherwise
|
27
|
+
def has_rackspace_kernel?
|
28
|
+
kernel[:release].split('-').last.eql?("rscloud")
|
29
|
+
end
|
30
30
|
|
31
|
-
# Checks for rackspace provider attribute
|
32
|
-
#
|
33
|
-
# === Return
|
34
|
-
# true:: If rackspace provider attribute found
|
35
|
-
# false:: Otherwise
|
36
|
-
def has_rackspace_metadata?
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
# Checks for rackspace provider attribute
|
32
|
+
#
|
33
|
+
# === Return
|
34
|
+
# true:: If rackspace provider attribute found
|
35
|
+
# false:: Otherwise
|
36
|
+
def has_rackspace_metadata?
|
37
|
+
so = shell_out("xenstore-read vm-data/provider_data/provider")
|
38
|
+
if so.exitstatus == 0
|
39
|
+
so.stdout.strip.downcase == 'rackspace'
|
40
|
+
end
|
41
|
+
rescue Ohai::Exceptions::Exec
|
42
|
+
false
|
40
43
|
end
|
41
|
-
rescue Ohai::Exceptions::Exec
|
42
|
-
false
|
43
|
-
end
|
44
44
|
|
45
|
-
# Identifies the rackspace cloud
|
46
|
-
#
|
47
|
-
# === Return
|
48
|
-
# true:: If the rackspace cloud can be identified
|
49
|
-
# false:: Otherwise
|
50
|
-
def looks_like_rackspace?
|
51
|
-
|
52
|
-
end
|
45
|
+
# Identifies the rackspace cloud
|
46
|
+
#
|
47
|
+
# === Return
|
48
|
+
# true:: If the rackspace cloud can be identified
|
49
|
+
# false:: Otherwise
|
50
|
+
def looks_like_rackspace?
|
51
|
+
hint?('rackspace') || has_rackspace_metadata? || has_rackspace_kernel?
|
52
|
+
end
|
53
53
|
|
54
|
-
# Names rackspace ip address
|
55
|
-
#
|
56
|
-
# === Parameters
|
57
|
-
# name<Symbol>:: Use :public_ip or :private_ip
|
58
|
-
# eth<Symbol>:: Interface name of public or private ip
|
59
|
-
def get_ip_address(name, eth)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
# Names rackspace ip address
|
55
|
+
#
|
56
|
+
# === Parameters
|
57
|
+
# name<Symbol>:: Use :public_ip or :private_ip
|
58
|
+
# eth<Symbol>:: Interface name of public or private ip
|
59
|
+
def get_ip_address(name, eth)
|
60
|
+
network[:interfaces][eth][:addresses].each do |key, info|
|
61
|
+
if info['family'] == 'inet'
|
62
|
+
rackspace[name] = key
|
63
|
+
break # break when we found an address
|
64
|
+
end
|
64
65
|
end
|
65
66
|
end
|
66
|
-
end
|
67
67
|
|
68
|
-
# Names rackspace ipv6 address for interface
|
69
|
-
#
|
70
|
-
# === Parameters
|
71
|
-
# name<Symbol>:: Use :public_ip or :private_ip
|
72
|
-
# eth<Symbol>:: Interface name of public or private ip
|
73
|
-
def get_global_ipv6_address(name, eth)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
# Names rackspace ipv6 address for interface
|
69
|
+
#
|
70
|
+
# === Parameters
|
71
|
+
# name<Symbol>:: Use :public_ip or :private_ip
|
72
|
+
# eth<Symbol>:: Interface name of public or private ip
|
73
|
+
def get_global_ipv6_address(name, eth)
|
74
|
+
network[:interfaces][eth][:addresses].each do |key, info|
|
75
|
+
# check if we got an ipv6 address and if its in global scope
|
76
|
+
if info['family'] == 'inet6' && info['scope'] == 'Global'
|
77
|
+
rackspace[name] = key
|
78
|
+
break # break when we found an address
|
79
|
+
end
|
79
80
|
end
|
80
81
|
end
|
81
|
-
end
|
82
82
|
|
83
|
-
# Get the rackspace region
|
84
|
-
#
|
85
|
-
def get_region()
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
# Get the rackspace region
|
84
|
+
#
|
85
|
+
def get_region()
|
86
|
+
so = shell_out("xenstore-ls vm-data/provider_data")
|
87
|
+
if so.exitstatus == 0
|
88
|
+
so.stdout.split("\n").each do |line|
|
89
|
+
rackspace[:region] = line.split[2].delete('\"') if line =~ /^region/
|
90
|
+
end
|
90
91
|
end
|
92
|
+
rescue Ohai::Exceptions::Exec
|
93
|
+
Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
|
91
94
|
end
|
92
|
-
rescue Ohai::Exceptions::Exec
|
93
|
-
Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
|
94
|
-
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
96
|
+
collect_data do
|
97
|
+
# Adds rackspace Mash
|
98
|
+
if looks_like_rackspace?
|
99
|
+
rackspace Mash.new
|
100
|
+
get_ip_address(:public_ip, :eth0)
|
101
|
+
get_ip_address(:private_ip, :eth1)
|
102
|
+
get_region()
|
103
|
+
# public_ip + private_ip are deprecated in favor of public_ipv4 and local_ipv4 to standardize.
|
104
|
+
rackspace[:public_ipv4] = rackspace[:public_ip]
|
105
|
+
get_global_ipv6_address(:public_ipv6, :eth0)
|
106
|
+
unless rackspace[:public_ip].nil?
|
107
|
+
rackspace[:public_hostname] = "#{rackspace[:public_ip].gsub('.','-')}.static.cloud-ips.com"
|
108
|
+
end
|
109
|
+
rackspace[:local_ipv4] = rackspace[:private_ip]
|
110
|
+
get_global_ipv6_address(:local_ipv6, :eth1)
|
111
|
+
rackspace[:local_hostname] = hostname
|
112
|
+
end
|
113
|
+
end
|
109
114
|
end
|
@@ -15,14 +15,18 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
|
18
|
+
Ohai.plugin(:RootGroup) do
|
19
|
+
provides 'root_group'
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
collect_data do
|
22
|
+
case ::RbConfig::CONFIG['host_os']
|
23
|
+
when /mswin|mingw32|windows/
|
24
|
+
# TODO: OHAI-491
|
25
|
+
# http://tickets.opscode.com/browse/OHAI-491
|
26
|
+
# The windows implementation of this plugin has been removed because of
|
27
|
+
# performance considerations (see: OHAI-490).
|
28
|
+
else
|
29
|
+
root_group Etc.getgrgid(Etc.getpwnam('root').gid).name
|
30
|
+
end
|
31
|
+
end
|
28
32
|
end
|
data/lib/ohai/plugins/ruby.rb
CHANGED
@@ -16,60 +16,62 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Ruby) do
|
20
|
+
provides "languages/ruby"
|
20
21
|
|
21
|
-
|
22
|
+
depends "languages"
|
22
23
|
|
24
|
+
def run_ruby(command)
|
25
|
+
cmd = "ruby -e \"require 'rbconfig'; #{command}\""
|
26
|
+
so = shell_out(cmd)
|
27
|
+
so.stdout.strip
|
28
|
+
end
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
status, stdout, stderr = run_command(:no_status_check => true, :command => cmd)
|
27
|
-
stdout.strip
|
28
|
-
end
|
29
|
-
|
30
|
+
collect_data do
|
31
|
+
languages[:ruby] = Mash.new
|
30
32
|
|
31
|
-
|
33
|
+
values = {
|
34
|
+
:platform => "RUBY_PLATFORM",
|
35
|
+
:version => "RUBY_VERSION",
|
36
|
+
:release_date => "RUBY_RELEASE_DATE",
|
37
|
+
:target => "::Config::CONFIG['target']",
|
38
|
+
:target_cpu => "::Config::CONFIG['target_cpu']",
|
39
|
+
:target_vendor => "::Config::CONFIG['target_vendor']",
|
40
|
+
:target_os => "::Config::CONFIG['target_os']",
|
41
|
+
:host => "::Config::CONFIG['host']",
|
42
|
+
:host_cpu => "::Config::CONFIG['host_cpu']",
|
43
|
+
:host_os => "::Config::CONFIG['host_os']",
|
44
|
+
:host_vendor => "::Config::CONFIG['host_vendor']",
|
45
|
+
:bin_dir => "::Config::CONFIG['bindir']",
|
46
|
+
:ruby_bin => "::File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])"
|
47
|
+
}
|
32
48
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:target_cpu => "::Config::CONFIG['target_cpu']",
|
39
|
-
:target_vendor => "::Config::CONFIG['target_vendor']",
|
40
|
-
:target_os => "::Config::CONFIG['target_os']",
|
41
|
-
:host => "::Config::CONFIG['host']",
|
42
|
-
:host_cpu => "::Config::CONFIG['host_cpu']",
|
43
|
-
:host_os => "::Config::CONFIG['host_os']",
|
44
|
-
:host_vendor => "::Config::CONFIG['host_vendor']",
|
45
|
-
:bin_dir => "::Config::CONFIG['bindir']",
|
46
|
-
:ruby_bin => "::File.join(::Config::CONFIG['bindir'], ::Config::CONFIG['ruby_install_name'])"
|
47
|
-
}
|
49
|
+
# Create a query string from above hash
|
50
|
+
env_string = ""
|
51
|
+
values.keys.each do |v|
|
52
|
+
env_string << "#{v}=\#{#{values[v]}},"
|
53
|
+
end
|
48
54
|
|
49
|
-
#
|
50
|
-
|
51
|
-
values.keys.each do |v|
|
52
|
-
env_string << "#{v}=\#{#{values[v]}},"
|
53
|
-
end
|
55
|
+
# Query the system ruby
|
56
|
+
result = run_ruby "puts %Q(#{env_string})"
|
54
57
|
|
55
|
-
#
|
56
|
-
result
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
key, value = entry.split('=')
|
61
|
-
languages[:ruby][key.to_sym] = value || ""
|
62
|
-
end
|
58
|
+
# Parse results to plugin hash
|
59
|
+
result.split(',').each do |entry|
|
60
|
+
key, value = entry.split('=')
|
61
|
+
languages[:ruby][key.to_sym] = value || ""
|
62
|
+
end
|
63
63
|
|
64
|
-
# Perform one more (conditional) query
|
65
|
-
bin_dir = languages[:ruby][:bin_dir]
|
66
|
-
ruby_bin = languages[:ruby][:ruby_bin]
|
67
|
-
gem_binaries = [
|
68
|
-
|
69
|
-
|
70
|
-
].map {|bin| ::File.join(bin_dir, bin)}
|
71
|
-
gem_binary = gem_binaries.find {|bin| ::File.exists? bin }
|
72
|
-
if gem_binary
|
73
|
-
|
74
|
-
|
64
|
+
# Perform one more (conditional) query
|
65
|
+
bin_dir = languages[:ruby][:bin_dir]
|
66
|
+
ruby_bin = languages[:ruby][:ruby_bin]
|
67
|
+
gem_binaries = [
|
68
|
+
run_ruby("require 'rubygems'; puts ::Gem.default_exec_format % 'gem'"),
|
69
|
+
"gem"
|
70
|
+
].map {|bin| ::File.join(bin_dir, bin)}
|
71
|
+
gem_binary = gem_binaries.find {|bin| ::File.exists? bin }
|
72
|
+
if gem_binary
|
73
|
+
languages[:ruby][:gems_dir] = run_ruby "puts %x{#{ruby_bin} #{gem_binary} env gemdir}.chomp!"
|
74
|
+
languages[:ruby][:gem_bin] = gem_binary
|
75
|
+
end
|
76
|
+
end
|
75
77
|
end
|
@@ -16,25 +16,29 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:CPU) do
|
20
|
+
provides "cpu"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:hpux, :default) do
|
23
|
+
require 'sigar'
|
22
24
|
|
23
|
-
|
25
|
+
sigar = Sigar.new
|
24
26
|
|
25
|
-
cpuinfo = Mash.new
|
26
|
-
ix = 0
|
27
|
+
cpuinfo = Mash.new
|
28
|
+
ix = 0
|
27
29
|
|
28
|
-
sigar.cpu_info_list.each do |info|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
30
|
+
sigar.cpu_info_list.each do |info|
|
31
|
+
current_cpu = ix.to_s
|
32
|
+
ix += 1
|
33
|
+
cpuinfo[current_cpu] = Mash.new
|
34
|
+
cpuinfo[current_cpu]["vendor_id"] = info.vendor
|
35
|
+
cpuinfo[current_cpu]["model"] = info.model
|
36
|
+
cpuinfo[current_cpu]["mhz"] = info.mhz.to_s
|
37
|
+
cpuinfo[current_cpu]["cache_size"] = info.cache_size.to_s
|
38
|
+
cpuinfo[:total] = info.total_cores
|
39
|
+
cpuinfo[:real] = info.total_sockets
|
40
|
+
end
|
39
41
|
|
40
|
-
cpu cpuinfo
|
42
|
+
cpu cpuinfo
|
43
|
+
end
|
44
|
+
end
|
@@ -16,32 +16,35 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Filesystem) do
|
20
|
+
provides "filesystem"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:hpux, :default) do
|
23
|
+
require "sigar"
|
24
|
+
sigar = Sigar.new
|
22
25
|
|
23
|
-
fs = Mash.new
|
26
|
+
fs = Mash.new
|
24
27
|
|
25
|
-
sigar
|
28
|
+
sigar.file_system_list.each do |fsys|
|
29
|
+
filesystem = fsys.dev_name
|
30
|
+
fs[filesystem] = Mash.new
|
31
|
+
fs[filesystem][:mount] = fsys.dir_name
|
32
|
+
fs[filesystem][:fs_type] = fsys.sys_type_name
|
33
|
+
fs[filesystem][:mount_options] = fsys.options
|
34
|
+
begin
|
35
|
+
usage = sigar.file_system_usage(fsys.dir_name)
|
36
|
+
fs[filesystem][:kb_size] = (usage.total / 1024).to_s
|
37
|
+
fs[filesystem][:kb_used] = ((usage.total - usage.free) / 1024).to_s
|
38
|
+
fs[filesystem][:kb_available] = (usage.free / 1024).to_s
|
39
|
+
fs[filesystem][:percent_used] = (usage.use_percent * 100).to_s + '%'
|
40
|
+
rescue SystemExit => e
|
41
|
+
raise
|
42
|
+
rescue Exception => e
|
43
|
+
#e.g. floppy or cdrom drive
|
44
|
+
end
|
45
|
+
end
|
26
46
|
|
27
|
-
|
28
|
-
|
29
|
-
fs[filesystem] = Mash.new
|
30
|
-
fs[filesystem][:mount] = fsys.dir_name
|
31
|
-
fs[filesystem][:fs_type] = fsys.sys_type_name
|
32
|
-
fs[filesystem][:mount_options] = fsys.options
|
33
|
-
begin
|
34
|
-
usage = sigar.file_system_usage(fsys.dir_name)
|
35
|
-
fs[filesystem][:kb_size] = (usage.total / 1024).to_s
|
36
|
-
fs[filesystem][:kb_used] = ((usage.total - usage.free) / 1024).to_s
|
37
|
-
fs[filesystem][:kb_available] = (usage.free / 1024).to_s
|
38
|
-
fs[filesystem][:percent_used] = (usage.use_percent * 100).to_s + '%'
|
39
|
-
rescue SystemExit => e
|
40
|
-
raise
|
41
|
-
rescue Exception => e
|
42
|
-
#e.g. floppy or cdrom drive
|
47
|
+
# Set the filesystem data
|
48
|
+
filesystem fs
|
43
49
|
end
|
44
50
|
end
|
45
|
-
|
46
|
-
# Set the filesystem data
|
47
|
-
filesystem fs
|
@@ -16,21 +16,24 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Memory) do
|
20
|
+
provides "memory"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:hpux, :default) do
|
23
|
+
require "sigar"
|
24
|
+
sigar = Sigar.new
|
22
25
|
|
23
|
-
|
26
|
+
memory Mash.new
|
27
|
+
memory[:swap] = Mash.new
|
24
28
|
|
25
|
-
|
26
|
-
|
29
|
+
mem = sigar.mem
|
30
|
+
swap = sigar.swap
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
memory[:total] = (
|
32
|
-
memory[:free] = (
|
33
|
-
memory[:used] = (
|
34
|
-
|
35
|
-
|
36
|
-
memory[:swap][:used] = (swap.used / 1024).to_s + "kB"
|
32
|
+
memory[:total] = (mem.total / 1024).to_s + "kB"
|
33
|
+
memory[:free] = (mem.free / 1024).to_s + "kB"
|
34
|
+
memory[:used] = (mem.used / 1024).to_s + "kB"
|
35
|
+
memory[:swap][:total] = (swap.total / 1024).to_s + "kB"
|
36
|
+
memory[:swap][:free] = (swap.free / 1024).to_s + "kB"
|
37
|
+
memory[:swap][:used] = (swap.used / 1024).to_s + "kB"
|
38
|
+
end
|
39
|
+
end
|