def __init__(self, **kargs): self.logger = logging.getLogger('eventgen_server') self.eventgen_core_object = eventgen_core.EventGenerator( self._create_args(**kargs)) self.configured = False self.configfile = None self.check_and_configure_eventgen()
def refresh_eventgen_core_object(self): self.eventgen_core_object.kill_processes() self.eventgen_core_object = eventgen_core.EventGenerator( self._create_args()) self.configured = False self.configfile = None self.check_and_configure_eventgen() self.logger.info("Refreshed the eventgen core object")
def run(self, stanza, input_config, **kwargs): self.output.initStream() logger.info("Initialized streaming") try: if input_config: session_key = input_config.session_key logger.info("Input Config is: {}".format(input_config)) created_arguments = self.create_args() new_args = self.prepare_config(created_arguments) logger.info("Prepared Config") try: eventgen = eventgen_core.EventGenerator(created_arguments) logger.info("Eventgen object generated") config = eventgenconfig.Config(configfile=None, **new_args) logger.info("Config object generated") config.makeSplunkEmbedded(sessionKey=session_key) logger.info("Config made Splunk Embedded") eventgen.config = config eventgen.config.parse() logger.info("Finished config parsing") if eventgen.config.samples: for sample in eventgen.config.samples: if sample.outputMode not in ["spool", "file"]: sample.outputMode = "modinput" logger.info("Finished parse") eventgen._reload_plugins() logger.info("Finished reload") eventgen._setup_pools(eventgen.config.generatorWorkers) logger.info("Finished setup pools") eventgen.start(join_after_start=True) logger.info("Finished running start") except Exception as e: logger.exception(e) self.output.finishStream() logger.info("Finished streaming") except Exception as e: logger.error("Main code exit, Exception caught: %s" % e) raise e