January 16, 2009

Chef and ohai.

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″, :P ort => 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.

merle 0.1 release.

It’s official, I have released merle 0.1. Download it here.

Features:
* Support for the following memcached commands : stats, version, get, delete, set, add, replace, append, prepend, cas
* Supports making calls to memcached directly as well as through gen_server

Let me know what you think and report back if you find any bugs. Thanks!

January 14, 2009

Merle Updates.

I just pushed out some new code to github for merle. It should have some nice new treats in it for you including a new recieve loop for large objects. Just to make sure it worked properly I ran md5’s on the input and output, example below. In the last few days I have also added a few new calls such as version/0 which gets the memcached version for you. Check out the readme for examples and entire API. Things are getting close to the first full release so stay tuned.

2> merle:start_link(“localhost”, 11211).
{ok,<0.38.0>}
3> {ok, TestPDF} = file:read_file(“test.pdf”).
{ok,<<"%PDF-1.4\n11 0 obj\n<< /S /GoTo /D (Outline1) >>\nendobj\n14 0 obj\n(Introduction)\nendobj\n15 0 obj\n<< /S /GoTo /D"...>>}
4> merle:set(“a”, “1″, “0″, TestPDF).
["STORED"]
5> merle:get(“a”).
[<<"%PDF-1.4\n11 0 obj\n<< /S /GoTo /D (Outline1) >>\nendobj\n14 0 obj\n(Introduction)\nendobj\n15 0 obj\n<< /S /GoTo /D (Ou"...>>]
6> [TestPDF1] = merle:get(“a”).
[<<"%PDF-1.4\n11 0 obj\n<< /S /GoTo /D (Outline1) >>\nendobj\n14 0 obj\n(Introduction)\nendobj\n15 0 obj\n<< /S /GoTo /D (Ou"...>>]
7> erlang:md5(TestPDF).
<<120,165,244,215,18,94,214,215,236,65,148,80,135,39,68,
125>>
8> erlang:md5(TestPDF1).
<<120,165,244,215,18,94,214,215,236,65,148,80,135,39,68,
125>>

Seattle Erlounge.

For anyone in or around the Seattle metro area we are starting an Erlounge up and the first meeting is Wednesday January 21st, 7pm at the Garage.
You can find more information at http://erloungeseattle.org/ Hope to see you there.

January 12, 2009

megaman vs all the bosses at once.

YouTube Preview Image

[Found at offworld.]