def config(cfg): # Handle legacy config (not multiple-endpoint capable) if not any([n.key == 'Endpoint' for n in cfg.children]): # Create fake intermediary Endpoint node cfg.children = (collectd.Config('Endpoint', cfg, ('default', ), cfg.children), ) endpoints = [] for node in cfg.children: if node.key == 'Endpoint': endpoint = WriteWarp10.config_endpoint(node) if endpoint: if any(e['name'] == endpoint['name'] for e in endpoints): collectd.warning('write_warp10 plugin: Duplicate ' 'endpoint: %s' % endpoint['name']) else: endpoints.append(endpoint) else: collectd.warning('write_warp10 plugin: Unknown config key: ' '%s' % node.key) if endpoints: for e in endpoints: ww10 = WriteWarp10(e['url'], e['token'], e['flush_interval'], e['flush_retry_interval'], e['buffer_size'], e['default_labels'], e['rewrite_rules'], e['rewrite_limit']) collectd.info('write_warp10 plugin: register init write and ' 'shutdown functions') collectd.register_init(ww10.init, name='write_warp10/%s' % e['name']) collectd.register_write(ww10.write, name='write_warp10/%s' % e['name']) collectd.register_shutdown(ww10.shutdown, name='write_warp10/%s' % e['name']) else: collectd.warning('write_warp10 plugin: No valid endpoints found')
def setUp(self): username = collectd.Config('Username', ('admin',)) password = collectd.Config('Password', ('admin',)) realm = collectd.Config('Realm', ('RabbitMQ Management',)) host = collectd.Config('Host', ('localhost',)) port = collectd.Config('Port', ('15672',)) schema = collectd.Config('Scheme', ('http',)) vhost_prefix = collectd.Config('VHostPrefix', ('',)) ignore_queues = [ collectd.Config('Regex', ('amq-gen-.*',)), collectd.Config('Regex', ('tmp-.*',)), ] ignore_exchanges = [ collectd.Config('Regex', ('amq.*',)), ] ignore_queue = collectd.Config('Ignore', ('queue',), ignore_queues) ignore_exchange = collectd.Config('Ignore', ('exchange',), ignore_exchanges) config_data = [username, password, host, port, realm, schema, ignore_queue, ignore_exchange, vhost_prefix ] self.test_config = collectd.Config( 'Module', ('rabbitmq',), config_data) collectd_plugin.configure(self.test_config) self.collectd_plugin = collectd_plugin.CollectdPlugin( collectd_plugin.CONFIGS[0])
def setUp(self): username = collectd.Config('Username', ('admin', )) password = collectd.Config('Password', ('admin', )) realm = collectd.Config('Realm', ('RabbitMQ Management', )) host = collectd.Config('Host', ('localhost', )) port = collectd.Config('Port', ('15672', )) ignore_queues = [ collectd.Config('Regex', ('amq-gen-.*', )), collectd.Config('Regex', ('tmp-.*', )), ] ignore_exchanges = [ collectd.Config('Regex', ('amq.*', )), ] ignore_queue = collectd.Config('Ignore', ('queue', ), ignore_queues) ignore_exchange = collectd.Config('Ignore', ('exchange', ), ignore_exchanges) self.module = collectd.Config('Module', ('rabbitmq', ), [ username, password, host, port, realm, ignore_queue, ignore_exchange ]) collectd_plugin.configure(self.module) self.collectd_plugin = collectd_plugin.CollectdPlugin()