From: 1848 Date: Mon, 5 Nov 2018 14:18:39 +0000 (+0100) Subject: Add option to set interval between health checks X-Git-Tag: auth-4.2.0-beta1~30^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c9bf18dd46580d69de027caac1bc1b9bd7509e0;p=pdns Add option to set interval between health checks Add option 'checkInterval' for newServer() to set the interval between health checks. --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 2bc27b1e6..9af8bfdf2 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -289,6 +289,10 @@ void setupLuaConfig(bool client) ret->retries=std::stoi(boost::get(vars["retries"])); } + if(vars.count("checkInterval")) { + ret->checkInterval=static_cast(std::stoul(boost::get(vars["checkInterval"]))); + } + if(vars.count("tcpConnectTimeout")) { ret->tcpConnectTimeout=std::stoi(boost::get(vars["tcpConnectTimeout"])); } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 488056870..315145983 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1947,6 +1947,9 @@ static void* healthChecksThread() auto states = g_dstates.getLocal(); // this points to the actual shared_ptrs! for(auto& dss : *states) { + if(++dss->lastCheck < dss->checkInterval) + continue; + dss->lastCheck = 0; if(dss->availability==DownstreamState::Availability::Auto) { bool newState=upCheck(*dss); if (newState) { diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 566a2c245..d3325a510 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -698,6 +698,8 @@ struct DownstreamState int tcpConnectTimeout{5}; int tcpRecvTimeout{30}; int tcpSendTimeout{30}; + unsigned int checkInterval{1}; + unsigned int lastCheck{0}; const unsigned int sourceItf{0}; uint16_t retries{5}; uint16_t xpfRRCode{0}; diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index f4391859e..79b33fcee 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -339,6 +339,7 @@ Servers checkFunction=FUNCTION -- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`) setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false maxCheckFailures=NUM, -- Allow NUM check failures before declaring the backend down, default: 1 + checkInterval=NUM -- The time in seconds between health checks mustResolve=BOOL, -- Set to true when the health check MUST return a NOERROR RCODE and an answer useClientSubnet=BOOL, -- Add the client's IP address in the EDNS Client Subnet option when forwarding the query to this backend source=STRING, -- The source address or interface to use for queries to this backend, by default this is left to the kernel's address selection