Changeset 470b93f1c4a81c167145f7551c3c015de74669f2

Show
Ignore:
Timestamp:
10/25/11 21:59:50 (2 years ago)
Author:
Paul Querna <pquerna@apache.org>
git-committer:
Paul Querna <pquerna@apache.org> 1319579990 -0700
git-parent:

[3c4929015c7e763c1aa84c4ecf095f93e09a936f]

git-author:
Paul Querna <pquerna@apache.org> 1319579990 -0700
Message:

Add support for setting the Port of the remote Nameserver in the DNS check

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/dns.c

    rf91ddca r470b93f  
    8181  dns_free(h->ctx); 
    8282} 
    83 static dns_ctx_handle_t *dns_ctx_alloc(const char *ns) { 
     83static dns_ctx_handle_t *dns_ctx_alloc(const char *ns, int port) { 
    8484  void *vh; 
    8585  dns_ctx_handle_t *h = NULL; 
     
    105105      if(dns_add_serv(h->ctx, NULL) < 0) failed++; 
    106106      if(dns_add_serv(h->ctx, ns) < 0) failed++; 
     107    } 
     108    if(port && port != DNS_PORT) { 
     109      dns_set_opt(h->ctx, DNS_OPT_PORT, port); 
    107110    } 
    108111    if(dns_open(h->ctx) < 0) failed++; 
     
    305308  } 
    306309  dns_free(pctx); 
    307   if(dns_ctx_alloc(NULL) == NULL) { 
     310  if(dns_ctx_alloc(NULL, 0) == NULL) { 
    308311    noitL(nlerr, "Error setting up default dns resolver context.\n"); 
    309312    return -1; 
     
    606609  const char *rtype = NULL; 
    607610  const char *nameserver = NULL; 
     611  int port = 0; 
     612  const char *port_str = NULL; 
    608613  const char *want_sort = NULL; 
    609614  const char *ctype = "IN"; 
     
    639644    query = "%[name]"; 
    640645  } 
     646 
     647  if(noit_hash_retr_str(check->config, "port", strlen("port"), 
     648                        &port_str)) { 
     649    port = atoi(port_str); 
     650  } 
     651 
    641652#define CONFIG_OVERRIDE(a) \ 
    642653  if(noit_hash_retr_str(check->config, #a, strlen(#a), \ 
     
    688699  } 
    689700  /* use the cached one, unless we don't have one */ 
    690   if(!ci->h) ci->h = dns_ctx_alloc(nameserver); 
     701  if(!ci->h) ci->h = dns_ctx_alloc(nameserver, port); 
    691702  if(!ci->h) ci->error = strdup("bad nameserver"); 
    692703 
  • src/modules/dns.xml

    rb553f9a r470b93f  
    1212               default="%[target_ip] or determined from underlying system" 
    1313               allowed=".+">The domain name server to query. If the name of the check is in-addr.arpa, the system default nameserver is used.  Otherwise, the nameserver is the %[target_ip] of the the check.  If set to the string "default" the underlying system default nameserver is used.</parameter> 
     14    <parameter name="port" 
     15               required="optional" 
     16               default="53" 
     17               allowed="\d+">The port on which the remote server's DNS service is running.</parameter> 
    1418    <parameter name="ctype" 
    1519               required="optional"