The guys at
Opscode recently released
ohai and
Chef. ohai "Ohai profiles your system and emits JSON" and "Chef is a systems management framework masquerading as a configuration management tool." Ezra Zygmuntowicz explains the details over
here. I decided to check out ohai today here's what I came up with.
First, just for fun I wrote a little rack server that serves up the JSON that ohai produces.
require 'rubygems'
require 'rack'
class OhaiRack
def call(env)
data = IO.popen("ohai")
info = data.readlines
[200, {"Content-Type"=>"text/plain"}, ["#{info.join}"]]
end
end
app = Rack::Builder.new {
use Rack::CommonLogger, STDERR
run OhaiRack.new
}.to_app
server = Rack::Handler::Mongrel
options = {:Host => "127.0.0.1", :Port => 3000}
server.run app, options
I also wrote a erlang plugin so that ohai can get the version and details about your erlang installation. I put the following code in
/usr/lib/ruby/gems/1.8/gems/ohai-0.1.2/lib/ohai/plugins/erlang.rb, your location may be different depending on your ruby and/or gems installation location.
require_plugin "languages"
require "open3"
languages[:erlang] = Mash.new
stdin, stdout, stderr = Open3.popen3('erl +V')
output = stderr.gets
info = output.split
languages[:erlang][:version] = info[5]
languages[:erlang][:options] = info[1]
languages[:erlang][:emulator] = info[2]
The output should look something like:
"erlang": {
"name": "Erlang",
"version": "5.6.5",
"emulator": "(BEAM)",
"options": "(SMP,ASYNC_THREADS,HIPE)"
Anywho, kinda fun and worth checking out, especially if you are working on the cloud.