Esempio n. 1
0
 def __init__(self, agentConfig):
     self.client = None
     self.agentConfig = agentConfig
     self.settings = self._extract_settings(agentConfig)
     self.client = self.get_client()
     self.sd_template_dir = agentConfig.get('sd_template_dir')
     self.auto_conf_images = get_auto_conf_images(agentConfig)
 def __init__(self, agentConfig):
     self.client = None
     self.agentConfig = agentConfig
     self.settings = self._extract_settings(agentConfig)
     self.client = self.get_client()
     self.sd_template_dir = agentConfig.get('sd_template_dir')
     self.auto_conf_images = get_auto_conf_images(agentConfig)
Esempio n. 3
0
    def __init__(self, agentConfig):
        self.client = None
        self.agentConfig = agentConfig
        self.settings = self._extract_settings(agentConfig)
        self.client = self.get_client()
        self.sd_template_dir = agentConfig.get('sd_template_dir')
        self.auto_conf_images = get_auto_conf_images()

        # this cache is used to determine which check to
        # reload based on the image linked to a docker event
        #
        # it is invalidated entirely when a change is detected in the config store
        self.template_cache = _TemplateCache(self.client_read, self.sd_template_dir)
Esempio n. 4
0
    def __init__(self, agentConfig):
        self.client = None
        self.agentConfig = agentConfig
        self.settings = self._extract_settings(agentConfig)
        self.client = self.get_client()
        self.sd_template_dir = agentConfig.get('sd_template_dir')
        self.auto_conf_images = get_auto_conf_images()

        # this cache is used to determine which check to
        # reload based on the image linked to a docker event
        #
        # it is invalidated entirely when a change is detected in the config store
        self.template_cache = _TemplateCache(self.client_read,
                                             self.sd_template_dir)
Esempio n. 5
0
    def __init__(self, agentConfig):
        self.client = None
        self.agentConfig = agentConfig
        self.settings = self._extract_settings(agentConfig)
        self.client = self.get_client()
        self.sd_template_dir = agentConfig.get('sd_template_dir')
        self.auto_conf_images = get_auto_conf_images(agentConfig)

        # cache used by dockerutil to determine which check to reload based on the image linked to an event
        #
        # it is invalidated entirely when a change is detected in the kv store
        #
        # this is a defaultdict(set) and some calls to it rely on this property
        # so if you're planning on changing that, track its references
        #
        # TODO Haissam: this should be fleshed out a bit more and used as a cache instead
        # of querying the kv store for each template
        self.identifier_to_checks = self._populate_identifier_to_checks()
    def __init__(self, agentConfig):
        self.client = None
        self.agentConfig = agentConfig
        self.settings = self._extract_settings(agentConfig)
        self.client = self.get_client()
        self.sd_template_dir = agentConfig.get('sd_template_dir')
        self.auto_conf_images = get_auto_conf_images(agentConfig)

        # cache used by dockerutil to determine which check to reload based on the image linked to an event
        #
        # it is invalidated entirely when a change is detected in the kv store
        #
        # this is a defaultdict(set) and some calls to it rely on this property
        # so if you're planning on changing that, track its references
        #
        # TODO Haissam: this should be fleshed out a bit more and used as a cache instead
        # of querying the kv store for each template
        self.identifier_to_checks = self._populate_identifier_to_checks()
Esempio n. 7
0
 def _populate_auto_conf(self):
     """Retrieve auto_conf templates"""
     raw_templates = get_auto_conf_images(full_tpl=True)
     for image, tpls in raw_templates.iteritems():
         for check_name, init_tpl, instance_tpl in zip(*tpls):
             if image in self.auto_conf_templates:
                 if check_name in self.auto_conf_templates[image][0]:
                     log.warning("Conflicting templates in auto_conf for image %s and check %s. "
                             "Please check your template files." % (image, check_name))
                     continue
                 self.auto_conf_templates[image][0].append(check_name)
                 self.auto_conf_templates[image][1].append(init_tpl)
                 self.auto_conf_templates[image][2].append(instance_tpl)
             else:
                 self.auto_conf_templates[image][0] = [check_name]
                 self.auto_conf_templates[image][1] = [init_tpl or {}]
                 # no list wrapping because auto_conf files already have a list of instances
                 self.auto_conf_templates[image][2] = instance_tpl or [{}]
Esempio n. 8
0
 def _populate_auto_conf(self):
     """Retrieve auto_conf templates"""
     raw_templates = get_auto_conf_images(full_tpl=True)
     for image, tpls in raw_templates.iteritems():
         for check_name, init_tpl, instance_tpl in zip(*tpls):
             if image in self.auto_conf_templates:
                 if check_name in self.auto_conf_templates[image][0]:
                     log.warning(
                         "Conflicting templates in auto_conf for image %s and check %s. "
                         "Please check your template files." %
                         (image, check_name))
                     continue
                 self.auto_conf_templates[image][0].append(check_name)
                 self.auto_conf_templates[image][1].append(init_tpl)
                 self.auto_conf_templates[image][2].append(instance_tpl)
             else:
                 self.auto_conf_templates[image][0] = [check_name]
                 self.auto_conf_templates[image][1] = [init_tpl or {}]
                 # no list wrapping because auto_conf files already have a list of instances
                 self.auto_conf_templates[image][2] = instance_tpl or [{}]
    def _populate_identifier_to_checks(self):
        """Populate the identifier_to_checks cache with templates pulled
        from the config store and from the auto-config folder"""
        identifier_to_checks = defaultdict(set)
        # config store templates
        try:
            templates = self.client_read(self.sd_template_dir.lstrip('/'), all=True)
        except (NotImplementedError, TimeoutError, AttributeError):
            templates = []
        for tpl in templates:
            split_tpl = tpl[0].split('/')
            ident, var = split_tpl[-2], split_tpl[-1]
            if var == CHECK_NAMES:
                identifier_to_checks[ident].update(set(json.loads(tpl[1])))

        # auto-config templates
        templates = get_auto_conf_images(self.agentConfig)
        for image, check in templates.iteritems():
            identifier_to_checks[image].add(check)

        return identifier_to_checks
Esempio n. 10
0
    def _populate_identifier_to_checks(self):
        """Populate the identifier_to_checks cache with templates pulled
        from the config store and from the auto-config folder"""
        identifier_to_checks = defaultdict(set)
        # config store templates
        try:
            templates = self.client_read(self.sd_template_dir.lstrip('/'), all=True)
        except (NotImplementedError, TimeoutError, AttributeError):
            templates = []
        for tpl in templates:
            split_tpl = tpl[0].split('/')
            ident, var = split_tpl[-2], split_tpl[-1]
            if var == CHECK_NAMES:
                identifier_to_checks[ident].update(set(json.loads(tpl[1])))

        # auto-config templates
        templates = get_auto_conf_images(self.agentConfig)
        for image, check in templates.iteritems():
            identifier_to_checks[image].add(check)

        return identifier_to_checks