From: Fusl Date: Tue, 21 Jan 2014 14:57:42 +0000 (+0100) Subject: Fixed Habbie's suggestions (https://github.com/PowerDNS/pdns/pull/1220#issuecomment... X-Git-Tag: rec-3.6.0-rc1~231^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09425ce1d22e81d87ffd225fc4fa1e328a59bb2c;p=pdns Fixed Habbie's suggestions (https://github.com/PowerDNS/pdns/pull/1220#issuecomment-32884985) --- diff --git a/pdns/Makefile-recursor b/pdns/Makefile-recursor index ba5c2acd9..d6cc1d974 100644 --- a/pdns/Makefile-recursor +++ b/pdns/Makefile-recursor @@ -21,7 +21,7 @@ dnswriter.o dnsrecords.o rcpgenerator.o base64.o zoneparser-tng.o \ rec_channel.o rec_channel_rec.o selectmplexer.o sillyrecords.o \ dns_random.o ext/polarssl-1.3.2/library/aes.o ext/polarssl-1.3.2/library/padlock.o dnslabeltext.o \ lua-pdns.o lua-recursor.o randomhelper.o recpacketcache.o dns.o \ -reczones.o base32.o nsecrecords.o json.o json_ws.o version.o +reczones.o base32.o nsecrecords.o json.o json_ws.o version.o responsestats.o REC_CONTROL_OBJECTS=rec_channel.o rec_control.o arguments.o misc.o \ unix_utility.o logger.o qtype.o diff --git a/pdns/dist-recursor b/pdns/dist-recursor index 2ecee16b7..c0e4c973c 100755 --- a/pdns/dist-recursor +++ b/pdns/dist-recursor @@ -25,7 +25,8 @@ recursor_cache.hh rec_channel.hh qtype.hh misc.hh dns.hh syncres.hh \ sstuff.hh mtasker.hh mtasker.cc lwres.hh logger.hh pdnsexception.hh \ mplexer.hh \ dns_random.hh lua-pdns.hh lua-recursor.hh namespaces.hh \ -recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh" +recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh \ +responsestats.hh" CFILES="syncres.cc misc.cc unix_utility.cc qtype.cc \ logger.cc arguments.cc lwres.cc pdns_recursor.cc \ @@ -34,7 +35,8 @@ base64.cc zoneparser-tng.cc rec_channel.cc rec_channel_rec.cc rec_control.cc \ selectmplexer.cc epollmplexer.cc kqueuemplexer.cc portsmplexer.cc pdns_hw.cc \ sillyrecords.cc lua-pdns.cc lua-recursor.cc randomhelper.cc \ devpollmplexer.cc recpacketcache.cc dns.cc reczones.cc base32.cc nsecrecords.cc \ -dnslabeltext.cc json.cc json_ws.cc json_ws.hh version.cc dns_random.cc" +dnslabeltext.cc json.cc json_ws.cc json_ws.hh version.cc dns_random.cc \ +responsestats.cc" cd docs make pdns_recursor.1 rec_control.1 diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 663a47f8f..308b87aae 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -31,6 +31,9 @@ #include "communicator.hh" #include "dnsseckeeper.hh" #include "nameserver.hh" +#include "responsestats.hh" + +extern ResponseStats g_rs; static bool s_pleasequit; static string d_status; @@ -160,14 +163,7 @@ string DLCCHandler(const vector&parts, Utility::pid_t ppid) string DLQTypesHandler(const vector&parts, Utility::pid_t ppid) { - typedef map qtypenums_t; - qtypenums_t qtypenums = g_rs.getQTypeResponseCounts(); - ostringstream os; - boost::format fmt("%s\t%d\n"); - BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) { - os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str(); - } - return os.str(); + return g_rs.getQTypeReport(); } string DLRSizesHandler(const vector&parts, Utility::pid_t ppid) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 45df2f616..373632fcc 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -567,7 +567,6 @@ void startDoResolve(void *p) } if(res == RecursorBehaviour::DROP) { - g_rs.submitResponse(dc->d_mdp.d_qtype, 0, !dc->d_tcp); delete dc; dc=0; return; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index db079be07..d31bde3cb 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -425,18 +425,6 @@ uint64_t doGetMallocated() extern ResponseStats g_rs; -string qtypeList() -{ - typedef map qtypenums_t; - qtypenums_t qtypenums = g_rs.getQTypeResponseCounts(); - ostringstream os; - boost::format fmt("%s\t%d\n"); - BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) { - os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str(); - } - return os.str(); -} - RecursorControlParser::RecursorControlParser() { addGetStat("questions", &g_stats.qcounter); @@ -605,6 +593,8 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP "get [key1] [key2] .. get specific statistics\n" "get-all get all statistics\n" "get-parameter [key1] [key2] .. get configuration parameters\n" +"get-qtypelist get QType statistics\n" +" notice: queries from cache aren't being counted yet\n" "help get this list\n" "ping check that all threads are alive\n" "quit stop the recursor daemon\n" @@ -693,7 +683,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP } if(cmd=="get-qtypelist") { - return qtypeList(); + return g_rs.getQTypeReport(); } return "Unknown command '"+cmd+"', try 'help'\n"; diff --git a/pdns/receiver.cc b/pdns/receiver.cc index ef8739a4e..421c1127a 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -67,7 +67,6 @@ #include "dnsrecords.hh" #include "version.hh" - time_t s_starttime; string s_programname="pdns"; // used in packethandler.cc diff --git a/pdns/responsestats.cc b/pdns/responsestats.cc index 6e018d022..ce45f6546 100644 --- a/pdns/responsestats.cc +++ b/pdns/responsestats.cc @@ -2,6 +2,8 @@ #include #include "namespaces.hh" #include "logger.hh" +#include "boost/foreach.hpp" +#include "dnsparser.hh" ResponseStats::ResponseStats() { @@ -54,3 +56,15 @@ map ResponseStats::getSizeResponseCounts() } return ret; } + +string ResponseStats::getQTypeReport() +{ + typedef map qtypenums_t; + qtypenums_t qtypenums = getQTypeResponseCounts(); + ostringstream os; + boost::format fmt("%s\t%d\n"); + BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) { + os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str(); + } + return os.str(); +} \ No newline at end of file diff --git a/pdns/responsestats.hh b/pdns/responsestats.hh index e2d768a32..45fe23225 100644 --- a/pdns/responsestats.hh +++ b/pdns/responsestats.hh @@ -10,6 +10,7 @@ public: void submitResponse(uint16_t qtype, uint16_t respsize, bool udpOrTCP); map getQTypeResponseCounts(); map getSizeResponseCounts(); + string getQTypeReport(); private: vector d_qtypecounters;