def start(host="localhost", port=24224, app="engine"): """ Listen to salt events and forward them to fluent args: host (str): Host running fluentd agent. Default is localhost port (int): Port of fluentd agent. Default is 24224 app (str): Text sent as fluentd tag. Default is "engine". This text is appended to "saltstack." to form a fluentd tag, ex: "saltstack.engine" """ SENDER_NAME = "saltstack" sender.setup(SENDER_NAME, host=host, port=port) if __opts__.get("id").endswith("_master"): event_bus = salt.utils.event.get_master_event( __opts__, __opts__["sock_dir"], listen=True ) else: event_bus = salt.utils.event.get_event( "minion", transport=__opts__["transport"], opts=__opts__, sock_dir=__opts__["sock_dir"], listen=True, ) log.info("Fluent engine started") while True: salt_event = event_bus.get_event_block() if salt_event: event.Event(app, salt_event)
def start(host='localhost', port=24224, app='engine'): ''' Listen to salt events and forward them to fluent args: host (str): Host running fluentd agent. Default is localhost port (int): Port of fluentd agent. Default is 24224 app (str): Text sent as fluentd tag. Default is "engine". This text is appended to "saltstack." to form a fluentd tag, ex: "saltstack.engine" ''' SENDER_NAME = 'saltstack' sender.setup(SENDER_NAME, host=host, port=port) if __opts__.get('id').endswith('_master'): event_bus = salt.utils.event.get_master_event( __opts__, __opts__['sock_dir'], listen=True) else: event_bus = salt.utils.event.get_event( 'minion', transport=__opts__['transport'], opts=__opts__, sock_dir=__opts__['sock_dir'], listen=True) log.info('Fluent engine started') while True: salt_event = event_bus.get_event_block() if salt_event: event.Event(app, salt_event)