Fix import, add hbase up/health vars
This commit is contained in:
parent
6138487566
commit
408e3d8ac9
@ -24,6 +24,7 @@ import random
|
||||
import re
|
||||
import requests
|
||||
import subprocess
|
||||
from subprocess import Popen
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
@ -47,6 +48,8 @@ prom_hdfs_used = Gauge('hdfs_bytes_used', 'HDFS used bytes')
|
||||
prom_hdfs_remaining = Gauge('hdfs_bytes_remaining', 'HDFS remaining bytes')
|
||||
prom_hdfs_num_datanodes_live = Gauge('hdfs_datanodes_live', 'HDFS Live DataNodes')
|
||||
prom_hdfs_num_datanodes_dead = Gauge('hdfs_datanodes_dead', 'HDFS Dead DataNodes')
|
||||
prom_hbase_up = Gauge('hbase_up', 'HBase is up and running, a master is elected')
|
||||
prom_hbase_healthy = Gauge('hbase_healthy', 'HBase is up and running, a master is elected, no inconsistencies are detected, hbase is queryable')
|
||||
prom_hbase_num_regionservers_live = Gauge('hbase_regionservers_live', 'HBase Live Regionservers')
|
||||
prom_hbase_num_regionservers_dead = Gauge('hbase_regionservers_dead', 'HBase Dead Regionservers')
|
||||
prom_hbase_num_clusterrequests = Gauge('hbase_clusterrequests', 'HBase Clusterrequests')
|
||||
@ -54,6 +57,7 @@ prom_hbase_num_clusterrequests = Gauge('hbase_clusterrequests', 'HBase Clusterre
|
||||
# HDFS/HBase
|
||||
hdfs_config_file = "/etc/hadoop/conf/hdfs-site.xml"
|
||||
cmd_hbase_active_master = ['/usr/hdp/current/hbase-client/bin/hbase-jruby', '/usr/hdp/current/hbase-client/bin/get-active-master.rb']
|
||||
cmd_hbase_hbck = ['hbase', 'hbck']
|
||||
cmd_hdfs_namenodes = ['hdfs', 'getconf', '-namenodes']
|
||||
namenodes = ""
|
||||
namenode_use_tls = False
|
||||
@ -199,10 +203,27 @@ class hbase_exporter():
|
||||
|
||||
if not hbase_active_master:
|
||||
logging.info("Failed to determine active HBase master")
|
||||
prom_hbase_up.set(0)
|
||||
prom_hbase_healthy.set(0)
|
||||
return False
|
||||
|
||||
self.get_stale_regions_in_transition(hbase_active_master)
|
||||
#self.hbck_get_inconsistencies()
|
||||
self.hbck_get_inconsistencies()
|
||||
self.check_health()
|
||||
|
||||
def check_health():
|
||||
if self.num_inconsistencies > 0:
|
||||
prom_hbase_healthy.set(0)
|
||||
return False
|
||||
|
||||
if prom_ihbase_regions_in_transition_stale > 0:
|
||||
prom_hbase_healthy.set(0)
|
||||
return False
|
||||
|
||||
prom_hbase_up.set(1)
|
||||
prom_hbase_healthy.set(1)
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def get_active_master():
|
||||
@ -221,6 +242,7 @@ class hbase_exporter():
|
||||
if 'Master not running' in r.stdout.decode('utf-8'):
|
||||
return False
|
||||
|
||||
prom_hbase_up.set(1)
|
||||
return r.stdout.decode('utf-8')
|
||||
|
||||
def get_stale_regions_in_transition(self, hbase_master):
|
||||
@ -252,8 +274,10 @@ class hbase_exporter():
|
||||
|
||||
msg = '{0} regions stale in transition '\
|
||||
.format(num_regions_in_transition_stale)
|
||||
|
||||
prom_hbase_num_regions_in_transition_stale.set(num_regions_in_transition_stale)
|
||||
logging.info(msg)
|
||||
|
||||
return num_regions_in_transition_stale
|
||||
|
||||
def hbaseui_parse_output(self, content):
|
||||
@ -314,6 +338,9 @@ class hbase_exporter():
|
||||
|
||||
if not isinstance(num_inconsistencies, int):
|
||||
logging.info('Error: Non-integer detected for the number of inconsistencies')
|
||||
return False
|
||||
|
||||
self.num_inconsistencies = num_inconsistencies
|
||||
|
||||
@staticmethod
|
||||
def hbaseui_parse_table(table):
|
||||
|
Loading…
Reference in New Issue
Block a user