def run(self): self.no_args() host = self.get_opt('host') port = self.get_opt('port') table = self.get_opt('table') validate_host(host) validate_port(port) validate_database_tablename(table) # raises 500 error if table doesn't exist url = 'http://%(host)s:%(port)s/table.jsp?name=%(table)s' % locals() log.debug('GET %s', url) try: req = requests.get(url) except requests.exceptions.RequestException as _: raise CriticalError(_) log.debug("response: %s %s", req.status_code, req.reason) log.debug("content:\n%s\n%s\n%s", '='*80, req.content.strip(), '='*80) if req.status_code != 200: info = '' #if req.status_code == '500' and 'TableNotFoundException' in req.content: if 'TableNotFoundException' in req.content: info = 'table not found' raise CriticalError("%s %s %s" % (req.status_code, req.reason, info)) is_table_compacting = self.parse_is_table_compacting(req.content) self.msg = 'HBase table \'{0}\' '.format(table) if is_table_compacting: self.warning() self.msg += 'has compaction in progress' else: self.msg += 'has no compaction in progress'
def process_args(self): # this resets DEBUG env var #log.setLevel(logging.INFO) self.no_args() self.host = self.get_opt('host') self.port = self.get_opt('port') validate_host(self.host) validate_port(self.port) self.table = self.get_opt('table') self.num_rows = self.get_opt('num') self.key_length = self.get_opt('key_length') self.value_length = self.get_opt('value_length') validate_database_tablename(self.table) validate_int(self.num_rows, 'num rows', 1, 1000000000) validate_int(self.key_length, 'key length', 10, 1000) validate_int(self.value_length, 'value length', 1, 1000000) self.num_rows = int(self.num_rows) self.skew = self.get_opt('skew') log_option('skew data', self.skew) self.skew_pc = self.get_opt('skew_percentage') validate_int(self.skew_pc, 'skew percentage', 0, 100) self.skew_pc = int(self.skew_pc) self.drop_table = self.get_opt('drop_table') self.use_existing_table = self.get_opt('use_existing_table') if self.drop_table and self.table != self.default_table_name: die("not allowed to use --drop-table if using a table name other than the default table '{0}'"\ .format(self.default_table_name))
def process_args(self): # this resets DEBUG env var #log.setLevel(logging.INFO) self.no_args() self.host = self.get_opt('host') self.port = self.get_opt('port') validate_host(self.host) validate_port(self.port) # happybase socket requires an integer self.port = int(self.port) self.table = self.get_opt('table') self.num_rows = self.get_opt('num') self.key_length = self.get_opt('key_length') self.value_length = self.get_opt('value_length') validate_database_tablename(self.table) validate_int(self.num_rows, 'num rows', 1, 1000000000) validate_int(self.key_length, 'key length', 10, 1000) validate_int(self.value_length, 'value length', 1, 1000000) self.num_rows = int(self.num_rows) self.skew = self.get_opt('skew') log_option('skew data', self.skew) self.skew_pc = self.get_opt('skew_percentage') validate_int(self.skew_pc, 'skew percentage', 0, 100) self.skew_pc = int(self.skew_pc) self.drop_table = self.get_opt('drop_table') self.use_existing_table = self.get_opt('use_existing_table') if self.drop_table and self.table != self.default_table_name: die("not allowed to use --drop-table if using a table name other than the default table '{0}'"\ .format(self.default_table_name))
def run(self): self.no_args() host = self.get_opt('host') port = self.get_opt('port') table = self.get_opt('table') validate_host(host) validate_port(port) validate_database_tablename(table) # raises 500 error if table doesn't exist url = 'http://%(host)s:%(port)s/table.jsp?name=%(table)s' % locals() log.debug('GET %s', url) try: req = requests.get(url) except requests.exceptions.RequestException as _: qquit('CRITICAL', _) log.debug("response: %s %s", req.status_code, req.reason) log.debug("content:\n%s\n%s\n%s", '='*80, req.content.strip(), '='*80) if req.status_code != 200: info = '' #if req.status_code == '500' and 'TableNotFoundException' in req.content: if 'TableNotFoundException' in req.content: info = 'table not found' qquit('CRITICAL', "%s %s %s" % (req.status_code, req.reason, info)) is_table_compacting = self.parse_is_table_compacting(req.content) self.msg = 'HBase table \'{0}\' '.format(table) if is_table_compacting: self.warning() self.msg += 'has compaction in progress' else: self.msg += 'has no compaction in progress'
def run(self): self.no_args() self.host = self.get_opt('host') self.port = self.get_opt('port') validate_host(self.host) validate_port(self.port) self.list_tables = self.get_opt('list') if not self.list_tables: self.table = self.get_opt('table') validate_database_tablename(self.table, 'hbase') self.validate_thresholds(simple='lower', min=1) self.connect() if self.list_tables: tables = self.get_tables() print('HBase Tables:\n\n' + '\n'.join(tables)) sys.exit(ERRORS['UNKNOWN']) self.check_table_regions()
def run(self): self.no_args() self.host = self.get_opt('host') self.port = self.get_opt('port') self.table = self.get_opt('table') validate_host(self.host) validate_port(self.port) validate_database_tablename(self.table, 'hbase') try: log.info('connecting to HBase Thrift Server at %s:%s', self.host, self.port) # cast port to int to avoid low level socket module TypeError for ports > 32000 self.conn = happybase.Connection(host=self.host, port=int(self.port), timeout=10 * 1000) # ms except (socket.error, socket.timeout, ThriftException, HBaseIOError) as _: qquit('CRITICAL', 'error connecting: {0}'.format(_)) if self.get_opt('list'): tables = self.get_tables() print('HBase Tables:\n\n' + '\n'.join(tables)) sys.exit(ERRORS['UNKNOWN']) log.info('checking table \'%s\'', self.table) is_enabled = None try: is_enabled = self.conn.is_table_enabled(self.table) except HBaseIOError as _: #if 'org.apache.hadoop.hbase.TableNotFoundException' in _.message: if 'TableNotFoundException' in _.message: qquit('CRITICAL', 'table \'{0}\' does not exist'.format(self.table)) else: qquit('CRITICAL', _) except (socket.error, socket.timeout, ThriftException) as _: qquit('CRITICAL', _) if not is_enabled: self.critical() self.msg = 'HBase table \'{0}\' enabled = {1}'.format( self.table, is_enabled) log.info('finished, closing connection') self.conn.close()
def run(self): self.no_args() self.host = self.get_opt('host') self.port = self.get_opt('port') self.table = self.get_opt('table') validate_host(self.host) validate_port(self.port) validate_database_tablename(self.table, 'hbase') try: log.info('connecting to HBase Thrift Server at %s:%s', self.host, self.port) # cast port to int to avoid low level socket module TypeError for ports > 32000 self.conn = happybase.Connection(host=self.host, port=int(self.port), timeout=10 * 1000) # ms except (socket.error, socket.timeout, ThriftException, HBaseIOError) as _: qquit('CRITICAL', 'error connecting: {0}'.format(_)) if self.get_opt('list'): tables = self.get_tables() print('HBase Tables:\n\n' + '\n'.join(tables)) sys.exit(ERRORS['UNKNOWN']) log.info('checking table \'%s\'', self.table) is_enabled = None try: is_enabled = self.conn.is_table_enabled(self.table) except HBaseIOError as _: #if 'org.apache.hadoop.hbase.TableNotFoundException' in _.message: if 'TableNotFoundException' in _.message: qquit('CRITICAL', 'table \'{0}\' does not exist'.format(self.table)) else: qquit('CRITICAL', _) except (socket.error, socket.timeout, ThriftException) as _: qquit('CRITICAL', _) if not is_enabled: self.critical() self.msg = 'HBase table \'{0}\' enabled = {1}'.format(self.table, is_enabled) log.info('finished, closing connection') self.conn.close()