From: bert hubert Date: Sat, 21 Nov 2015 21:01:31 +0000 (+0100) Subject: improve statistics and logging a bit (warn for 'no downstream servers' for example) X-Git-Tag: dnsdist-1.0.0-alpha1~210^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e73ec7d30cea69594f022259ae6c22147d2786aa;p=pdns improve statistics and logging a bit (warn for 'no downstream servers' for example) --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 13c908e8e..27dde44fe 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index d3450e1fb..bae1e8b9e 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -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} }; };