Select DNS resolver on host check

Issue #656 closed
yrpen91 created an issue

It would be great if we can select DNS resolver on host check.

For example:

check host example.com with address example.com resolvers 8.8.8.8 or 8.8.4.4. every 15 cycles
    if failed port 80 protocol http then alert

Comments (1)

  1. Tildeslash repo owner

    Monit uses system resolver and cannot select which name services (such as files, dns, nis, ldap) or particular server should be used (that's resolver's business).

    If nameservice itself needs to be tested on a specific DNS server, that server should be target of the test itself with a DNS protocol test, otherwise the error will be ambiguous, if bundled with the example.com:80 check. I think somethink like this would be more flexible (may also allow to test other records such as CNAME, NS, AAAA, etc.):

    # DNS: check that example.com resolves to 1.2.3.4 on first nameserver:
    check host mynameserver1 with address 8.8.8.8
        if failed port 53 type udp protocol dns query "IN A example.com" = "1.2.3.4" then alert
    
    # DNS: check that example.com resolves to 1.2.3.4 on second nameserver:
    check host mynameserver2 with address 8.8.4.4
        if failed port 53 type udp protocol dns query "IN A example.com" = "1.2.3.4" then alert
    
    # check that example.com works:
    check host example.com with address example.com
        if failed port 80 protocol http then alert
        depends on mynameserver1, mynameserver2
    

    Custom queries are however currently not supported by the DNS protocol check ... you can use "check program" with custom script (based on nslookup or dig) that will make sure the host resolves correctly. Check program syntax: https://mmonit.com/monit/documentation/monit.html#PROGRAM-STATUS-TEST

  2. Log in to comment