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
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,98 @@
1
+ = ohai
2
+
3
+ = DESCRIPTION:
4
+
5
+ Ohai detects data about your operating system. It can be used standalone, but it's primary purpose is to provide node data to Chef.
6
+
7
+ Ohai will print out a JSON data blob for all the known data about your system. When used with Chef, that data is reported back via node attributes.
8
+
9
+ Opscode distributes ohai as a RubyGem. This README is for developers who want to modify the Ohai source code. For users who want to write plugins for Ohai, see the wiki:
10
+
11
+ * http://wiki.opscode.com/display/ohai/Home
12
+
13
+ = DEVELOPMENT:
14
+
15
+ Before working on the code, if you plan to contribute your changes, you need to read the Opscode Contributing document.
16
+
17
+ * http://wiki.opscode.com/display/opscode/Contributing
18
+
19
+ You will also need to set up the repository with the appropriate branches. We document the process on the Chef Wiki.
20
+
21
+ * http://wiki.opscode.com/display/opscode/Working+with+Git
22
+
23
+ (Substitude 'ohai' for 'chef')
24
+
25
+ Once your repository is set up, you can start working on the code. We do use BDD/TDD with RSpec, and soon Cucumber for integration/feature testing, so you'll need to get those installed.
26
+
27
+ = ENVIRONMENT:
28
+
29
+ In order to have a dev environment where you can work on Ohai, you'll need to install a few additional gems after setting up the Git repository.
30
+
31
+ Install the following RubyGems.
32
+
33
+ * rake
34
+ * rspec
35
+ * extlib
36
+ * systemu
37
+ * json
38
+
39
+ gem install rake rspec extlib systemu json
40
+
41
+ == Rake Tasks
42
+
43
+ Ohai has some Rake tasks for doing various things.
44
+
45
+ rake -T
46
+ rake clobber_package # Remove package products
47
+ rake gem # Build the gem file ohai-$VERSION.gem
48
+ rake install # install the gem locally
49
+ rake make_spec # create a gemspec file
50
+ rake package # Build all the packages
51
+ rake repackage # Force a rebuild of the package files
52
+ rake spec # Run specs
53
+
54
+ ($VERSION is the current version, from the GemSpec in Rakefile)
55
+
56
+ == Spec Testing:
57
+
58
+ We use RSpec for unit/spec tests.
59
+
60
+ rake spec
61
+
62
+ Because ohai gathers system information, and we don't know what kind of system we might be running on (yet), we're moving away from specs for integration testing and to cucumber.
63
+
64
+ = LINKS:
65
+
66
+ Source:
67
+
68
+ * http://github.com/opscode/ohai/tree/master
69
+
70
+ Tickets/Issues:
71
+
72
+ * http://tickets.opscode.com/
73
+
74
+ (Use the OHAI project)
75
+
76
+ Documentation:
77
+
78
+ * http://wiki.opscode.com/display/ohai/Home/
79
+
80
+ = LICENSE:
81
+
82
+ Ohai - system information application
83
+
84
+ Author:: Adam Jacob (<adam@opscode.com>)
85
+ Copyright:: Copyright (c) 2008 Opscode, Inc.
86
+ License:: Apache License, Version 2.0
87
+
88
+ Licensed under the Apache License, Version 2.0 (the "License");
89
+ you may not use this file except in compliance with the License.
90
+ You may obtain a copy of the License at
91
+
92
+ http://www.apache.org/licenses/LICENSE-2.0
93
+
94
+ Unless required by applicable law or agreed to in writing, software
95
+ distributed under the License is distributed on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
97
+ See the License for the specific language governing permissions and
98
+ limitations under the License.
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+ require 'spec/rake/spectask'
6
+
7
+ GEM = "ohai"
8
+ GEM_VERSION = "0.3.4"
9
+ AUTHOR = "Adam Jacob"
10
+ EMAIL = "adam@opscode.com"
11
+ HOMEPAGE = "http://wiki.opscode.com/display/ohai"
12
+ SUMMARY = "Ohai profiles your system and emits JSON"
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = GEM
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.has_rdoc = true
19
+ s.summary = SUMMARY
20
+ s.description = s.summary
21
+ s.author = AUTHOR
22
+ s.email = EMAIL
23
+ s.homepage = HOMEPAGE
24
+
25
+ s.add_dependency "extlib"
26
+ s.add_dependency "systemu"
27
+ s.add_dependency "mixlib-cli"
28
+ s.add_dependency "mixlib-config"
29
+ s.add_dependency "mixlib-log"
30
+ s.bindir = "bin"
31
+ s.executables = %w(ohai)
32
+
33
+ s.require_path = 'lib'
34
+ s.autorequire = GEM
35
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{extras,lib,spec}/**/*")
36
+ end
37
+
38
+ task :default => :spec
39
+
40
+ desc "Run specs"
41
+ Spec::Rake::SpecTask.new do |t|
42
+ t.spec_files = FileList['spec/**/*_spec.rb']
43
+ t.spec_opts = %w(-fs --color)
44
+ end
45
+
46
+
47
+ Rake::GemPackageTask.new(spec) do |pkg|
48
+ pkg.gem_spec = spec
49
+ end
50
+
51
+ desc "install the gem locally"
52
+ task :install => [:package] do
53
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
54
+ end
55
+
56
+ desc "create a gemspec file"
57
+ task :make_spec do
58
+ File.open("#{GEM}.gemspec", "w") do |file|
59
+ file.puts spec.to_ruby
60
+ end
61
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # ./ohai - I'm in ur serverz, showin you the daters
4
+ #
5
+ # Author:: Adam Jacob (<adam@opscode.com>)
6
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ $: << File.join(File.dirname(__FILE__), "..", "lib")
23
+ require 'ohai/application'
24
+ Ohai::Application.new.run
@@ -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
+ $:.unshift(File.dirname(__FILE__)) unless
20
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
21
+
22
+ require 'ohai/config'
23
+ require 'ohai/system'
24
+
25
+ module Ohai
26
+ VERSION = '0.3.3'
27
+ end
@@ -0,0 +1,113 @@
1
+ #
2
+ # Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
3
+ # Copyright:: Copyright (c) 2009 Mathieu Sauve-Frankel.
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
+ require 'ohai'
19
+ require 'ohai/log'
20
+ require 'mixlib/cli'
21
+
22
+ class Ohai::Application
23
+ include Mixlib::CLI
24
+
25
+ option :directory,
26
+ :short => "-d DIRECTORY",
27
+ :long => "--directory DIRECTORY",
28
+ :description => "A directory to add to the Ohai search path"
29
+
30
+ option :file,
31
+ :short => "-f FILE",
32
+ :long => "--file FILE",
33
+ :description => "A file to run Ohai against"
34
+
35
+ option :log_level,
36
+ :short => "-l LEVEL",
37
+ :long => "--log_level LEVEL",
38
+ :description => "Set the log level (debug, info, warn, error, fatal)",
39
+ :proc => lambda { |l| l.to_sym }
40
+
41
+ option :log_location,
42
+ :short => "-L LOGLOCATION",
43
+ :long => "--logfile LOGLOCATION",
44
+ :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
45
+ :proc => nil
46
+
47
+ option :help,
48
+ :short => "-h",
49
+ :long => "--help",
50
+ :description => "Show this message",
51
+ :on => :tail,
52
+ :boolean => true,
53
+ :show_options => true,
54
+ :exit => 0
55
+
56
+ option :version,
57
+ :short => "-v",
58
+ :long => "--version",
59
+ :description => "Show chef version",
60
+ :boolean => true,
61
+ :proc => lambda {|v| puts "Ohai: #{::Ohai::VERSION}"},
62
+ :exit => 0
63
+
64
+ def run
65
+ configure_ohai
66
+ configure_logging
67
+ run_application
68
+ end
69
+
70
+ def configure_ohai
71
+ @attributes = parse_options
72
+
73
+ Ohai::Config.merge!(config)
74
+ if Ohai::Config[:directory]
75
+ Ohai::Config[:plugin_path] << Ohai::Config[:directory]
76
+ end
77
+ end
78
+
79
+ def configure_logging
80
+ Ohai::Log.init(Ohai::Config[:log_location])
81
+ Ohai::Log.level(Ohai::Config[:log_level])
82
+ end
83
+
84
+ def run_application
85
+ ohai = Ohai::System.new
86
+ if Ohai::Config[:file]
87
+ ohai.from_file(Ohai::Config[:file])
88
+ else
89
+ ohai.all_plugins
90
+ end
91
+ if @attributes.length > 0
92
+ @attributes.each do |a|
93
+ puts ohai.attributes_print(a)
94
+ end
95
+ else
96
+ puts ohai.json_pretty_print
97
+ end
98
+ end
99
+
100
+ class << self
101
+ # Log a fatal error message to both STDERR and the Logger, exit the application
102
+ def fatal!(msg, err = -1)
103
+ STDERR.puts("FATAL: #{msg}")
104
+ Chef::Log.fatal(msg)
105
+ Process.exit err
106
+ end
107
+
108
+ def exit!(msg, err = -1)
109
+ Chef::Log.debug(msg)
110
+ Process.exit err
111
+ end
112
+ end
113
+ end