Skip to content

Instantly share code, notes, and snippets.

@abhijith
Created April 13, 2012 10:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save abhijith/2375847 to your computer and use it in GitHub Desktop.
sensu check-hbase-status plugin
#!/usr/bin/hbase org.jruby.Main
#
# HBase status plugin
# ===
#
# This plugin checks if any of the regionservers are down
#
# Copyright 2012 Runa Inc
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
$: << Dir.glob("/var/lib/gems/1.8/gems/mixlib-cli*/lib")
$: << Dir.glob("/var/lib/gems/1.8/gems/sensu-plugin*/lib")
$:.flatten!
require 'java'
require 'rubygems'
require 'mixlib/cli'
require 'sensu-plugin/check/cli'
require 'java'
include Java
import org.apache.hadoop.hbase.client.HBaseAdmin
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.log4j.Logger
packages = ["org.apache.zookeeper", "org.apache.hadoop", "org.apache.hadoop.hbase"]
packages.each do |package|
logger = org.apache.log4j.Logger.getLogger(package)
logger.setLevel(org.apache.log4j.Level::ERROR);
end
class CheckRabbitMQ < Sensu::Plugin::Check::CLI
def check_hbase_status
conf = HBaseConfiguration.new
admin = HBaseAdmin.new(conf)
status = admin.getClusterStatus()
dead_servers = status.getDeadServerNames()
count = dead_servers.length
if count == 0
ok "Alive"
else
critical "Dead: #{dead_servers.join(" ")}"
end
unknown "No output from plugin"
end
def run
check_hbase_status
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment