Example #1
0
    def build_config(self):
        """Build the config as a Plugins object and return.

        """
        # A bit silly to parse the yaml only for it to be converted back but this
        # plugin is the exception not the rule
        with open(os.path.join(self.template_dir, 'conf.d/network.yaml'), 'r') as network_template:
            default_net_config = yaml.load(network_template.read())
        config = agent_config.Plugins()
        config['network'] = default_net_config
        return config
Example #2
0
def watch_process(search_strings, service=None, component=None):
    """Takes a list of process search strings and returns a Plugins object with the config set.
        This was built as a helper as many plugins setup process watching
    """
    config = agent_config.Plugins()
    parameters = {'name': search_strings[0], 'search_string': search_strings}

    dimensions = _get_dimensions(service, component)
    if len(dimensions) > 0:
        parameters['dimensions'] = dimensions

    config['process'] = {'init_config': None, 'instances': [parameters]}
    return config
Example #3
0
def service_api_check(name, url, pattern, service=None, component=None):
    """Setup a service api to be watched by the http_check plugin.
    """
    config = agent_config.Plugins()
    parameters = {
        'name': name,
        'url': url,
        'match_pattern': pattern,
        'timeout': 10,
        'use_keystone': True
    }

    dimensions = _get_dimensions(service, component)
    if len(dimensions) > 0:
        parameters['dimensions'] = dimensions

    config['http_check'] = {'init_config': None, 'instances': [parameters]}

    return config
Example #4
0
    def build_config(self):
        """Build the config as a Plugins object and return.

        """
        config = agent_config.Plugins()
        for process in self.found_processes:
            # Watch the service processes
            log.info("\tMonitoring the {0} {1} process.".format(
                process, self.service_name))
            config.merge(watch_process([process], self.service_name, process))

        if self.service_api_url and self.search_pattern:
            # Setup an active http_status check on the API
            log.info("\tConfiguring an http_check for the {0} API.".format(
                self.service_name))
            config.merge(
                service_api_check(self.service_name + '-api',
                                  self.service_api_url, self.search_pattern,
                                  self.service_name + '_api'))

        return config
Example #5
0
 def __init__(self, template_dir, overwrite=True, alarms=None, port=9092):
     Plugin.__init__(self, template_dir, overwrite, alarms)
     self.port = port
     self.zk_url = self._find_zookeeper_url()
     self.config = agent_config.Plugins()