From: Peter van Dijk Date: Thu, 8 Aug 2013 13:43:30 +0000 (+0200) Subject: merge ahu's work X-Git-Tag: rec-3.6.0-rc1~528^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93698ef3af11dc38781c9fec845d0ec8e82d6c11;p=thirdparty%2Fpdns.git merge ahu's work --- diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index e77816b678..45b4e2cea2 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -168,17 +168,41 @@ 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; - typedef map qtmap; - qtmap stats = g_rs.getQTypeResponseCounts(); - BOOST_FOREACH(qtmap::value_type &i, stats) - { - os<&parts, Utility::pid_t ppid) +{ + typedef map respsizes_t; + respsizes_t respsizes = g_rs.getSizeResponseCounts(); + ostringstream os; + boost::format fmt("%d\t%d\n"); + BOOST_FOREACH(const respsizes_t::value_type& val, respsizes) { + os << (fmt % val.first % val.second).str(); } - os<&parts, Utility::pid_t ppid) +{ + extern StatBag S; + typedef vector > totals_t; + totals_t totals = S.getRing("remotes"); + string ret; + boost::format fmt("%s\t%d\n"); + BOOST_FOREACH(totals_t::value_type& val, totals) { + ret += (fmt % val.first % val.second).str(); + } + return ret; +} + string DLSettingsHandler(const vector&parts, Utility::pid_t ppid) { static const char *whitelist[]={"query-logging",0}; diff --git a/pdns/dynhandler.hh b/pdns/dynhandler.hh index d6fd1b28bf..9b284090e0 100644 --- a/pdns/dynhandler.hh +++ b/pdns/dynhandler.hh @@ -42,8 +42,11 @@ string DLPingHandler(const vector&parts, Utility::pid_t ppid); string DLShowHandler(const vector&parts, Utility::pid_t ppid); string DLUptimeHandler(const vector&parts, Utility::pid_t ppid); string DLSettingsHandler(const vector&parts, Utility::pid_t ppid); +string DLRespSizeHandler(const vector&parts, Utility::pid_t ppid); string DLCCHandler(const vector&parts, Utility::pid_t ppid); string DLQTypesHandler(const vector&parts, Utility::pid_t ppid); +string DLRSizesHandler(const vector&parts, Utility::pid_t ppid); +string DLRemotesHandler(const vector&parts, Utility::pid_t ppid); string DLStatusHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyHostHandler(const vector&parts, Utility::pid_t ppid); diff --git a/pdns/receiver.cc b/pdns/receiver.cc index a4f79fdb23..b5cb44d65a 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -553,6 +553,8 @@ int main(int argc, char **argv) DynListener::registerFunc("PURGE",&DLPurgeHandler, "purge entries from packet cache", "[]"); DynListener::registerFunc("CCOUNTS",&DLCCHandler, "get cache statistics"); DynListener::registerFunc("QTYPES", &DLQTypesHandler, "get QType statistics"); + DynListener::registerFunc("RESPSIZES", &DLRSizesHandler, "get histogram of response sizes"); + DynListener::registerFunc("REMOTES", &DLRemotesHandler, "get top remotes"); DynListener::registerFunc("SET",&DLSettingsHandler, "set config variables", " "); DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", ""); DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "Retrieve the current configuration"); diff --git a/pdns/responsestats.cc b/pdns/responsestats.cc index 90d05beb0e..2d9c287a73 100644 --- a/pdns/responsestats.cc +++ b/pdns/responsestats.cc @@ -42,3 +42,14 @@ map ResponseStats::getQTypeResponseCounts() } return ret; } + +map ResponseStats::getSizeResponseCounts() +{ + map ret; + for(sizecounters_t::const_iterator iter = d_sizecounters.begin(); + iter != d_sizecounters.end(); + ++iter) { + ret[iter->first]=iter->second; + } + return ret; +} \ No newline at end of file