def __init__(self, config_path): config = cfg.Config() statsd_config = config.get_config(['Main', 'Statsd']) # Create the aggregator (which is the point of communication between the server and reporting threads. aggregator = agg.MetricsAggregator( util.get_hostname(), recent_point_threshold=statsd_config['recent_point_threshold']) # Start the reporting thread. interval = int(statsd_config['monasca_statsd_interval']) assert 0 < interval self.reporter = reporter.Reporter( interval, aggregator, statsd_config['forwarder_url'], statsd_config.get('event_chunk_size')) # Start the server on an IPv4 stack if statsd_config['non_local_traffic']: server_host = '' else: server_host = 'localhost' self.server = udp.Server( aggregator, server_host, statsd_config['monasca_statsd_port'], forward_to_host=statsd_config.get('monasca_statsd_forward_host'), forward_to_port=int( statsd_config.get('monasca_statsd_forward_port')))
def __init__(self, name, init_config, agent_config, instances=None): """Initialize a new check. :param name: The name of the check :param init_config: The config for initializing the check :param agent_config: The global configuration for the agent :param instances: A list of configuration objects for each instance. """ super(AgentCheck, self).__init__(agent_config) self.name = name self.init_config = init_config self.hostname = util.get_hostname() self.log = logging.getLogger('%s.%s' % (__name__, name)) threshold = agent_config.get('recent_point_threshold', None) self.aggregator = (aggregator.MetricsAggregator( self.hostname, recent_point_threshold=threshold)) self.instances = instances or [] self.library_versions = None
def setUp(self): self.aggregator = aggregator.MetricsAggregator("Foo")