rightscale-ohai 0.3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +98 -0
- data/Rakefile +59 -0
- data/bin/ohai +78 -0
- data/lib/ohai/config.rb +118 -0
- data/lib/ohai/exception.rb +23 -0
- data/lib/ohai/log/formatter.rb +57 -0
- data/lib/ohai/log.rb +89 -0
- data/lib/ohai/mixin/command.rb +203 -0
- data/lib/ohai/mixin/from_file.rb +36 -0
- data/lib/ohai/mixin/string.rb +29 -0
- data/lib/ohai/plugins/cloud.rb +35 -0
- data/lib/ohai/plugins/command.rb +21 -0
- data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
- data/lib/ohai/plugins/darwin/hostname.rb +22 -0
- data/lib/ohai/plugins/darwin/kernel.rb +37 -0
- data/lib/ohai/plugins/darwin/network.rb +187 -0
- data/lib/ohai/plugins/darwin/platform.rb +36 -0
- data/lib/ohai/plugins/darwin/ps.rb +23 -0
- data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
- data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
- data/lib/ohai/plugins/darwin/uptime.rb +32 -0
- data/lib/ohai/plugins/dmi.rb +59 -0
- data/lib/ohai/plugins/ec2.rb +100 -0
- data/lib/ohai/plugins/erlang.rb +40 -0
- data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
- data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
- data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
- data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
- data/lib/ohai/plugins/freebsd/memory.rb +50 -0
- data/lib/ohai/plugins/freebsd/network.rb +112 -0
- data/lib/ohai/plugins/freebsd/platform.rb +23 -0
- data/lib/ohai/plugins/freebsd/ps.rb +24 -0
- data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
- data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
- data/lib/ohai/plugins/hostname.rb +27 -0
- data/lib/ohai/plugins/java.rb +36 -0
- data/lib/ohai/plugins/kernel.rb +33 -0
- data/lib/ohai/plugins/keys.rb +22 -0
- data/lib/ohai/plugins/languages.rb +21 -0
- data/lib/ohai/plugins/linux/block_device.rb +38 -0
- data/lib/ohai/plugins/linux/cpu.rb +60 -0
- data/lib/ohai/plugins/linux/filesystem.rb +57 -0
- data/lib/ohai/plugins/linux/hostname.rb +26 -0
- data/lib/ohai/plugins/linux/kernel.rb +33 -0
- data/lib/ohai/plugins/linux/lsb.rb +38 -0
- data/lib/ohai/plugins/linux/memory.rb +83 -0
- data/lib/ohai/plugins/linux/network.rb +112 -0
- data/lib/ohai/plugins/linux/platform.rb +43 -0
- data/lib/ohai/plugins/linux/ps.rb +23 -0
- data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/linux/uptime.rb +28 -0
- data/lib/ohai/plugins/linux/virtualization.rb +77 -0
- data/lib/ohai/plugins/network.rb +52 -0
- data/lib/ohai/plugins/ohai_time.rb +21 -0
- data/lib/ohai/plugins/os.rb +43 -0
- data/lib/ohai/plugins/perl.rb +37 -0
- data/lib/ohai/plugins/platform.rb +25 -0
- data/lib/ohai/plugins/python.rb +37 -0
- data/lib/ohai/plugins/rightscale.rb +53 -0
- data/lib/ohai/plugins/ruby.rb +37 -0
- data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
- data/lib/ohai/plugins/solaris2/hostname.rb +22 -0
- data/lib/ohai/plugins/solaris2/kernel.rb +21 -0
- data/lib/ohai/plugins/solaris2/network.rb +141 -0
- data/lib/ohai/plugins/solaris2/platform.rb +33 -0
- data/lib/ohai/plugins/solaris2/ps.rb +23 -0
- data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
- data/lib/ohai/plugins/uptime.rb +42 -0
- data/lib/ohai/plugins/virtualization.rb +86 -0
- data/lib/ohai/plugins/windows/filesystem.rb +44 -0
- data/lib/ohai/plugins/windows/hostname.rb +25 -0
- data/lib/ohai/plugins/windows/kernel.rb +75 -0
- data/lib/ohai/plugins/windows/network.rb +114 -0
- data/lib/ohai/plugins/windows/platform.rb +26 -0
- data/lib/ohai/system.rb +226 -0
- data/lib/ohai.rb +27 -0
- data/spec/ohai/log/log_formatter_spec.rb +50 -0
- data/spec/ohai/log_spec.rb +63 -0
- data/spec/ohai/mixin/from_file_spec.rb +53 -0
- data/spec/ohai/plugins/cloud_spec.rb +64 -0
- data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
- data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
- data/spec/ohai/plugins/dmi_spec.rb +73 -0
- data/spec/ohai/plugins/ec2_spec.rb +77 -0
- data/spec/ohai/plugins/erlang_spec.rb +63 -0
- data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
- data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
- data/spec/ohai/plugins/hostname_spec.rb +39 -0
- data/spec/ohai/plugins/java_spec.rb +70 -0
- data/spec/ohai/plugins/kernel_spec.rb +43 -0
- data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
- data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
- data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
- data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
- data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
- data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
- data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
- data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
- data/spec/ohai/plugins/os_spec.rb +58 -0
- data/spec/ohai/plugins/perl_spec.rb +89 -0
- data/spec/ohai/plugins/platform_spec.rb +56 -0
- data/spec/ohai/plugins/python_spec.rb +53 -0
- data/spec/ohai/plugins/rightscale_spec.rb +71 -0
- data/spec/ohai/plugins/ruby_spec.rb +51 -0
- data/spec/ohai/system_spec.rb +130 -0
- data/spec/ohai_spec.rb +27 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +66 -0
- metadata +209 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "network", "counters/network"
|
20
|
+
|
21
|
+
network[:default_interface] = from("route -n get default \| grep interface: \| awk \'/: / \{print \$2\}\'")
|
22
|
+
|
23
|
+
iface = Mash.new
|
24
|
+
popen4("/sbin/ifconfig -a") do |pid, stdin, stdout, stderr|
|
25
|
+
stdin.close
|
26
|
+
cint = nil
|
27
|
+
stdout.each do |line|
|
28
|
+
if line =~ /^([0-9a-zA-Z\.]+):\s+/
|
29
|
+
cint = $1
|
30
|
+
iface[cint] = Mash.new
|
31
|
+
if cint =~ /^(\w+)(\d+.*)/
|
32
|
+
iface[cint][:type] = $1
|
33
|
+
iface[cint][:number] = $2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
# call the family lladdr to match linux for consistency
|
37
|
+
if line =~ /\s+ether (.+?)\s/
|
38
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
39
|
+
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
40
|
+
end
|
41
|
+
if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
|
42
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
43
|
+
# convert the netmask to decimal for consistency
|
44
|
+
netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
|
45
|
+
if $3.empty?
|
46
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
|
47
|
+
else
|
48
|
+
# found a broadcast address
|
49
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
|
53
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
54
|
+
if $4.empty?
|
55
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
|
56
|
+
else
|
57
|
+
# found a zone_id / scope
|
58
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if line =~ /flags=\d+<(.+)>/
|
62
|
+
flags = $1.split(',')
|
63
|
+
iface[cint][:flags] = flags if flags.length > 0
|
64
|
+
end
|
65
|
+
if line =~ /metric: (\d+) mtu: (\d+)/
|
66
|
+
iface[cint][:metric] = $1
|
67
|
+
iface[cint][:mtu] = $2
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
popen4("arp -an") do |pid, stdin, stdout, stderr|
|
73
|
+
stdin.close
|
74
|
+
stdout.each do |line|
|
75
|
+
if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
|
76
|
+
next unless iface[$3] # this should never happen
|
77
|
+
iface[$3][:arp] = Mash.new unless iface[$3][:arp]
|
78
|
+
iface[$3][:arp][$1] = $2.downcase
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
network["interfaces"] = iface
|
84
|
+
|
85
|
+
net_counters = Mash.new
|
86
|
+
# From netstat(1), not sure of the implications:
|
87
|
+
# Show the state of all network interfaces or a single interface
|
88
|
+
# which have been auto-configured (interfaces statically configured
|
89
|
+
# into a system, but not located at boot time are not shown).
|
90
|
+
popen4("netstat -ibdn") do |pid, stdin, stdout, stderr|
|
91
|
+
stdin.close
|
92
|
+
stdout.each do |line|
|
93
|
+
# Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
94
|
+
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
95
|
+
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
|
96
|
+
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+)/
|
97
|
+
net_counters[$1] = Mash.new unless net_counters[$1]
|
98
|
+
net_counters[$1]["rx"] = Mash.new unless net_counters[$1]["rx"]
|
99
|
+
net_counters[$1]["tx"] = Mash.new unless net_counters[$1]["tx"]
|
100
|
+
net_counters[$1]["rx"]["packets"] = $3
|
101
|
+
net_counters[$1]["rx"]["errors"] = $4
|
102
|
+
net_counters[$1]["rx"]["bytes"] = $5
|
103
|
+
net_counters[$1]["tx"]["packets"] = $6
|
104
|
+
net_counters[$1]["tx"]["errors"] = $7
|
105
|
+
net_counters[$1]["tx"]["bytes"] = $8
|
106
|
+
net_counters[$1]["tx"]["collisions"] = $9
|
107
|
+
net_counters[$1]["tx"]["dropped"] = $10
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
counters[:network][:interfaces] = net_counters
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "platform", "platform_version"
|
20
|
+
|
21
|
+
platform from("uname -s").downcase
|
22
|
+
platform_version from("uname -r")
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "command/ps"
|
20
|
+
|
21
|
+
require_plugin 'command'
|
22
|
+
|
23
|
+
# ps -e requires procfs
|
24
|
+
command[:ps] = 'ps -ax'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "keys/ssh"
|
20
|
+
|
21
|
+
require_plugin "keys"
|
22
|
+
|
23
|
+
keys[:ssh] = Mash.new
|
24
|
+
|
25
|
+
keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
26
|
+
keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "uptime", "uptime_seconds"
|
20
|
+
|
21
|
+
# kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
|
22
|
+
|
23
|
+
popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
|
24
|
+
stdin.close
|
25
|
+
stdout.each do |line|
|
26
|
+
if line =~ /kern.boottime:\D+(\d+)/
|
27
|
+
uptime_seconds Time.new.to_i - $1.to_i
|
28
|
+
uptime self._seconds_to_human(uptime_seconds)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "virtualization"
|
20
|
+
|
21
|
+
virtualization Mash.new
|
22
|
+
|
23
|
+
# KVM Host support for FreeBSD is in development
|
24
|
+
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
25
|
+
|
26
|
+
# Detect KVM/QEMU from cpu, report as KVM
|
27
|
+
# hw.model: QEMU Virtual CPU version 0.9.1
|
28
|
+
if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
|
29
|
+
virtualization[:system] = "kvm"
|
30
|
+
virtualization[:role] = "guest"
|
31
|
+
end
|
32
|
+
|
33
|
+
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
34
|
+
if File.exists?("/usr/local/sbin/dmidecode")
|
35
|
+
popen4("dmidecode") do |pid, stdin, stdout, stderr|
|
36
|
+
stdin.close
|
37
|
+
found_virt_manufacturer = nil
|
38
|
+
found_virt_product = nil
|
39
|
+
stdout.each do |line|
|
40
|
+
case line
|
41
|
+
when /Manufacturer: Microsoft/
|
42
|
+
found_virt_manufacturer = "microsoft"
|
43
|
+
when /Product Name: Virtual Machine/
|
44
|
+
found_virt_product = "microsoft"
|
45
|
+
when /Version: 5.0/
|
46
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
47
|
+
virtualization[:system] = "virtualpc"
|
48
|
+
virtualization[:role] = "guest"
|
49
|
+
end
|
50
|
+
when /Version: VS2005R2/
|
51
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
52
|
+
virtualization[:system] = "virtualserver"
|
53
|
+
virtualization[:role] = "guest"
|
54
|
+
end
|
55
|
+
when /Manufacturer: VMware/
|
56
|
+
found_virt_manufacturer = "vmware"
|
57
|
+
when /Product Name: VMware Virtual Platform/
|
58
|
+
if found_virt_manufacturer == "vmware"
|
59
|
+
virtualization[:system] = "vmware"
|
60
|
+
virtualization[:role] = "guest"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "fqdn", "domain"
|
20
|
+
|
21
|
+
require_plugin "#{os}::hostname"
|
22
|
+
|
23
|
+
# Domain is everything after the first dot
|
24
|
+
if fqdn
|
25
|
+
fqdn =~ /.+?\.(.*)/
|
26
|
+
domain $1
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Benjamin Black (<bb@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
provides "languages/java"
|
19
|
+
|
20
|
+
require_plugin "languages"
|
21
|
+
|
22
|
+
java = Mash.new
|
23
|
+
|
24
|
+
status, stdout, stderr = run_command(:no_status_check => true, :command => "java -version")
|
25
|
+
|
26
|
+
if status == 0
|
27
|
+
stderr.split("\n").each do |line|
|
28
|
+
case line
|
29
|
+
when /java version \"([0-9\.\_]+)\"/: java[:version] = $1
|
30
|
+
when /^(.+Runtime Environment.*) \(build (.+)\)$/: java[:runtime] = { "name" => $1, "build" => $2 }
|
31
|
+
when /^(.+ Client VM) \(build (.+)\)$/: java[:hotspot] = { "name" => $1, "build" => $2 }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
languages[:java] = java if java[:version]
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "kernel"
|
20
|
+
|
21
|
+
require_plugin 'ruby'
|
22
|
+
|
23
|
+
kernel Mash.new
|
24
|
+
case languages[:ruby][:host_os]
|
25
|
+
when /mswin/
|
26
|
+
require_plugin "windows::kernel"
|
27
|
+
else
|
28
|
+
kernel[:name] = from("uname -s")
|
29
|
+
kernel[:release] = from("uname -r")
|
30
|
+
kernel[:version] = from("uname -v")
|
31
|
+
kernel[:machine] = from("uname -m")
|
32
|
+
kernel[:modules] = Mash.new
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: apache2
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
# Copyright 2008, OpsCode, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
provides "keys"
|
21
|
+
|
22
|
+
keys Mash.new
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "languages"
|
20
|
+
|
21
|
+
languages Mash.new
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "block_device"
|
20
|
+
|
21
|
+
if File.exists?("/sys/block")
|
22
|
+
block = Mash.new
|
23
|
+
Dir["/sys/block/*"].each do |block_device_dir|
|
24
|
+
dir = File.basename(block_device_dir)
|
25
|
+
block[dir] = Mash.new
|
26
|
+
%w{size removable}.each do |check|
|
27
|
+
if File.exists?("/sys/block/#{dir}/#{check}")
|
28
|
+
block[dir][check] = `cat "/sys/block/#{dir}/#{check}"`.chomp
|
29
|
+
end
|
30
|
+
end
|
31
|
+
%w{model rev state timeout vendor}.each do |check|
|
32
|
+
if File.exists?("/sys/block/#{dir}/device/#{check}")
|
33
|
+
block[dir][check] = `cat "/sys/block/#{dir}/device/#{check}"`.chomp
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
block_device block
|
38
|
+
end
|