Exemple #1
0
 def __init__(self):
     # Python 2.x
     super(PubSubNagiosPlugin, self).__init__()
     # Python 3.x
     # super().__init__()
     self.name = None
     self.default_host = 'localhost'
     self.default_port = None
     self.host = None
     self.port = None
     self.producer = None
     self.consumer = None
     self.key = os.path.basename(get_topfile()) + '-' + random_alnum(20)
     self.start_offset = None
     timestamp = time.time()
     # socket.getfqdn() hangs on network / DNS outage, use socket.gethostname() instead
     self.publish_message = "Test message from Hari Sekhon {0} on host {1} "\
                            .format(os.path.basename(get_topfile()), socket.gethostname()) + \
                             "at epoch {0} ({1}) with random token '{2}'"\
                            .format(timestamp, time.ctime(timestamp), random_alnum(20))
     self._consumed_message = None
     self._publish_timing = None
     self._consume_timing = None
     self.status = 'OK'
     self.warning = 1
     self.critical = 2
 def __init__(self):
     # Python 2.x
     super(PubSubNagiosPlugin, self).__init__()
     # Python 3.x
     # super().__init__()
     self.name = None
     self.default_host = 'localhost'
     self.default_port = None
     self.host = None
     self.port = None
     self.producer = None
     self.consumer = None
     self.key = os.path.basename(get_topfile()) + '-' + random_alnum(20)
     self.start_offset = None
     timestamp = time.time()
     # socket.getfqdn() hangs on network / DNS outage, use socket.gethostname() instead
     self.publish_message = "Test message from Hari Sekhon {0} on host {1} "\
                            .format(os.path.basename(get_topfile()), socket.gethostname()) + \
                             "at epoch {0} ({1}) with random token '{2}'"\
                            .format(timestamp, time.ctime(timestamp), random_alnum(20))
     self._consumed_message = None
     self._publish_time = None
     self._consume_time = None
     self._total_time = None
     self._precision = 3
     self.status = 'OK'
     self.warning_threshold_default = 1
     self.critical_threshold_default = 2
     self.__sleep_secs = 0
 def __init__(self):
     # Python 2.x
     super(KeyWriteNagiosPlugin, self).__init__()
     # Python 3.x
     # super().__init__()
     self.key = os.path.basename(get_topfile()) + "-" + random_alnum(20)
     self._write_value = random_alnum(20)
     self._write_timing = None
     self._delete_timing = None
 def __init__(self):
     # Python 2.x
     super(KeyWriteNagiosPlugin, self).__init__()
     # Python 3.x
     # super().__init__()
     self.key = os.path.basename(get_topfile()) + '-' + random_alnum(20)
     self._write_value = random_alnum(20)
     self._write_timing = None
     self._delete_timing = None
 def __init__(self):
     # Python 2.x
     super(CheckKafka, self).__init__()
     # Python 3.x
     # super().__init__()
     self.name = 'Kafka'
     self.default_host = 'localhost'
     self.default_port = '9092'
     self.producer = None
     self.consumer = None
     self.topic = None
     self.client_id = 'Hari Sekhon {prog} {version}'.format(
         prog=os.path.basename(get_topfile()), version=__version__)
     self.group_id = '{client_id} {pid} {random}'.format(
         client_id=self.client_id, pid=os.getpid(), random=random_alnum(10))
     self.acks = '1'
     self.retries = 0
     self.partition = None
     self.topic_partition = None
     self.brokers = None
     self.timeout_ms = None
     self.start_offset = None
     self.sleep_secs = 0
     self.sleep_usage = 'Sleep in seconds between producing and consuming from given topic' + \
                        ' (optional, default: {} secs)'.format(self.default_sleep_secs)
Exemple #6
0
 def __init__(self):
     # Python 2.x
     super(CheckHBaseWrite, self).__init__()
     # Python 3.x
     # super().__init__()
     self.conn = None
     self.host = None
     self.port = None
     self.table = None
     now = time.time()
     self.row = '{0}#{1}#{2}'.format(random_alnum(10), self._prog, now)
     self.column_qualifier = '{0}#{1}#{2}'.format(self._prog, now, random_alnum(5))
     self.value = '{0}#{1}'.format(now, random_alnum(10))
     self.num_column_families = None
     self.list_tables = False
     self.msg = 'msg not defined'
     self.ok()
 def __init__(self):
     # Python 2.x
     super(CheckHBaseWrite, self).__init__()
     # Python 3.x
     # super().__init__()
     self.conn = None
     self.host = None
     self.port = None
     self.table = None
     now = time.time()
     self.row = '{0}#{1}#{2}'.format(random_alnum(10), self._prog, now)
     self.column_qualifier = '{0}#{1}#{2}'.format(self._prog, now, random_alnum(5))
     self.value = '{0}#{1}'.format(now, random_alnum(10))
     self.num_column_families = None
     self.list_tables = False
     self.msg = 'msg not defined'
     self.ok()
Exemple #8
0
 def populate_table(self):
     table = self.table
     key_length = self.key_length
     value_length = self.value_length
     table_conn = None
     # does not actually connect until sending data
     #log.info("connecting to test table '%s'", table)
     try:
         table_conn = self.conn.table(table)
     except (socket.timeout, ThriftException, HBaseIOError) as _:
         die('ERROR while trying to connect to table \'{0}\': {1}'.format(
             table, _))
     log.info("populating test table '%s' with random data", table)
     if self.use_existing_table:
         self.column_family = sorted(table_conn.families().keys())[0]
     cf_col = self.column_family + ':col1'
     try:
         skew_prefix = 'A' * key_length
         skew_mod = max(1, 100.0 / self.skew_pc)
         #log.info('skew mod is %s', skew_mod)
         width = len('{0}'.format(self.num_rows))
         start = time.time()
         for _ in range(self.num_rows):
             if self.skew and int(_ % skew_mod) == 0:
                 table_conn.put(bytes(skew_prefix + '{number:0{width}d}'.format(width=width, number=_)), \
                                {bytes(cf_col): bytes(random_alnum(value_length))})
             else:
                 table_conn.put(
                     bytes(random_alnum(key_length)),
                     {bytes(cf_col): bytes(random_alnum(value_length))})
             if _ % 100 == 0:
                 print('.', file=sys.stderr, end='')
         print(file=sys.stderr)
         time_taken = time.time() - start
         log.info(
             'sent %s rows of generated data to HBase in %.2f seconds (%d rows/sec, %s/sec)',
             self.num_rows, time_taken, self.num_rows / time_taken,
             humanize.naturalsize(self.num_rows *
                                  (key_length + value_length) / time_taken))
     except (socket.timeout, ThriftException, HBaseIOError) as _:
         exp = str(_)
         exp = exp.replace('\\n', '\n')
         exp = exp.replace('\\t', '\t')
         die('ERROR while trying to populate table \'{0}\': {1}'.format(
             table, exp))
 def populate_table(self):
     table = self.table
     key_length = self.key_length
     value_length = self.value_length
     table_conn = None
     # does not actually connect until sending data
     #log.info("connecting to test table '%s'", table)
     try:
         table_conn = self.conn.table(table)
     except (socket.timeout, ThriftException, HBaseIOError) as _:
         die('ERROR while trying to connect to table \'{0}\': {1}'.format(table, _))
     log.info("populating test table '%s' with random data", table)
     if self.use_existing_table:
         self.column_family = sorted(table_conn.families().keys())[0]
     cf_col = self.column_family + ':col1'
     try:
         skew_prefix = 'A' * key_length
         skew_mod = max(1, 100.0 / self.skew_pc)
         #log.info('skew mod is %s', skew_mod)
         width = len('{0}'.format(self.num_rows))
         start = time.time()
         for _ in range(self.num_rows):
             if self.skew and int(_ % skew_mod) == 0:
                 table_conn.put(bytes(skew_prefix + '{number:0{width}d}'.format(width=width, number=_)), \
                                {bytes(cf_col): bytes(random_alnum(value_length))})
             else:
                 table_conn.put(bytes(random_alnum(key_length)), {bytes(cf_col): bytes(random_alnum(value_length))})
             if _ % 100 == 0:
                 print('.', file=sys.stderr, end='')
         print(file=sys.stderr)
         time_taken = time.time() - start
         log.info('sent %s rows of generated data to HBase in %.2f seconds (%d rows/sec, %s/sec)',
                  self.num_rows,
                  time_taken,
                  self.num_rows / time_taken,
                  humanize.naturalsize(self.num_rows * (key_length + value_length) / time_taken)
                 )
     except (socket.timeout, ThriftException, HBaseIOError) as _:
         exp = str(_)
         exp = exp.replace('\\n', '\n')
         exp = exp.replace('\\t', '\t')
         die('ERROR while trying to populate table \'{0}\': {1}'.format(table, exp))
 def __init__(self):
     # Python 2.x
     super(CheckKafka, self).__init__()
     # Python 3.x
     # super().__init__()
     self.name = 'Kafka'
     self.default_port = 9092
     self.producer = None
     self.consumer = None
     self.topic = None
     self.client_id = 'Hari Sekhon ' + os.path.basename(get_topfile()) + ' ' + __version__
     self.group_id = self.client_id + ' ' + str(os.getpid()) + ' ' + random_alnum(10)
     self.acks = '1'
     self.retries = 0
     self.partition = None
     self.topic_partition = None
     self.brokers = None
     self.timeout_ms = None
     self.start_offset = None