@@ -0,0 +1,2027 @@
+%22%22%22%0AThe DNSLookupCheckCollector does a DNS lookup and returns a check %0A##### Dependencies%0A* socket%0A%0AExample config file DNSLookupCheckCollector.conf%0A%60%60%60%0Aenabled = True%0Attl = 150%0A%0AdnsAddressList = ('www.google.com', 'www.yahoo.com')%0A%60%60%60%0A%22%22%22%0A%0Afrom collections import defaultdict%0Aimport diamond.collector%0A%0Atry:%0A  import socket%0Aexcept ImportError:%0A  socket = None%0A  self.log.error('Unable to import module socket')%0A%0Atry:%0A    import netuitive%0Aexcept ImportError:%0A    netuitive = None%0A%0A%0Aclass DNSLookupCheckCollector(diamond.collector.Collector):%0A%0A    def __init__(self, *args, **kwargs):%0A        super(DNSLookupCheckCollector, self).__init__(*args, **kwargs)%0A        self.hostname = self.get_hostname()%0A        self.ttl = self.config%5B'ttl'%5D%0A        %0A        if not netuitive:%0A            self.log.error('netuitive import failed. dnslookupcheck disabled')%0A            self.enabled = False%0A            return%0A%0A        try:%0A            self.version = self._get_version()%0A            self.api = netuitive.Client(self.config%5B'netuitive_url'%5D, self.config%5B'netuitive_api_key'%5D, self.version)%0A        except Exception as e:%0A            self.log.debug(e)%0A%0A    def get_default_config_help(self):%0A        config_help = super(DNSLookupCheckCollector, self).get_default_config_help()%0A        config_help.update(%7B%0A        %7D)%0A        return config_help%0A%0A    def get_default_config(self):%0A        config = super(DNSLookupCheckCollector, self).get_default_config()%0A        config.update(%7B%0A            'path': 'port',%0A            'port': %7B%7D,%0A        %7D)%0A        return config%0A%0A    def collect(self):%0A        %22%22%22%0A        Overrides the Collector.collect method%0A        %22%22%22%0A%0A        #check to see if the dns name returns an IP address%0A        for x in self.config%5B'dnsAddressList'%5D:%0A            try:%0A                addr = socket.gethostbyname(x)%0A                check = netuitive.Check(x, self.hostname, self.ttl)%0A                self.api.post_check(check)%0A            except socket.gaierror:%0A                self.log.error ('cannot resolve hostname')%0A

Create dnslookupcheck.py