Chef and ohai.
Joe Williams - - January 17, 2009The 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
endapp = Rack::Builder.new {
use Rack::CommonLogger, STDERR
run OhaiRack.new
}.to_appserver = 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.splitlanguages[: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.
Categories: Blogs Joe Williams
Comments
Add comment
Erlang on Twitter
» koher (koher): 本の並びが順に、Struts、SaaS、Slim3、Ajax、Spring、Scala、Erlang、Seasar2ってもうカオスだ…。
» josevalim (José Valim): Sweet. homebrew updated Erlang recipe to R15B, going to make it the required dependency for Elixir.
» stackfeed (StackOverflow): Erlang: unmarshalling variable length data fields in binary stream: I’m creating an Erlang application that need… http://t.co/0yDGJWz7
» tugocof (Bilski Storer): Viola Tricolor L. in Morphologischer, Anatomischer Und Biologischer Beziehung: Inaugural-Dissertation Zur Erlang… http://t.co/C4ojnX3h
» mickael (Mickaël Rémond): Hehe :)
RT @ostinelli spent the whole day in building an #ejabberd module. i just love this stuff. ^^_ #erlang
» darkproger (proger): RT @metabrew: If you use vim for #erlang, you might be interested in my rebar-friendly vimerl modifications: https://t.co/dSIKOs9p
» bipthelin (Bip Thelin): haven’t seen Hotline in a while RT “@github_erlang: hotline - Browser based Hotline client in Erlang http://t.co/mF50rC7D”
» erlang (Andreas Åkre Solberg): Mine bilder fra vakre Helgeland http://t.co/WNSNhNiw i min nye fancy bildefremviser
» github_erlang (GitHub Erlang): hotline - Browser based Hotline client in Erlang http://t.co/iLT9GmOG
» oki_dimas (Oki dimas mahendra ): Km wuching “@HammyDC: Bkan.. Aq dewa erlang.. RT @oki_dimas Bukan siluman “@HammyDC: Aq jdi yoko klo gtu..”
Statistics
Number of aggregated posts: 10454
Number of comments: 1392
Most recent article: January 31, 2012
Latest comments
» nobelboy on OpaDo Data Storage: Feel free to add some Qs here or contact me offline, and I will see what I can work into…
» darrensy on The Twisted Matrix: This has been a great idea you have shared. covers for kindle
» jony on Principle Software Engineer at LonoCloud (Full-time): That provides will become a internet marketer of little kinds of expert methods developers developing strategy using Erlang/OTP. There will…