Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

JRuby hbase plugins #41

merged 1 commit into from Apr 6, 2013


None yet
4 participants

abhijith commented Apr 9, 2012

  • check hbase status
  • check number of regions on a regionserver

There's a bit of code common to both the plugins. Need to figure out a way to do factor it out. Ideas?


portertech commented Apr 11, 2012

@abhijith Nice work! Is there a reason you didn't use the sensu-plugin gem? It would provide cli arg parsing (w/ a bit of self documenting), and cut down the boilerplate code in both plugins. Would it be possible to provide some sample output in your environment? This one is kinda hard for me to test :) Thanks!


abhijith commented Apr 12, 2012

@portertech Thanks!

I have written very little JRuby code. So I am not sure how to go about using gems with it. Is it possible to use the sensu-plugin gem with JRuby? If so, how do I go about it?


abhijith commented Apr 13, 2012

Nevermind the previous comment. Figured it out.

However, using sensu-plugin is not straightforward in this case.

Following are the complications:

  • chd3u3 ships with jruby-1.6.0 which has a bug which shows up during gem installation (Strangely, it does not affect all gems). JRuby 1.6.0 jar will have to be replaced with 1.6.2 which contains the fix for the bug.


Steps to be followed to get his working:

a) wget http://jruby.org.s3.amazonaws.com/downloads/1.6.2/jruby-complete-1.6.2.jar

b) mv jruby-complete-1.6.2.jar /usr/lib/hbase/lib/jruby-complete-1.x.x.jar

  • The plugin needs to explicitly add the gem path for mixlib-cli and sensu-plugin like so:
$:.push Dir.glob("/var/lib/gems/1.8/gems/mixlib-cli*/lib")
$:.push Dir.glob("/var/lib/gems/1.8/gems/sensu-plugin*/lib")

This makes assumptions about both the platform and the gem directory path.

Although using sensu-plugin removes the redundant code, it makes the plugins harder to use by introducing manual steps. Let me know if there is a better way to solve the above problems.

Link to the version using sensu-plugin: https://gist.github.com/2375847


decklin commented Apr 16, 2012

Hi - I'd definitely like sensu-plugin to be usable with JRuby. If think opening an issue in its repo would be appropriate, please go ahead.

I'm not sure I understand the 1.6.0 bug -- is adding the /var/lib/gems/1.8/gems path to $: just a workaround for this? A quick googling brings up http://kenai.com/projects/jruby/pages/GettingStarted#Installing_and_Using_Ruby_Gems which seems to imply to me that JRuby would install gems somewhere that it controls, not to /var/lib/gems/1.8 (looks like the typical Debian/Ubuntu path). Is that right?


abhijith commented Apr 16, 2012

@decklin: The JRuby bug shows up when we try to install gems. I don't think this has got anything to do with sensu-plugin as such. This seems to be affecting lot of other gems too.
The problem is in https://github.com/olabini/yecht which has been fixed and bundled with newer version of JRuby which explains why senu-plugin works with JRuby 1.6.2.

Adding /var/lib/gems/1.8/gems to path is not a workaround for the bug. This is a separate step that is required if we have to use gems which are not bundled with JRuby. This would hold true even if the JRuby bug hadn't existed.
Note that, we are exec'ing the plugin using "#!/usr/bin/hbase org.jruby.Main". This will look inside the jar for gems which have been "require'd" and won't find it. Hence, we need to explicitly add /var/lib/gems/1.8... to $:

And yes, JRuby would install gems to a different path.

NOTE: I am very new to JRuby and still trying to find my way around. Please feel free to comment if you think I am missing something obvious.


portertech commented Apr 16, 2012

This plugin can potentially be an executable Java JAR, using warbler (w/ bundler support) to vendor everything.


nstielau commented Dec 14, 2012

Let's get this merged or closed. I vote that if it works for you @abhijith we should merge it. If there is any weirdness with JRuby still, let's either add an EXPERIMENTAL note in the header, or more explicitly move it to a plugins/experimental/hbase/ directory.


portertech commented Dec 14, 2012

JRuby 1.7 is now available as well, the plugin looks pretty clean, 👍


abhijith commented Dec 16, 2012

@nstielau: works fine. we've been using it in production for about a year now. I guess its good enough to be merged in with a 'experimental' tag like time you've mentioned.

@abhijith abhijith closed this Dec 16, 2012

@abhijith abhijith reopened this Dec 16, 2012


abhijith commented Dec 16, 2012

Oops clicked the close button by mistake

portertech added a commit that referenced this pull request Apr 6, 2013

@portertech portertech merged commit 4e7ccb4 into sensu:master Apr 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment