opscode-ohai 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +56 -0
- data/Rakefile +58 -0
- data/bin/ohai +58 -0
- data/lib/ohai.rb +27 -0
- data/lib/ohai/config.rb +118 -0
- data/lib/ohai/exception.rb +23 -0
- data/lib/ohai/log.rb +89 -0
- data/lib/ohai/log/formatter.rb +57 -0
- data/lib/ohai/mixin/command.rb +198 -0
- data/lib/ohai/mixin/from_file.rb +36 -0
- data/lib/ohai/plugins/command.rb +19 -0
- data/lib/ohai/plugins/darwin/hostname.rb +20 -0
- data/lib/ohai/plugins/darwin/kernel.rb +31 -0
- data/lib/ohai/plugins/darwin/network.rb +154 -0
- data/lib/ohai/plugins/darwin/platform.rb +34 -0
- data/lib/ohai/plugins/darwin/ps.rb +21 -0
- data/lib/ohai/plugins/darwin/ssh_host_key.rb +24 -0
- data/lib/ohai/plugins/ec2.rb +41 -0
- data/lib/ohai/plugins/hostname.rb +23 -0
- data/lib/ohai/plugins/kernel.rb +24 -0
- data/lib/ohai/plugins/keys.rb +20 -0
- data/lib/ohai/plugins/languages.rb +19 -0
- data/lib/ohai/plugins/linux/block_device.rb +36 -0
- data/lib/ohai/plugins/linux/cpu.rb +58 -0
- data/lib/ohai/plugins/linux/filesystem.rb +55 -0
- data/lib/ohai/plugins/linux/hostname.rb +20 -0
- data/lib/ohai/plugins/linux/kernel.rb +31 -0
- data/lib/ohai/plugins/linux/lsb.rb +36 -0
- data/lib/ohai/plugins/linux/memory.rb +81 -0
- data/lib/ohai/plugins/linux/network.rb +103 -0
- data/lib/ohai/plugins/linux/platform.rb +41 -0
- data/lib/ohai/plugins/linux/ps.rb +21 -0
- data/lib/ohai/plugins/linux/ssh_host_key.rb +24 -0
- data/lib/ohai/plugins/linux/uptime.rb +26 -0
- data/lib/ohai/plugins/network.rb +48 -0
- data/lib/ohai/plugins/ohai_time.rb +19 -0
- data/lib/ohai/plugins/os.rb +34 -0
- data/lib/ohai/plugins/platform.rb +23 -0
- data/lib/ohai/plugins/ruby.rb +33 -0
- data/lib/ohai/plugins/uptime.rb +42 -0
- data/lib/ohai/system.rb +163 -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/darwin/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/darwin/kernel_spec.rb +35 -0
- data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
- data/spec/ohai/plugins/hostname_spec.rb +33 -0
- data/spec/ohai/plugins/kernel_spec.rb +41 -0
- data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
- data/spec/ohai/plugins/linux/hostname_spec.rb +34 -0
- data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
- data/spec/ohai/plugins/linux/lsb_spec.rb +59 -0
- data/spec/ohai/plugins/linux/platform_spec.rb +51 -0
- data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
- data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
- data/spec/ohai/plugins/os_spec.rb +58 -0
- data/spec/ohai/plugins/platform_spec.rb +56 -0
- data/spec/ohai/plugins/ruby_spec.rb +49 -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 +47 -0
- metadata +138 -0
@@ -0,0 +1,55 @@
|
|
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
|
+
fs = Mash.new
|
20
|
+
|
21
|
+
# Grab filesystem data from df
|
22
|
+
popen4("/bin/df -P") do |pid, stdin, stdout, stderr|
|
23
|
+
stdin.close
|
24
|
+
stdout.each do |line|
|
25
|
+
case line
|
26
|
+
when /^Filesystem\s+1024-blocks/
|
27
|
+
next
|
28
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
29
|
+
filesystem = $1
|
30
|
+
fs[filesystem] = Mash.new
|
31
|
+
fs[filesystem]['kb_size'] = $2
|
32
|
+
fs[filesystem]['kb_used'] = $3
|
33
|
+
fs[filesystem]['kb_available'] = $4
|
34
|
+
fs[filesystem]['percent_used'] = $5
|
35
|
+
fs[filesystem]['mount'] = $6
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Grab mount information from /bin/mount
|
41
|
+
popen4("/bin/mount -l") do |pid, stdin, stdout, stderr|
|
42
|
+
stdin.close
|
43
|
+
stdout.each do |line|
|
44
|
+
if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
|
45
|
+
filesystem = $1
|
46
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
47
|
+
fs[filesystem]['mount'] = $2
|
48
|
+
fs[filesystem]['fs_type'] = $3
|
49
|
+
fs[filesystem]['mount-options'] = $4.split(",")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Set the filesystem data
|
55
|
+
filesystem fs
|
@@ -0,0 +1,20 @@
|
|
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
|
+
hostname from("hostname")
|
20
|
+
fqdn from("hostname --fqdn")
|
@@ -0,0 +1,31 @@
|
|
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
|
+
kernel[:os] = from("uname -o")
|
20
|
+
|
21
|
+
kext = Mash.new
|
22
|
+
popen4("/sbin/lsmod") do |pid, stdin, stdout, stderr|
|
23
|
+
stdin.close
|
24
|
+
stdout.each do |line|
|
25
|
+
if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
|
26
|
+
kext[$1] = { :size => $2, :refcount => $3 }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
kernel[:modules] = kext
|
@@ -0,0 +1,36 @@
|
|
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
|
+
lsb Mash.new
|
20
|
+
|
21
|
+
begin
|
22
|
+
File.open("/etc/lsb-release").each do |line|
|
23
|
+
case line
|
24
|
+
when /^DISTRIB_ID=(.+)$/
|
25
|
+
lsb[:id] = $1
|
26
|
+
when /^DISTRIB_RELEASE=(.+)$/
|
27
|
+
lsb[:release] = $1
|
28
|
+
when /^DISTRIB_CODENAME=(.+)$/
|
29
|
+
lsb[:codename] = $1
|
30
|
+
when /^DISTRIB_DESCRIPTION=(.+)$/
|
31
|
+
lsb[:description] = $1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue
|
35
|
+
Ohai::Log.debug("Skipping LSB, cannot find /etc/lsb-release")
|
36
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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
|
+
memory Mash.new
|
20
|
+
memory[:swap] = Mash.new
|
21
|
+
|
22
|
+
File.open("/proc/meminfo").each do |line|
|
23
|
+
case line
|
24
|
+
when /^MemTotal:\s+(\d+) (.+)$/
|
25
|
+
memory[:total] = "#{$1}#{$2}"
|
26
|
+
when /^MemFree:\s+(\d+) (.+)$/
|
27
|
+
memory[:free] = "#{$1}#{$2}"
|
28
|
+
when /^Buffers:\s+(\d+) (.+)$/
|
29
|
+
memory[:buffers] = "#{$1}#{$2}"
|
30
|
+
when /^Cached:\s+(\d+) (.+)$/
|
31
|
+
memory[:cached] = "#{$1}#{$2}"
|
32
|
+
when /^Active:\s+(\d+) (.+)$/
|
33
|
+
memory[:active] = "#{$1}#{$2}"
|
34
|
+
when /^Inactive:\s+(\d+) (.+)$/
|
35
|
+
memory[:inactive] = "#{$1}#{$2}"
|
36
|
+
when /^HighTotal:\s+(\d+) (.+)$/
|
37
|
+
memory[:high_total] = "#{$1}#{$2}"
|
38
|
+
when /^HighFree:\s+(\d+) (.+)$/
|
39
|
+
memory[:high_free] = "#{$1}#{$2}"
|
40
|
+
when /^LowTotal:\s+(\d+) (.+)$/
|
41
|
+
memory[:low_total] = "#{$1}#{$2}"
|
42
|
+
when /^LowFree:\s+(\d+) (.+)$/
|
43
|
+
memory[:low_free] = "#{$1}#{$2}"
|
44
|
+
when /^Dirty:\s+(\d+) (.+)$/
|
45
|
+
memory[:dirty] = "#{$1}#{$2}"
|
46
|
+
when /^Writeback:\s+(\d+) (.+)$/
|
47
|
+
memory[:writeback] = "#{$1}#{$2}"
|
48
|
+
when /^AnonPages:\s+(\d+) (.+)$/
|
49
|
+
memory[:anon_pages] = "#{$1}#{$2}"
|
50
|
+
when /^Mapped:\s+(\d+) (.+)$/
|
51
|
+
memory[:mapped] = "#{$1}#{$2}"
|
52
|
+
when /^Slab:\s+(\d+) (.+)$/
|
53
|
+
memory[:slab] = "#{$1}#{$2}"
|
54
|
+
when /^SReclaimable:\s+(\d+) (.+)$/
|
55
|
+
memory[:slab_reclaimable] = "#{$1}#{$2}"
|
56
|
+
when /^SUnreclaim:\s+(\d+) (.+)$/
|
57
|
+
memory[:slab_unreclaim] = "#{$1}#{$2}"
|
58
|
+
when /^PageTables:\s+(\d+) (.+)$/
|
59
|
+
memory[:page_tables] = "#{$1}#{$2}"
|
60
|
+
when /^NFS_Unstable:\s+(\d+) (.+)$/
|
61
|
+
memory[:nfs_unstable] = "#{$1}#{$2}"
|
62
|
+
when /^Bounce:\s+(\d+) (.+)$/
|
63
|
+
memory[:bounce] = "#{$1}#{$2}"
|
64
|
+
when /^CommitLimit:\s+(\d+) (.+)$/
|
65
|
+
memory[:commit_limit] = "#{$1}#{$2}"
|
66
|
+
when /^Committed_AS:\s+(\d+) (.+)$/
|
67
|
+
memory[:committed_as] = "#{$1}#{$2}"
|
68
|
+
when /^VmallocTotal:\s+(\d+) (.+)$/
|
69
|
+
memory[:vmalloc_total] = "#{$1}#{$2}"
|
70
|
+
when /^VmallocUsed:\s+(\d+) (.+)$/
|
71
|
+
memory[:vmalloc_used] = "#{$1}#{$2}"
|
72
|
+
when /^VmallocChunk:\s+(\d+) (.+)$/
|
73
|
+
memory[:vmalloc_chunk] = "#{$1}#{$2}"
|
74
|
+
when /^SwapCached:\s+(\d+) (.+)$/
|
75
|
+
memory[:swap][:cached] = "#{$1}#{$2}"
|
76
|
+
when /^SwapTotal:\s+(\d+) (.+)$/
|
77
|
+
memory[:swap][:total] = "#{$1}#{$2}"
|
78
|
+
when /^SwapFree:\s+(\d+) (.+)$/
|
79
|
+
memory[:swap][:free] = "#{$1}#{$2}"
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,103 @@
|
|
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
|
+
def encaps_lookup(encap)
|
20
|
+
return "Loopback" if encap.eql?("Local Loopback")
|
21
|
+
return "PPP" if encap.eql?("Point-to-Point Protocol")
|
22
|
+
return "SLIP" if encap.eql?("Serial Line IP")
|
23
|
+
return "VJSLIP" if encap.eql?("VJ Serial Line IP")
|
24
|
+
return "IPIP" if encap.eql?("IPIP Tunnel")
|
25
|
+
return "6to4" if encap.eql?("IPv6-in-IPv4")
|
26
|
+
encap
|
27
|
+
end
|
28
|
+
|
29
|
+
iface = Mash.new
|
30
|
+
popen4("ifconfig -a") do |pid, stdin, stdout, stderr|
|
31
|
+
stdin.close
|
32
|
+
cint = nil
|
33
|
+
stdout.each do |line|
|
34
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+)\s+/
|
35
|
+
cint = $1
|
36
|
+
iface[cint] = Mash.new
|
37
|
+
if cint =~ /^(\w+)(\d+.*)/
|
38
|
+
iface[cint]["type"] = $1
|
39
|
+
iface[cint]["number"] = $2
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if line =~ /Link encap:(Local Loopback)/ || line =~ /Link encap:(.+?)\s/
|
43
|
+
iface[cint]["encapsulation"] = encaps_lookup($1)
|
44
|
+
end
|
45
|
+
if line =~ /HWaddr (.+?)\s/
|
46
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
47
|
+
iface[cint]["addresses"] << { "family" => "lladdr", "address" => $1 }
|
48
|
+
end
|
49
|
+
if line =~ /inet addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
50
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
51
|
+
iface[cint]["addresses"] << { "family" => "inet", "address" => $1 }
|
52
|
+
end
|
53
|
+
if line =~ /inet6 addr: ([a-f0-9\:]+)\/(\d+) Scope:(\w+)/
|
54
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
55
|
+
iface[cint]["addresses"] << { "family" => "inet6", "address" => $1, "prefixlen" => $2, "scope" => ($3.eql?("Host") ? "Node" : $3) }
|
56
|
+
end
|
57
|
+
if line =~ /Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
58
|
+
iface[cint]["addresses"].last["broadcast"] = $1
|
59
|
+
end
|
60
|
+
if line =~ /Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
61
|
+
iface[cint]["addresses"].last["netmask"] = $1
|
62
|
+
end
|
63
|
+
flags = line.scan(/(UP|BROADCAST|DEBUG|LOOPBACK|POINTTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC)\s/)
|
64
|
+
if flags.length > 1
|
65
|
+
iface[cint]["flags"] = flags.flatten
|
66
|
+
end
|
67
|
+
if line =~ /MTU:(\d+)/
|
68
|
+
iface[cint]["mtu"] = $1
|
69
|
+
end
|
70
|
+
if line =~ /RX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) frame:(\d+)/
|
71
|
+
iface[cint][:counters] = Mash.new unless iface[cint][:counters]
|
72
|
+
iface[cint][:counters][:rx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "frame" => $5 }
|
73
|
+
end
|
74
|
+
if line =~ /TX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) carrier:(\d+)/
|
75
|
+
iface[cint][:counters][:tx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "carrier" => $5 }
|
76
|
+
end
|
77
|
+
if line =~ /collisions:(\d+)/
|
78
|
+
iface[cint][:counters][:tx]["collisions"] = $1
|
79
|
+
end
|
80
|
+
if line =~ /txqueuelen:(\d+)/
|
81
|
+
iface[cint][:counters][:tx]["queuelen"] = $1
|
82
|
+
end
|
83
|
+
if line =~ /RX bytes:(\d+) \((\d+?\.\d+ .+?)\)/
|
84
|
+
iface[cint][:counters][:rx]["bytes"] = $1
|
85
|
+
end
|
86
|
+
if line =~ /TX bytes:(\d+) \((\d+?\.\d+ .+?)\)/
|
87
|
+
iface[cint][:counters][:tx]["bytes"] = $1
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
popen4("arp -an") do |pid, stdin, stdout, stderr|
|
93
|
+
stdin.close
|
94
|
+
stdout.each do |line|
|
95
|
+
if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) \[(\w+)\] on ([0-9a-zA-Z\.\:\-]+)/
|
96
|
+
next unless iface[$4] # this should never happen
|
97
|
+
iface[$4][:arp] = Mash.new unless iface[$4][:arp]
|
98
|
+
iface[$4][:arp][$1] = $2.downcase
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
network["interfaces"] = iface
|
@@ -0,0 +1,41 @@
|
|
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
|
+
require_plugin 'linux::lsb'
|
20
|
+
|
21
|
+
if lsb[:id]
|
22
|
+
platform lsb[:id].downcase
|
23
|
+
platform_version lsb[:release]
|
24
|
+
elsif File.exists?("/etc/debian_version")
|
25
|
+
platform "debian"
|
26
|
+
platform_version from("cat /etc/debian_version")
|
27
|
+
elsif File.exists?("/etc/redhat-release")
|
28
|
+
platform "redhat"
|
29
|
+
File.open("/etc/redhat-release").each do |line|
|
30
|
+
platform "centos" if line =~ /centos/i
|
31
|
+
case line
|
32
|
+
when /\(Rawhide\)/
|
33
|
+
platform_version "rawhide"
|
34
|
+
when /release (\d+)/
|
35
|
+
platform_version $1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
elsif File.exists?('/etc/gentoo-release')
|
39
|
+
platform "gentoo"
|
40
|
+
platform_version IO.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
|
41
|
+
end
|
@@ -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
|
+
require_plugin 'command'
|
20
|
+
|
21
|
+
command[:ps] = 'ps -ef'
|
@@ -0,0 +1,24 @@
|
|
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
|
+
require_plugin "keys"
|
20
|
+
|
21
|
+
keys[:ssh] = Mash.new
|
22
|
+
|
23
|
+
keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
|
24
|
+
keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
|
@@ -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
|
+
uptime, idletime = File.open("/proc/uptime").gets.split(" ")
|
20
|
+
uptime_seconds uptime.to_i
|
21
|
+
uptime self._seconds_to_human(uptime.to_i)
|
22
|
+
idletime_seconds idletime.to_i
|
23
|
+
idletime self._seconds_to_human(idletime.to_i)
|
24
|
+
|
25
|
+
|
26
|
+
|