def __init__(self, cfg, stats): threading.Thread.__init__(self) self.gtfo = False self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.stats = stats self.host_resolved_at = 0
def __init__(self, cfg): threading.Thread.__init__(self) self.gtfo = False self.event = threading.Event() self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.workers = list() self.node = MetricNode() self.log.debug('Metrics thread initiated')
def __init__(self, cfg): threading.Thread.__init__(self) self.gtfo = False self.event = threading.Event() self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.name = '{}'.format(cfg.name) self.log.debug('Load thread {} initiated'.format(self.name))
def __init__(self, cfg): threading.Thread.__init__(self) self.gtfo = False self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.Handler = NudnikHttpRequestHandler setattr(self.Handler, 'cfg', cfg) server_address = (cfg.ruok_host, cfg.ruok_port) self.httpd = socketserver.TCPServer(server_address, self.Handler) self.log.info('RUOK Server binded to "{}:{}"'.format( cfg.ruok_host, cfg.ruok_port))
def __init__(self, cfg, stream_id, stats): threading.Thread.__init__(self) self.gtfo = False self.event = threading.Event() self.workers = [] self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.stream_id = stream_id self.stats = stats self.queue = queue.Queue() self.name = '{}-{}'.format(cfg.name, stream_id) self.log.debug('Stream {} initiated'.format(self.name))
def __init__(self, cfg): threading.Thread.__init__(self) self.gtfo = False self.event = threading.Event() self.lock = threading.Lock() self.stats = list() self.successful_requests = 0 self.failed_requests = 0 self.cfg = cfg self.log = utils.get_logger(cfg.debug) self.workers = list() self.log.debug('Stats thread initiated')
def main(): args = utils.parse_args() cfg = utils.parse_config(args) log = utils.get_logger(cfg.debug) threads = list() if cfg.ruok is True: ruokthread = ruok.Ruok(cfg) threads.append(ruokthread) ruokthread.daemon = True ruokthread.start() if len(cfg.metrics) > 0: metricsthread = nudnik.metrics.Metrics(cfg) threads.append(metricsthread) metricsthread.daemon = True metricsthread.start() statsthread = nudnik.stats.Stats(cfg) threads.append(statsthread) statsthread.daemon = True statsthread.start() if cfg.server: log.debug('Running Nudnik in server mode') if cfg.protocol == 'grpc': server = nudnik.grpc_server.ParseService(cfg, statsthread) server.start_server() elif cfg.protocol == 'etcd': server = nudnik.etcd_server.Server(cfg, statsthread) server.daemon = True threads.append(server) server.start() else: log.debug('Running Nudnik in client mode') log.debug('Starting {} streams'.format(cfg.streams)) for i in range(0, cfg.streams): try: stream_id = cfg.initial_stream_index + i stream = nudnik.client.Stream(cfg, stream_id, statsthread) threads.append(stream) stream.start() except Exception as e: log.fatal('Fatal error during stream initialization: {}'.format(e)) if cfg.streams == 0 and len(cfg.load_list) > 0: load_thread = nudnik.load.Load(cfg) load_thread.daemon = True threads.append(load_thread) load_thread.start() try: while len(threads) > 0: if cfg.vvvvv: log.debug('Waiting for {} threads'.format(len(threads))) for index, stream in enumerate(threads): if cfg.vvvvv: log.debug('Waiting for thread, idx: {} repr: {}'.format(index, stream)) if stream.gtfo or not stream.is_alive(): threads.pop(index) else: stream.join(0.25) except KeyboardInterrupt: for s in threads: s.exit() log.debug('You are the weakest link, goodbye!'.format('')) return 1