def checkdns(dnsconfigfile, mailconfigfile, dnsservers):
    # get all records to test
    useOSDNS = True
    print ""
    print "[+] Running DNS check"
    if len(dnsservers) > 0:
        print "[+] Using %d DNS server(s) for queries:" % len(dnsservers)
        print "    %s" % dnsservers
        useOSDNS = False
    else:
        print "[+] Using OS DNS configuration for queries"
    print "\r\nResults:"
    print "--------"
    toreport = []
    cDNS = DNSConfig(dnsconfigfile)
    dnsscope, dnsscope_short = cDNS.getConfig()
    dnscnt = 1
    for dnscheck in dnsscope:
        extramsg = ""
        allresults = []
        try:
            if useOSDNS:
                allresults = [socket.gethostbyname(dnscheck)]
            else:
                r = dns.resolver.Resolver()
                r.nameservers = dnsservers
                dnsdata = r.query(dnscheck)
                for rdata in dnsdata:
                    thisresult = rdata.address
                    if not thisresult in allresults:
                        allresults.append(thisresult)
            extramsg = "(%s) " % allresults
        except:  
            allresults = ["?.?.?.? (unable to resolve)"]
            extramsg = "(Error looking up IP)"
        siteok = True
        for thisresult in allresults:
            if not thisresult in dnsscope[dnscheck]:
                siteok = False
                extramsg = "(%s : Record manipulated?)" % allresults
                toreport.append("%s: %s resolves to %s, but it should be %s" %
                                (getNow(), dnscheck, thisresult, dnsscope_short[dnscheck]))
        print "%d. %s - check OK? : %s %s" % (dnscnt,dnscheck, str(siteok).lower(), extramsg)
        dnscnt += 1
        
    print ""
    print "[+] Done checking, tested %d sites, reported %d IP mismatches" % \
          (len(dnsscope), len(toreport))
          
    if len(toreport) > 0:
        print ""
        print "*" * 50
        print len(toreport) % "%d DNS record(s) may have been manipulated:"

        mailbody = []
        mailbody.append("Hi,")
        mailbody.append("")
        mailbody.append("dnshjmon.py has detected %d DNS resolution issues:" % len(toreport))
        mailbody.append("")
        for tr in toreport:
            mailbody.append(tr)
            print tr
        print "*" * 50
        mailbody.append("")
        mailbody.append("Report generated with dnshjmon.py - https://github.com/corelan/dnshjmon")
        mailhandler = Mailer(mailconfigfile)
        mailhandler.sendmail(mailbody)

    return


# ----- classes -----
dataset/ETHPy150Open corelan/dnshjmon/dnshjmon.py/checkdns/swapped operands of `%`