rightscale-ohai 0.3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +98 -0
  3. data/Rakefile +59 -0
  4. data/bin/ohai +78 -0
  5. data/lib/ohai/config.rb +118 -0
  6. data/lib/ohai/exception.rb +23 -0
  7. data/lib/ohai/log/formatter.rb +57 -0
  8. data/lib/ohai/log.rb +89 -0
  9. data/lib/ohai/mixin/command.rb +203 -0
  10. data/lib/ohai/mixin/from_file.rb +36 -0
  11. data/lib/ohai/mixin/string.rb +29 -0
  12. data/lib/ohai/plugins/cloud.rb +35 -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/network.rb +52 -0
  56. data/lib/ohai/plugins/ohai_time.rb +21 -0
  57. data/lib/ohai/plugins/os.rb +43 -0
  58. data/lib/ohai/plugins/perl.rb +37 -0
  59. data/lib/ohai/plugins/platform.rb +25 -0
  60. data/lib/ohai/plugins/python.rb +37 -0
  61. data/lib/ohai/plugins/rightscale.rb +53 -0
  62. data/lib/ohai/plugins/ruby.rb +37 -0
  63. data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
  64. data/lib/ohai/plugins/solaris2/hostname.rb +22 -0
  65. data/lib/ohai/plugins/solaris2/kernel.rb +21 -0
  66. data/lib/ohai/plugins/solaris2/network.rb +141 -0
  67. data/lib/ohai/plugins/solaris2/platform.rb +33 -0
  68. data/lib/ohai/plugins/solaris2/ps.rb +23 -0
  69. data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
  70. data/lib/ohai/plugins/uptime.rb +42 -0
  71. data/lib/ohai/plugins/virtualization.rb +86 -0
  72. data/lib/ohai/plugins/windows/filesystem.rb +44 -0
  73. data/lib/ohai/plugins/windows/hostname.rb +25 -0
  74. data/lib/ohai/plugins/windows/kernel.rb +75 -0
  75. data/lib/ohai/plugins/windows/network.rb +114 -0
  76. data/lib/ohai/plugins/windows/platform.rb +26 -0
  77. data/lib/ohai/system.rb +226 -0
  78. data/lib/ohai.rb +27 -0
  79. data/spec/ohai/log/log_formatter_spec.rb +50 -0
  80. data/spec/ohai/log_spec.rb +63 -0
  81. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  82. data/spec/ohai/plugins/cloud_spec.rb +64 -0
  83. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  84. data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
  85. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  86. data/spec/ohai/plugins/dmi_spec.rb +73 -0
  87. data/spec/ohai/plugins/ec2_spec.rb +77 -0
  88. data/spec/ohai/plugins/erlang_spec.rb +63 -0
  89. data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
  90. data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
  91. data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
  92. data/spec/ohai/plugins/hostname_spec.rb +39 -0
  93. data/spec/ohai/plugins/java_spec.rb +70 -0
  94. data/spec/ohai/plugins/kernel_spec.rb +43 -0
  95. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  96. data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
  97. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  98. data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
  99. data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
  100. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  101. data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
  102. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  103. data/spec/ohai/plugins/os_spec.rb +58 -0
  104. data/spec/ohai/plugins/perl_spec.rb +89 -0
  105. data/spec/ohai/plugins/platform_spec.rb +56 -0
  106. data/spec/ohai/plugins/python_spec.rb +53 -0
  107. data/spec/ohai/plugins/rightscale_spec.rb +71 -0
  108. data/spec/ohai/plugins/ruby_spec.rb +51 -0
  109. data/spec/ohai/system_spec.rb +130 -0
  110. data/spec/ohai_spec.rb +27 -0
  111. data/spec/rcov.opts +2 -0
  112. data/spec/spec.opts +2 -0
  113. data/spec/spec_helper.rb +66 -0
  114. metadata +209 -0
@@ -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 "command"
20
+
21
+ command Mash.new
@@ -0,0 +1,57 @@
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
+
19
+ provides "filesystem"
20
+
21
+ fs = Mash.new
22
+
23
+ block_size = 0
24
+ popen4("df") do |pid, stdin, stdout, stderr|
25
+ stdin.close
26
+ stdout.each do |line|
27
+ case line
28
+ when /^Filesystem\s+(\d+)-/
29
+ block_size = $1.to_i
30
+ next
31
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
32
+ filesystem = $1
33
+ fs[filesystem] = Mash.new
34
+ fs[filesystem][:block_size] = block_size
35
+ fs[filesystem][:kb_size] = $2.to_i / (1024 / block_size)
36
+ fs[filesystem][:kb_used] = $3.to_i / (1024 / block_size)
37
+ fs[filesystem][:kb_available] = $4.to_i / (1024 / block_size)
38
+ fs[filesystem][:percent_used] = $5
39
+ fs[filesystem][:mount] = $6
40
+ end
41
+ end
42
+ end
43
+
44
+ popen4("mount") do |pid, stdin, stdout, stderr|
45
+ stdin.close
46
+ stdout.each do |line|
47
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
48
+ filesystem = $1
49
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
50
+ fs[filesystem][:mount] = $2
51
+ fs[filesystem][:fs_type] = $3
52
+ fs[filesystem][:mount_options] = $4.split(/,\s*/)
53
+ end
54
+ end
55
+ end
56
+
57
+ filesystem fs
@@ -0,0 +1,22 @@
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", "hostname"
20
+
21
+ hostname from("hostname -s")
22
+ fqdn from("hostname")
@@ -0,0 +1,37 @@
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] = kernel[:name]
22
+
23
+ if from("sysctl -n hw.optional.x86_64").to_i == 1
24
+ kernel[:machine] = 'x86_64'
25
+ end
26
+
27
+ kext = Mash.new
28
+ popen4("kextstat -k -l") do |pid, stdin, stdout, stderr|
29
+ stdin.close
30
+ stdout.each do |line|
31
+ 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\.]+)\)/
32
+ kext[$4] = { :version => $5, :size => $3.hex, :index => $1, :refcount => $2 }
33
+ end
34
+ end
35
+ end
36
+
37
+ kernel[:modules] = kext
@@ -0,0 +1,187 @@
1
+ #
2
+ # Author:: Benjamin Black (<bb@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 "network", "counters/network"
20
+
21
+ require 'scanf'
22
+
23
+ network[:default_interface] = from("route -n get default \| grep interface: \| awk \'/: / \{print \$2\}\'")
24
+
25
+ def parse_media(media_string)
26
+ media = Hash.new
27
+ line_array = media_string.split(' ')
28
+
29
+ 0.upto(line_array.length - 1) do |i|
30
+ unless line_array[i].eql?("none")
31
+
32
+ if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
33
+ media[line_array[i]] = Hash.new unless media.has_key?(line_array[i])
34
+ if media[line_array[i]].has_key?("options")
35
+ $1.split(",").each do |opt|
36
+ media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
37
+ end
38
+ else
39
+ media[line_array[i]]["options"] = $1.split(",")
40
+ end
41
+ else
42
+ if line_array[i].eql?("autoselect")
43
+ media["autoselect"] = Hash.new unless media.has_key?("autoselect")
44
+ media["autoselect"]["options"] = []
45
+ end
46
+ end
47
+ else
48
+ media["none"] = { "options" => [] }
49
+ end
50
+ end
51
+
52
+ media
53
+ end
54
+
55
+ def encaps_lookup(ifname)
56
+ return "Loopback" if ifname.eql?("lo")
57
+ return "1394" if ifname.eql?("fw")
58
+ return "IPIP" if ifname.eql?("gif")
59
+ return "6to4" if ifname.eql?("stf")
60
+ return "dot1q" if ifname.eql?("vlan")
61
+ "Unknown"
62
+ end
63
+
64
+ def scope_lookup(scope)
65
+ return "Link" if scope.match(/^fe80\:/)
66
+ return "Site" if scope.match(/^fec0\:/)
67
+ "Global"
68
+ end
69
+
70
+ def excluded_setting?(setting)
71
+ setting.match('_sw_cksum')
72
+ end
73
+
74
+ def locate_interface(ifaces, ifname, mac)
75
+ return ifname unless ifaces[ifname].nil?
76
+ # oh well, time to go hunting!
77
+ return ifname.chop if ifname.match /\*$/
78
+ ifaces.keys.each do |ifc|
79
+ ifaces[ifc][:addresses].keys.each do |addr|
80
+ return ifc if addr.eql? mac
81
+ end
82
+ end
83
+
84
+ nil
85
+ end
86
+
87
+ iface = Mash.new
88
+ popen4("ifconfig -a") do |pid, stdin, stdout, stderr|
89
+ stdin.close
90
+ cint = nil
91
+ stdout.each do |line|
92
+ if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)$/
93
+ cint = $1
94
+ iface[cint] = Mash.new unless iface[cint]; iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
95
+ iface[cint][:mtu] = $2
96
+ if line =~ /\sflags\=\d+\<((UP|BROADCAST|DEBUG|SMART|SIMPLEX|LOOPBACK|POINTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC|,)+)\>\s/
97
+ flags = $1.split(',')
98
+ else
99
+ flags = Array.new
100
+ end
101
+ iface[cint][:flags] = flags.flatten
102
+ if cint =~ /^(\w+)(\d+.*)/
103
+ iface[cint][:type] = $1
104
+ iface[cint][:number] = $2
105
+ iface[cint][:encapsulation] = encaps_lookup($1)
106
+ end
107
+ end
108
+ if line =~ /^\s+ether ([0-9a-f\:]+)\s/
109
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
110
+ iface[cint][:addresses][$1] = { "family" => "lladdr" }
111
+ iface[cint][:encapsulation] = "Ethernet"
112
+ end
113
+ if line =~ /^\s+lladdr ([0-9a-f\:]+)\s/
114
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
115
+ iface[cint][:addresses][$1] = { "family" => "lladdr" }
116
+ end
117
+ if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8})\s*$/
118
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
119
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*"."}
120
+ end
121
+ 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})/
122
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
123
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*".", "broadcast" => $4 }
124
+ end
125
+ if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*$/
126
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
127
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => "Node" }
128
+ end
129
+ if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
130
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
131
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
132
+ end
133
+ if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
134
+ iface[cint][:media] = Mash.new unless iface[cint][:media]
135
+ iface[cint][:media][:selected] = parse_media($1)
136
+ iface[cint][:status] = $4
137
+ end
138
+ if line =~ /^\s+supported media: (.*)/
139
+ iface[cint][:media] = Mash.new unless iface[cint][:media]
140
+ iface[cint][:media][:supported] = parse_media($1)
141
+ end
142
+ end
143
+ end
144
+
145
+ popen4("arp -an") do |pid, stdin, stdout, stderr|
146
+ stdin.close
147
+ stdout.each do |line|
148
+ 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+)\]/
149
+ # MAC addr really should be normalized to include all the zeroes.
150
+ next if iface[$3].nil? # this should never happen
151
+ iface[$3][:arp] = Mash.new unless iface[$3][:arp]
152
+ iface[$3][:arp][$1] = $2
153
+ end
154
+ end
155
+ end
156
+
157
+ settings = Mash.new
158
+ popen4("sysctl net") do |pid, stdin, stdout, stderr|
159
+ stdin.close
160
+ stdout.each do |line|
161
+ if line =~ /^([a-zA-Z0-9\.\_]+)\: (.*)/
162
+ # should normalize names between platforms for the same settings.
163
+ settings[$1] = $2 unless excluded_setting?($1)
164
+ end
165
+ end
166
+ end
167
+
168
+ network[:settings] = settings
169
+ network[:interfaces] = iface
170
+
171
+ net_counters = Mash.new
172
+ popen4("netstat -i -d -l -b -n") do |pid, stdin, stdout, stderr|
173
+ stdin.close
174
+ stdout.each do |line|
175
+ 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+)/ ||
176
+ line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>(\s+)(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
177
+ ifname = locate_interface(iface, $1, $2)
178
+ next if iface[ifname].nil? # this shouldn't happen, but just in case
179
+ net_counters[ifname] = Mash.new unless net_counters[ifname]
180
+ net_counters[ifname] = { :rx => { :bytes => $5, :packets => $3, :errors => $4, :drop => 0, :overrun => 0, :frame => 0, :compressed => 0, :multicast => 0 },
181
+ :tx => { :bytes => $8, :packets => $6, :errors => $7, :drop => 0, :overrun => 0, :collisions => $9, :carrier => 0, :compressed => 0 }
182
+ }
183
+ end
184
+ end
185
+ end
186
+
187
+ counters[:network][:interfaces] = net_counters
@@ -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
+ provides "platform", "platform_version", "platform_build"
20
+
21
+ popen4("/usr/bin/sw_vers") do |pid, stdin, stdout, stderr|
22
+ stdin.close
23
+ stdout.each do |line|
24
+ case line
25
+ when /^ProductName:\s+(.+)$/
26
+ macname = $1
27
+ macname.downcase!
28
+ macname.gsub!(" ", "_")
29
+ platform macname
30
+ when /^ProductVersion:\s+(.+)$/
31
+ platform_version $1
32
+ when /^BuildVersion:\s+(.+)$/
33
+ platform_build $1
34
+ end
35
+ end
36
+ 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
+ provides "command/ps"
20
+
21
+ require_plugin 'command'
22
+
23
+ command[:ps] = 'ps -ef'
@@ -0,0 +1,25 @@
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
+ keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh_host_dsa_key.pub").split[1]
25
+ keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh_host_rsa_key.pub").split[1]
@@ -0,0 +1,33 @@
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
+
19
+ provides "system_profile"
20
+
21
+ begin
22
+ require 'plist'
23
+
24
+ system_profile Array.new
25
+ popen4("system_profiler -xml -detailLevel mini") do |pid, stdin, stdout, stderr|
26
+ stdin.close
27
+ Plist::parse_xml(stdout.read).each do |e|
28
+ system_profile << e
29
+ end
30
+ end
31
+ rescue LoadError => e
32
+ Ohai::Log.debug("Can't load gem: #{e})")
33
+ end