]> granicus.if.org Git - pdns/commitdiff
improve statistics and logging a bit (warn for 'no downstream servers' for example)
authorbert hubert <bert.hubert@netherlabs.nl>
Sat, 21 Nov 2015 21:01:31 +0000 (22:01 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 21 Nov 2015 21:01:31 +0000 (22:01 +0100)
pdns/dnsdist.cc
pdns/dnsdist.hh

index 13c908e8e2828fbf97162a05d87cb65871795346..27dde44fee9a848e188d3b596c8dc82d27e0dfbe 100644 (file)
@@ -425,17 +425,22 @@ try
     try {
       len = recvmsg(cs->udpFD, &msgh, 0);
       g_rings.clientRing.push_back(remote);
-      if(len < (int)sizeof(struct dnsheader)) 
+      if(len < (int)sizeof(struct dnsheader)) {
+       g_stats.nonCompliantQueries++;
        continue;
+      }
 
       g_stats.queries++;
       if(!acl->match(remote)) {
+       vinfolog("Query from %s dropped because of ACL", remote.toStringWithPort());
        g_stats.aclDrops++;
        continue;
       }
       
-      if(dh->qr)    // don't respond to responses
+      if(dh->qr) {   // don't respond to responses
+       g_stats.nonCompliantQueries++;
        continue;
+      }
       
       const uint16_t * flags = getFlagsFromDNSHeader(dh);
       const uint16_t origFlags = *flags;
@@ -513,8 +518,7 @@ try
 
       if(!ss) {
        g_stats.noPolicy++;
-       continue;
-       
+       continue;       
       }
       
       ss->queries++;
@@ -1246,6 +1250,11 @@ try
     }
   }
 
+  if(g_dstates.getCopy().empty()) {
+    errlog("No downstream servers defined: all packets will get dropped");
+    // you might define them later, but you need to know
+  }
+
   for(auto& dss : g_dstates.getCopy()) { // it is a copy, but the internal shared_ptrs are the real deal
     if(dss->availability==DownstreamState::Availability::Auto) {
       bool newState=upCheck(dss->remote);
index d3450e1fb7e260bad3847a707fd51881ed603c61..bae1e8b9ed6410286743e5e5b5fbfeb70eb344e3 100644 (file)
@@ -18,6 +18,7 @@ struct DNSDistStats
   stat_t responses{0};
   stat_t servfailResponses{0};
   stat_t queries{0};
+  stat_t nonCompliantQueries{0};
   stat_t aclDrops{0};
   stat_t blockFilter{0};
   stat_t ruleDrop{0};
@@ -46,7 +47,8 @@ struct DNSDistStats
     {"latency-avg10000", &latencyAvg10000}, {"latency-avg1000000", &latencyAvg1000000},
     {"uptime", uptimeOfProcess},
     {"real-memory-usage", getRealMemoryUsage},
-    {"fd-usage", getOpenFileDescriptors}
+    {"fd-usage", getOpenFileDescriptors},
+    {"noncompliant-queries", &nonCompliantQueries}
   };
 };