opscode-ohai 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,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] = kernel[:name]
|
20
|
+
|
21
|
+
kext = Mash.new
|
22
|
+
popen4("/usr/sbin/kextstat -k -l") do |pid, stdin, stdout, stderr|
|
23
|
+
stdin.close
|
24
|
+
stdout.each do |line|
|
25
|
+
if line =~ /(\d+)\s+(\d+)\s+0x[0-9a-f]+\s+0x([0-9a-f]+)\s+0x[0-9a-f]+\s+([a-zA-Z0-9\.]+) \(([0-9\.]+)\)/
|
26
|
+
kext[$4] = { :version => $5, :size => $3.hex, :index => $1, :refcount => $2 }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
kernel[:modules] = kext
|
@@ -0,0 +1,154 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Benjamin Black (<nostromo@gmail.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 'scanf'
|
20
|
+
|
21
|
+
def parse_media(media_string)
|
22
|
+
media = Array.new
|
23
|
+
line_array = media_string.split(' ')
|
24
|
+
|
25
|
+
0.upto(line_array.length - 1) do |i|
|
26
|
+
unless line_array[i].eql?("none")
|
27
|
+
if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
|
28
|
+
media << { line_array[i] => { "options" => $1.split(',') }}
|
29
|
+
else
|
30
|
+
media << { "autoselect" => { "options" => [] } } if line_array[i].eql?("autoselect")
|
31
|
+
end
|
32
|
+
else
|
33
|
+
media << { "none" => { "options" => [] } }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
media
|
38
|
+
end
|
39
|
+
|
40
|
+
def encaps_lookup(ifname)
|
41
|
+
return "Loopback" if ifname.eql?("lo")
|
42
|
+
return "1394" if ifname.eql?("fw")
|
43
|
+
return "IPIP" if ifname.eql?("gif")
|
44
|
+
return "6to4" if ifname.eql?("stf")
|
45
|
+
return "dot1q" if ifname.eql?("vlan")
|
46
|
+
"Unknown"
|
47
|
+
end
|
48
|
+
|
49
|
+
def scope_lookup(scope)
|
50
|
+
return "Link" if scope.match(/^fe80\:/)
|
51
|
+
return "Site" if scope.match(/^fec0\:/)
|
52
|
+
"Global"
|
53
|
+
end
|
54
|
+
|
55
|
+
def excluded_setting?(setting)
|
56
|
+
setting.match('_sw_cksum')
|
57
|
+
end
|
58
|
+
|
59
|
+
iface = Mash.new
|
60
|
+
popen4("ifconfig -a") do |pid, stdin, stdout, stderr|
|
61
|
+
stdin.close
|
62
|
+
cint = nil
|
63
|
+
stdout.each do |line|
|
64
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)$/
|
65
|
+
cint = $1
|
66
|
+
iface[cint] = Mash.new
|
67
|
+
iface[cint]["mtu"] = $2
|
68
|
+
if line =~ /\sflags\=\d+\<((UP|BROADCAST|DEBUG|SMART|SIMPLEX|LOOPBACK|POINTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC|,)+)\>\s/
|
69
|
+
flags = $1.split(',')
|
70
|
+
else
|
71
|
+
flags = Array.new
|
72
|
+
end
|
73
|
+
iface[cint]["flags"] = flags.flatten
|
74
|
+
if cint =~ /^(\w+)(\d+.*)/
|
75
|
+
iface[cint]["type"] = $1
|
76
|
+
iface[cint]["number"] = $2
|
77
|
+
iface[cint]["encapsulation"] = encaps_lookup($1)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
if line =~ /^\s+ether ([0-9a-f\:]+)\s/
|
81
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
82
|
+
iface[cint]["addresses"] << { "family" => "lladdr", "address" => $1 }
|
83
|
+
iface[cint]["encapsulation"] = "Ethernet"
|
84
|
+
end
|
85
|
+
if line =~ /^\s+lladdr ([0-9a-f\:]+)\s/
|
86
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
87
|
+
iface[cint]["addresses"] << { "family" => "lladdr", "address" => $1 }
|
88
|
+
end
|
89
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8})\s*$/
|
90
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
91
|
+
iface[cint]["addresses"] << { "family" => "inet", "address" => $1, "netmask" => $2.scanf('%2x'*4)*"."}
|
92
|
+
end
|
93
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
94
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
95
|
+
iface[cint]["addresses"] << { "family" => "inet", "address" => $1, "netmask" => $2.scanf('%2x'*4)*".", "broadcast" => $4 }
|
96
|
+
end
|
97
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*$/
|
98
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
99
|
+
iface[cint]["addresses"] << { "family" => "inet6", "address" => $1, "prefixlen" => $4 , "scope" => "Node" }
|
100
|
+
end
|
101
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
|
102
|
+
iface[cint]["addresses"] = Array.new unless iface[cint]["addresses"]
|
103
|
+
iface[cint]["addresses"] << { "family" => "inet6", "address" => $1, "prefixlen" => $4 , "scope" => scope_lookup($1) }
|
104
|
+
end
|
105
|
+
if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
|
106
|
+
iface[cint]["media"] = Mash.new unless iface[cint]["media"]
|
107
|
+
iface[cint]["media"]["selected"] = parse_media($1)
|
108
|
+
iface[cint]["status"] = $4
|
109
|
+
end
|
110
|
+
if line =~ /^\s+supported media: (.*)/
|
111
|
+
iface[cint]["media"] = Mash.new unless iface[cint]["media"]
|
112
|
+
iface[cint]["media"]["supported"] = parse_media($1)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
popen4("/usr/sbin/arp -an") do |pid, stdin, stdout, stderr|
|
118
|
+
stdin.close
|
119
|
+
stdout.each do |line|
|
120
|
+
if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([a-zA-Z0-9\.\:\-]+) \[(\w+)\]/
|
121
|
+
# MAC addr really should be normalized to include all the zeroes.
|
122
|
+
next unless iface[$3] # this should never happen
|
123
|
+
iface[$3][:arp] = Mash.new unless iface[$3][:arp]
|
124
|
+
iface[$3][:arp][$1] = $2
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
settings = Mash.new
|
130
|
+
popen4("/usr/sbin/sysctl net") do |pid, stdin, stdout, stderr|
|
131
|
+
stdin.close
|
132
|
+
stdout.each do |line|
|
133
|
+
if line =~ /^([a-zA-Z0-9\.\_]+)\: (.*)/
|
134
|
+
# should normalize names between platforms for the same settings.
|
135
|
+
settings[$1] = $2 unless excluded_setting?($1)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
popen4("/usr/sbin/netstat -i -d -l -b") do |pid, stdin, stdout, stderr|
|
141
|
+
stdin.close
|
142
|
+
stdout.each do |line|
|
143
|
+
if line =~ /^([a-zA-Z0-9\.\:\-]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>\s+[a-f0-9\:]+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
144
|
+
iface[$1] = Mash.new unless iface[$1]
|
145
|
+
iface[$1][:counters] = Mash.new unless iface[$1][:counters]
|
146
|
+
iface[$1][:counters] = { :rx => { :bytes => $4, :packets => $2, :errors => $3, :drop => 0, :overrun => 0, :frame => 0, :compressed => 0, :multicast => 0 },
|
147
|
+
:tx => { :bytes => $7, :packets => $5, :errors => $6, :drop => 0, :overrun => 0, :collisions => $8, :carrier => 0, :compressed => 0 }
|
148
|
+
}
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
network[:settings] = settings
|
154
|
+
network[:interfaces] = iface
|
@@ -0,0 +1,34 @@
|
|
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
|
+
popen4("/usr/bin/sw_vers") do |pid, stdin, stdout, stderr|
|
20
|
+
stdin.close
|
21
|
+
stdout.each do |line|
|
22
|
+
case line
|
23
|
+
when /^ProductName:\s+(.+)$/
|
24
|
+
macname = $1
|
25
|
+
macname.downcase!
|
26
|
+
macname.gsub!(" ", "_")
|
27
|
+
platform macname
|
28
|
+
when /^ProductVersion:\s+(.+)$/
|
29
|
+
platform_version $1
|
30
|
+
when /^BuildVersion:\s+(.+)$/
|
31
|
+
platform_build $1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
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_host_dsa_key.pub").split[1]
|
24
|
+
keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh_host_rsa_key.pub").split[1]
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
|
+
# Author:: Benjamin Black (<bb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
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
|
+
require 'open-uri'
|
20
|
+
|
21
|
+
require_plugin "hostname"
|
22
|
+
require_plugin "kernel"
|
23
|
+
|
24
|
+
def metadata(id='')
|
25
|
+
OpenURI.open_uri("http://169.254.169.254/2008-02-01/meta-data/#{id}").
|
26
|
+
read.split("\n").each do |o|
|
27
|
+
key = "#{id}#{o.gsub(/\=.*$/, '/')}"
|
28
|
+
if key[-1..-1] != '/'
|
29
|
+
ec2[key.gsub(/\-|\//, '_').to_sym] =
|
30
|
+
OpenURI.open_uri("http://169.254.169.254/2008-02-01" +
|
31
|
+
"/meta-data/#{key}").gets
|
32
|
+
else
|
33
|
+
metadata(key)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if (domain =~ /\.internal$/ || kernel[:release] =~ /-ec2-/)
|
39
|
+
ec2 Mash.new
|
40
|
+
self.metadata
|
41
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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 "#{os}::hostname"
|
20
|
+
|
21
|
+
# Domain is everything after the first dot
|
22
|
+
fqdn =~ /.+?\.(.*)/
|
23
|
+
domain $1
|
@@ -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
|
+
kernel Mash.new
|
20
|
+
kernel[:name] = from("uname -s")
|
21
|
+
kernel[:release] = from("uname -r")
|
22
|
+
kernel[:version] = from("uname -v")
|
23
|
+
kernel[:machine] = from("uname -m")
|
24
|
+
kernel[:modules] = Mash.new
|
@@ -0,0 +1,20 @@
|
|
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
|
+
keys Mash.new
|
@@ -0,0 +1,19 @@
|
|
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
|
+
languages Mash.new
|
@@ -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
|
+
if File.exists?("/sys/block")
|
20
|
+
block = Mash.new
|
21
|
+
Dir["/sys/block/*"].each do |block_device_dir|
|
22
|
+
dir = File.basename(block_device_dir)
|
23
|
+
block[dir] = Mash.new
|
24
|
+
%w{size removable}.each do |check|
|
25
|
+
if File.exists?("/sys/block/#{dir}/#{check}")
|
26
|
+
block[dir][check] = from("cat /sys/block/#{dir}/#{check}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
%w{model rev state timeout vendor}.each do |check|
|
30
|
+
if File.exists?("/sys/block/#{dir}/device/#{check}")
|
31
|
+
block[dir][check] = from("cat /sys/block/#{dir}/device/#{check}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
block_device block
|
36
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
+
cpuinfo = Mash.new
|
20
|
+
real_cpu = Mash.new
|
21
|
+
cpu_number = 0
|
22
|
+
current_cpu = nil
|
23
|
+
|
24
|
+
File.open("/proc/cpuinfo").each do |line|
|
25
|
+
case line
|
26
|
+
when /processor\s+:\s(.+)/
|
27
|
+
cpuinfo[$1] = Mash.new
|
28
|
+
current_cpu = $1
|
29
|
+
cpu_number += 1
|
30
|
+
when /vendor_id\s+:\s(.+)/
|
31
|
+
cpuinfo[current_cpu]["vendor_id"] = $1
|
32
|
+
when /cpu family\s+:\s(.+)/
|
33
|
+
cpuinfo[current_cpu]["family"] = $1
|
34
|
+
when /model\s+:\s(.+)/
|
35
|
+
cpuinfo[current_cpu]["model"] = $1
|
36
|
+
when /stepping\s+:\s(.+)/
|
37
|
+
cpuinfo[current_cpu]["stepping"] = $1
|
38
|
+
when /physical id\s+:\s(.+)/
|
39
|
+
cpuinfo[current_cpu]["physical_id"] = $1
|
40
|
+
real_cpu[$1] = true
|
41
|
+
when /core id\s+:\s(.+)/
|
42
|
+
cpuinfo[current_cpu]["core_id"] = $1
|
43
|
+
when /cpu cores\s+:\s(.+)/
|
44
|
+
cpuinfo[current_cpu]["cores"] = $1
|
45
|
+
when /model name\s+:\s(.+)/
|
46
|
+
cpuinfo[current_cpu]["model_name"] = $1
|
47
|
+
when /cpu MHz\s+:\s(.+)/
|
48
|
+
cpuinfo[current_cpu]["mhz"] = $1
|
49
|
+
when /cache size\s+:\s(.+)/
|
50
|
+
cpuinfo[current_cpu]["cache_size"] = $1
|
51
|
+
when /flags\s+:\s(.+)/
|
52
|
+
cpuinfo[current_cpu]["flags"] = $1.split(' ')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
cpu cpuinfo
|
57
|
+
cpu[:total] = cpu_number
|
58
|
+
cpu[:real] = real_cpu.keys.length
|