Issue with sensu-plugin gem on Debian Wheezy

As it has taken me a considerable amount of time to sort this and would like to avoid the same kind of pain to someone else facing the same problem, let me quickly summarize the context, the issue and the solution.

The Context

I have been playing during the last week with Sensu, Graphite and few other items to build a monitoring/graphing solution for a new product we are about to launch.

All the servers that we want to monitor have also the amazing Mcollective tool (orchestration) installed.

The Issue

While following this great post about how to link Sensu and Graphite, I faced a strange error when trying to run the vmstat-metrics plugin.

Basically, after properly installing the  sensu-plugin gem, I was getting the following error when trying to execute the vmstat-metrics plugin:

root@web1:/etc/sensu/plugins# ./vmstat-metrics.rb
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- sensu-plugin/metric/cli (LoadError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from ./vmstat-metrics.rb:17

Of course the sensu-plugin gem was properly installed:

root@web1:/etc/sensu/plugins# gem list
*** LOCAL GEMS ***
json (1.8.1)
mixlib-cli (1.3.0)
sensu-plugin (0.2.1)

Which suggested we could have some nasty path or version issue. 

The Solution

After much research here and there with which I will not bore you, I realized that ruby alternatives were not properly configured (most probably something related with mcollective but can't ascertain): 

root@web1:/etc/sensu/plugins# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/ruby1.9.1   51        auto mode
* 1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   51        manual mode
Press enter to keep the current choice[*], or type selection number: 0
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in auto mode

When they should have been (as compared with another server with  vmstat-metrics plugin working): 

root@web1:/etc/sensu/plugins# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.9.1   51        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
  2            /usr/bin/ruby1.9.1   51        manual mode
Press enter to keep the current choice[*], or type selection number:

Just with his change (and as sensu-plugin was deployed to ruby1.9.1) all started to work immediately and I could continue with my adventures with Sensu & friends:

root@web1:/etc/sensu/plugins# ./vmstat-metrics.rb
web1.vmstat.procs.waiting    0    1382899284
web1.vmstat.procs.uninterruptible    0    1382899284
web1.vmstat.memory.swap_used    0    1382899284
web1.memory.free    134152    1382899284
...