]> granicus.if.org Git - pdns/commitdiff
Add option to set interval between health checks
author1848 <nomail>
Mon, 5 Nov 2018 14:18:39 +0000 (15:18 +0100)
committer1848 <nomail>
Mon, 5 Nov 2018 14:18:39 +0000 (15:18 +0100)
Add option 'checkInterval' for newServer() to set the interval between
health checks.

pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdist.hh
pdns/dnsdistdist/docs/reference/config.rst

index 2bc27b1e680fb4bffd95d0f00d8d15e50ec381f5..9af8bfdf288bc81552ef2f8b4382ae8a47505cff 100644 (file)
@@ -289,6 +289,10 @@ void setupLuaConfig(bool client)
                          ret->retries=std::stoi(boost::get<string>(vars["retries"]));
                        }
 
+                       if(vars.count("checkInterval")) {
+                         ret->checkInterval=static_cast<unsigned int>(std::stoul(boost::get<string>(vars["checkInterval"])));
+                       }
+
                        if(vars.count("tcpConnectTimeout")) {
                          ret->tcpConnectTimeout=std::stoi(boost::get<string>(vars["tcpConnectTimeout"]));
                        }
index 48805687061864b1f5621315c1e1cdcfa77d9479..315145983d99322cee3fa9a1670141f4e1df3a37 100644 (file)
@@ -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) {
index 566a2c245e637c157e8e26280454a18471b2f084..d3325a510348c65e860a324acdc06fe784752cc1 100644 (file)
@@ -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};
index f4391859e02183e41161bdb34ca9cafa9bd6244b..79b33fcee9c620f4dcd7e4ccf4d366c713045b71 100644 (file)
@@ -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