ohai 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +98 -0
  3. data/Rakefile +61 -0
  4. data/bin/ohai +24 -0
  5. data/lib/ohai.rb +27 -0
  6. data/lib/ohai/application.rb +113 -0
  7. data/lib/ohai/config.rb +29 -0
  8. data/lib/ohai/exception.rb +23 -0
  9. data/lib/ohai/log.rb +26 -0
  10. data/lib/ohai/mixin/command.rb +208 -0
  11. data/lib/ohai/mixin/from_file.rb +36 -0
  12. data/lib/ohai/mixin/string.rb +29 -0
  13. data/lib/ohai/plugins/command.rb +21 -0
  14. data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
  15. data/lib/ohai/plugins/darwin/hostname.rb +22 -0
  16. data/lib/ohai/plugins/darwin/kernel.rb +37 -0
  17. data/lib/ohai/plugins/darwin/network.rb +187 -0
  18. data/lib/ohai/plugins/darwin/platform.rb +36 -0
  19. data/lib/ohai/plugins/darwin/ps.rb +23 -0
  20. data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
  21. data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
  22. data/lib/ohai/plugins/darwin/uptime.rb +32 -0
  23. data/lib/ohai/plugins/dmi.rb +59 -0
  24. data/lib/ohai/plugins/ec2.rb +100 -0
  25. data/lib/ohai/plugins/erlang.rb +40 -0
  26. data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
  27. data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
  28. data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
  29. data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
  30. data/lib/ohai/plugins/freebsd/memory.rb +50 -0
  31. data/lib/ohai/plugins/freebsd/network.rb +112 -0
  32. data/lib/ohai/plugins/freebsd/platform.rb +23 -0
  33. data/lib/ohai/plugins/freebsd/ps.rb +24 -0
  34. data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
  35. data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
  36. data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
  37. data/lib/ohai/plugins/hostname.rb +27 -0
  38. data/lib/ohai/plugins/java.rb +36 -0
  39. data/lib/ohai/plugins/kernel.rb +33 -0
  40. data/lib/ohai/plugins/keys.rb +22 -0
  41. data/lib/ohai/plugins/languages.rb +21 -0
  42. data/lib/ohai/plugins/linux/block_device.rb +38 -0
  43. data/lib/ohai/plugins/linux/cpu.rb +60 -0
  44. data/lib/ohai/plugins/linux/filesystem.rb +57 -0
  45. data/lib/ohai/plugins/linux/hostname.rb +26 -0
  46. data/lib/ohai/plugins/linux/kernel.rb +33 -0
  47. data/lib/ohai/plugins/linux/lsb.rb +38 -0
  48. data/lib/ohai/plugins/linux/memory.rb +83 -0
  49. data/lib/ohai/plugins/linux/network.rb +112 -0
  50. data/lib/ohai/plugins/linux/platform.rb +43 -0
  51. data/lib/ohai/plugins/linux/ps.rb +23 -0
  52. data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
  53. data/lib/ohai/plugins/linux/uptime.rb +28 -0
  54. data/lib/ohai/plugins/linux/virtualization.rb +77 -0
  55. data/lib/ohai/plugins/netbsd/cpu.rb +48 -0
  56. data/lib/ohai/plugins/netbsd/filesystem.rb +57 -0
  57. data/lib/ohai/plugins/netbsd/hostname.rb +22 -0
  58. data/lib/ohai/plugins/netbsd/kernel.rb +35 -0
  59. data/lib/ohai/plugins/netbsd/memory.rb +98 -0
  60. data/lib/ohai/plugins/netbsd/network.rb +111 -0
  61. data/lib/ohai/plugins/netbsd/platform.rb +22 -0
  62. data/lib/ohai/plugins/netbsd/ps.rb +24 -0
  63. data/lib/ohai/plugins/netbsd/ssh_host_key.rb +26 -0
  64. data/lib/ohai/plugins/netbsd/uptime.rb +31 -0
  65. data/lib/ohai/plugins/netbsd/virtualization.rb +65 -0
  66. data/lib/ohai/plugins/network.rb +52 -0
  67. data/lib/ohai/plugins/ohai_time.rb +21 -0
  68. data/lib/ohai/plugins/openbsd/cpu.rb +38 -0
  69. data/lib/ohai/plugins/openbsd/filesystem.rb +57 -0
  70. data/lib/ohai/plugins/openbsd/hostname.rb +22 -0
  71. data/lib/ohai/plugins/openbsd/kernel.rb +35 -0
  72. data/lib/ohai/plugins/openbsd/memory.rb +98 -0
  73. data/lib/ohai/plugins/openbsd/network.rb +111 -0
  74. data/lib/ohai/plugins/openbsd/platform.rb +23 -0
  75. data/lib/ohai/plugins/openbsd/ps.rb +24 -0
  76. data/lib/ohai/plugins/openbsd/ssh_host_key.rb +26 -0
  77. data/lib/ohai/plugins/openbsd/uptime.rb +32 -0
  78. data/lib/ohai/plugins/openbsd/virtualization.rb +66 -0
  79. data/lib/ohai/plugins/os.rb +48 -0
  80. data/lib/ohai/plugins/perl.rb +37 -0
  81. data/lib/ohai/plugins/platform.rb +25 -0
  82. data/lib/ohai/plugins/python.rb +37 -0
  83. data/lib/ohai/plugins/ruby.rb +39 -0
  84. data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
  85. data/lib/ohai/plugins/solaris2/hostname.rb +25 -0
  86. data/lib/ohai/plugins/solaris2/kernel.rb +40 -0
  87. data/lib/ohai/plugins/solaris2/network.rb +141 -0
  88. data/lib/ohai/plugins/solaris2/platform.rb +33 -0
  89. data/lib/ohai/plugins/solaris2/ps.rb +23 -0
  90. data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
  91. data/lib/ohai/plugins/uptime.rb +42 -0
  92. data/lib/ohai/plugins/virtualization.rb +86 -0
  93. data/lib/ohai/plugins/windows/filesystem.rb +44 -0
  94. data/lib/ohai/plugins/windows/hostname.rb +25 -0
  95. data/lib/ohai/plugins/windows/kernel.rb +75 -0
  96. data/lib/ohai/plugins/windows/network.rb +114 -0
  97. data/lib/ohai/plugins/windows/platform.rb +26 -0
  98. data/lib/ohai/system.rb +241 -0
  99. data/spec/ohai/mixin/command_spec.rb +37 -0
  100. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  101. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  102. data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
  103. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  104. data/spec/ohai/plugins/dmi_spec.rb +73 -0
  105. data/spec/ohai/plugins/ec2_spec.rb +81 -0
  106. data/spec/ohai/plugins/erlang_spec.rb +63 -0
  107. data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
  108. data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
  109. data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
  110. data/spec/ohai/plugins/hostname_spec.rb +39 -0
  111. data/spec/ohai/plugins/java_spec.rb +70 -0
  112. data/spec/ohai/plugins/kernel_spec.rb +43 -0
  113. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  114. data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
  115. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  116. data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
  117. data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
  118. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  119. data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
  120. data/spec/ohai/plugins/netbsd/hostname_spec.rb +34 -0
  121. data/spec/ohai/plugins/netbsd/kernel_spec.rb +36 -0
  122. data/spec/ohai/plugins/netbsd/platform_spec.rb +40 -0
  123. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  124. data/spec/ohai/plugins/openbsd/hostname_spec.rb +34 -0
  125. data/spec/ohai/plugins/openbsd/kernel_spec.rb +37 -0
  126. data/spec/ohai/plugins/openbsd/platform_spec.rb +40 -0
  127. data/spec/ohai/plugins/os_spec.rb +69 -0
  128. data/spec/ohai/plugins/perl_spec.rb +89 -0
  129. data/spec/ohai/plugins/platform_spec.rb +56 -0
  130. data/spec/ohai/plugins/python_spec.rb +53 -0
  131. data/spec/ohai/plugins/ruby_spec.rb +51 -0
  132. data/spec/ohai/plugins/solaris2/hostname_spec.rb +43 -0
  133. data/spec/ohai/plugins/solaris2/kernel_spec.rb +164 -0
  134. data/spec/ohai/system_spec.rb +130 -0
  135. data/spec/ohai_spec.rb +27 -0
  136. data/spec/rcov.opts +2 -0
  137. data/spec/spec.opts +2 -0
  138. data/spec/spec_helper.rb +68 -0
  139. metadata +240 -0
@@ -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] = File.read("/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] = File.read("/sys/block/#{dir}/device/#{check}").chomp
34
+ end
35
+ end
36
+ end
37
+ block_device block
38
+ end
@@ -0,0 +1,60 @@
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 "cpu"
20
+
21
+ cpuinfo = Mash.new
22
+ real_cpu = Mash.new
23
+ cpu_number = 0
24
+ current_cpu = nil
25
+
26
+ File.open("/proc/cpuinfo").each do |line|
27
+ case line
28
+ when /processor\s+:\s(.+)/
29
+ cpuinfo[$1] = Mash.new
30
+ current_cpu = $1
31
+ cpu_number += 1
32
+ when /vendor_id\s+:\s(.+)/
33
+ cpuinfo[current_cpu]["vendor_id"] = $1
34
+ when /cpu family\s+:\s(.+)/
35
+ cpuinfo[current_cpu]["family"] = $1
36
+ when /model\s+:\s(.+)/
37
+ cpuinfo[current_cpu]["model"] = $1
38
+ when /stepping\s+:\s(.+)/
39
+ cpuinfo[current_cpu]["stepping"] = $1
40
+ when /physical id\s+:\s(.+)/
41
+ cpuinfo[current_cpu]["physical_id"] = $1
42
+ real_cpu[$1] = true
43
+ when /core id\s+:\s(.+)/
44
+ cpuinfo[current_cpu]["core_id"] = $1
45
+ when /cpu cores\s+:\s(.+)/
46
+ cpuinfo[current_cpu]["cores"] = $1
47
+ when /model name\s+:\s(.+)/
48
+ cpuinfo[current_cpu]["model_name"] = $1
49
+ when /cpu MHz\s+:\s(.+)/
50
+ cpuinfo[current_cpu]["mhz"] = $1
51
+ when /cache size\s+:\s(.+)/
52
+ cpuinfo[current_cpu]["cache_size"] = $1
53
+ when /flags\s+:\s(.+)/
54
+ cpuinfo[current_cpu]["flags"] = $1.split(' ')
55
+ end
56
+ end
57
+
58
+ cpu cpuinfo
59
+ cpu[:total] = cpu_number
60
+ cpu[:real] = real_cpu.keys.length
@@ -0,0 +1,57 @@
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 "filesystem"
20
+
21
+ fs = Mash.new
22
+
23
+ # Grab filesystem data from df
24
+ popen4("df -P") do |pid, stdin, stdout, stderr|
25
+ stdin.close
26
+ stdout.each do |line|
27
+ case line
28
+ when /^Filesystem\s+1024-blocks/
29
+ next
30
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
31
+ filesystem = $1
32
+ fs[filesystem] = Mash.new
33
+ fs[filesystem][:kb_size] = $2
34
+ fs[filesystem][:kb_used] = $3
35
+ fs[filesystem][:kb_available] = $4
36
+ fs[filesystem][:percent_used] = $5
37
+ fs[filesystem][:mount] = $6
38
+ end
39
+ end
40
+ end
41
+
42
+ # Grab mount information from /bin/mount
43
+ popen4("mount -l") do |pid, stdin, stdout, stderr|
44
+ stdin.close
45
+ stdout.each do |line|
46
+ if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
47
+ filesystem = $1
48
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
49
+ fs[filesystem][:mount] = $2
50
+ fs[filesystem][:fs_type] = $3
51
+ fs[filesystem][:mount_options] = $4.split(",")
52
+ end
53
+ end
54
+ end
55
+
56
+ # Set the filesystem data
57
+ filesystem fs
@@ -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 "hostname", "fqdn"
20
+
21
+ hostname from("hostname -s")
22
+ begin
23
+ fqdn from("hostname --fqdn")
24
+ rescue
25
+ Ohai::Log.debug("hostname -f returned an error, probably no domain is set")
26
+ 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
+ kernel[:os] = from("uname -o")
22
+
23
+ kext = Mash.new
24
+ popen4("env lsmod") do |pid, stdin, stdout, stderr|
25
+ stdin.close
26
+ stdout.each do |line|
27
+ if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
28
+ kext[$1] = { :size => $2, :refcount => $3 }
29
+ end
30
+ end
31
+ end
32
+
33
+ kernel[:modules] = kext