Пример #1
0
    def read_persistent_cache(self, key):
        # type: (str) -> str
        """Returns the value previously stored with `write_persistent_cache` for the same `key`.

        - **key** (_str_) - The key to retrieve
        """
        return datadog_agent.read_persistent_cache(self._persistent_cache_id(key))
Пример #2
0
    def _start_discovery(self):
        cache = read_persistent_cache(self.check_id)
        if cache:
            hosts = json.loads(cache)
            for host in hosts:
                try:
                    ipaddress.ip_address(host)
                except ValueError:
                    write_persistent_cache(self.check_id, json.dumps([]))
                    break
                instance = self.instance.copy()
                instance.pop('network_address')
                instance['ip_address'] = host

                host_config = self._build_config(instance)
                self._config.discovered_instances[host] = host_config

        self._thread = threading.Thread(target=self.discover_instances, name=self.name)
        self._thread.daemon = True
        self._thread.start()
Пример #3
0
 def read_persistent_cache(self, key):
     # type: (str) -> str
     return datadog_agent.read_persistent_cache(
         self._persistent_cache_id(key))