def __init__(self, port, agent_config, skip_ssl_validation=False, use_simple_http_client=False): self._unflushed_iterations = 0 self._endpoint = mon.MonascaAPI(agent_config) self._ioloop = None self._port = int(port) self._flush_interval = FLUSH_INTERVAL * 1000 self._non_local_traffic = agent_config.get("non_local_traffic", False) logging.getLogger().setLevel( agent_config.get('log_level', logging.INFO)) self.skip_ssl_validation = skip_ssl_validation or agent_config.get( 'skip_ssl_validation', False) self.use_simple_http_client = use_simple_http_client if self.skip_ssl_validation: log.info( "Skipping SSL hostname validation, useful when using a transparent proxy" )
def __init__(self, port, agent_config, watchdog=True, skip_ssl_validation=False, use_simple_http_client=False): self._port = int(port) self._agent_config = agent_config self.flush_interval = (int(agent_config.get('check_freq')) / 2) * 1000 self._metrics = {} transaction.MetricTransaction.set_application(self) transaction.MetricTransaction.set_endpoints( mon.MonascaAPI(agent_config)) self._tr_manager = transaction.TransactionManager( MAX_WAIT_FOR_REPLAY, MAX_QUEUE_SIZE, THROTTLING_DELAY, agent_config) transaction.MetricTransaction.set_tr_manager(self._tr_manager) self._watchdog = None self.skip_ssl_validation = skip_ssl_validation or agent_config.get( 'skip_ssl_validation', False) self.use_simple_http_client = use_simple_http_client if self.skip_ssl_validation: log.info( "Skipping SSL hostname validation, useful when using a transparent proxy" ) if watchdog: watchdog_timeout = self.flush_interval * WATCHDOG_INTERVAL_MULTIPLIER self._watchdog = util.Watchdog(watchdog_timeout, max_mem_mb=agent_config.get( 'limit_memory_consumption', None))
def __init__(self, port, agent_config, skip_ssl_validation=False, use_simple_http_client=False): self._port = int(port) self._agent_config = agent_config self.flush_interval = (int(agent_config.get('check_freq')) / 2) * 1000 self._metrics = {} transaction.MetricTransaction.set_application(self) transaction.MetricTransaction.set_endpoints(mon.MonascaAPI(agent_config)) self._tr_manager = transaction.TransactionManager(MAX_WAIT_FOR_REPLAY, MAX_QUEUE_SIZE, THROTTLING_DELAY, agent_config) transaction.MetricTransaction.set_tr_manager(self._tr_manager) self.skip_ssl_validation = skip_ssl_validation or agent_config.get( 'skip_ssl_validation', False) self.use_simple_http_client = use_simple_http_client if self.skip_ssl_validation: log.info("Skipping SSL hostname validation, useful when using a transparent proxy")
'jmxfetch_log_file': '/var/log/monasca/agent/jmxfetch.log', 'pool_full_max_retries': 4, 'project_domain_name': None, 'username': '******', 'collector_log_file': '/var/log/monasca/agent/collector.log', 'project_name': 'service', 'skip_ssl_validation': False, 'forwarder_url': 'http://localhost:17123', 'amplifier': 0, 'insecure': False, 'dimensions': {}, 'ca_file': None, 'password': '******', 'sub_collection_warn': 6, 'project_id': None, 'user_domain_id': None, 'url': None, 'keystone_url': keystone_url, 'forwarder_log_file': '/var/log/monasca/agent/forwarder.log', 'write_timeout': 10, 'log_to_event_viewer': False } mon_api = mon.MonascaAPI(mon_api_config) for wr_amt in range(write_amount): message_batch = gen_data_batch() mon_api.post_metrics(message_batch) print "Write data batch %s, %s left..." % (wr_amt + 1, write_amount - wr_amt - 1) time.sleep(1)