Created
April 2, 2013 17:34
-
-
Save dallasmarlow/5294311 to your computer and use it in GitHub Desktop.
check hbase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env tumblr_ruby | |
| require 'nrpe_check/extend' | |
| require 'timeout' | |
| require 'json' | |
| @options = { | |
| timeout: 120, # seconds | |
| hbck_command: 'hbase hbck 2>/dev/null', | |
| hbck_keys: [ | |
| 'Version', | |
| 'Master', | |
| 'Status', | |
| 'Number of Tables', | |
| 'Number of live region servers', | |
| 'Number of dead region servers', | |
| 'Number of backup masters', | |
| ], | |
| } | |
| check do | |
| status :unknown, 'unable to determine hbck status' # register an initial status | |
| # query hbase for status | |
| hbck_output, hbck_status = Timeout.timeout @options[:timeout] do | |
| [%x[#{@options[:hbck_command]}], $?] | |
| end | |
| # parse result | |
| hbase_status = hbck_output.lines.reduce({}) do |status, line| | |
| if @options[:hbck_keys].any? {|key| line.include? key} | |
| key, value = line.chomp.split ':' | |
| status[key] = value.strip | |
| end | |
| status | |
| end | |
| # check hbase | |
| case | |
| when hbase_status['Number of dead region servers'].to_i != 0 | |
| exit_with_status :critical, "dead region servers: #{hbase_status['Number of dead region servers']}" | |
| when hbase_status['Status'] != 'OK' | |
| exit_with_status :critical, "hbck status: #{hbase_status['Status']}" | |
| when hbck_status.exitstatus != 0 | |
| exit_with_status :critical, "hbck status: unhealthy" | |
| else | |
| status :ok, hbase_status.to_json | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment