From e9a628a297f8bd2953d42ef4d898aeba1c371ae3 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 28 Feb 2018 14:46:10 +0000 Subject: [PATCH] rec: Add the auth-zone-queries metric counting queries to hosted zones --- pdns/rec_channel_rec.cc | 26 +++++++++++--------------- pdns/recursordist/docs/metrics.rst | 4 ++++ pdns/syncres.cc | 2 ++ pdns/syncres.hh | 1 + 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 7daaa998a0..4108e93ecb 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -39,33 +39,28 @@ #include "namespaces.hh" pthread_mutex_t g_carbon_config_lock=PTHREAD_MUTEX_INITIALIZER; -map d_get32bitpointers; -map d_get64bitpointers; -map*> d_getatomics; -map > d_get64bitmembers; -pthread_mutex_t d_dynmetricslock = PTHREAD_MUTEX_INITIALIZER; -map* > d_dynmetrics; -void addGetStat(const string& name, const uint32_t* place) +static map d_get32bitpointers; +static map d_get64bitpointers; +static map*> d_getatomics; +static map > d_get64bitmembers; +static pthread_mutex_t d_dynmetricslock = PTHREAD_MUTEX_INITIALIZER; +static map* > d_dynmetrics; + +static void addGetStat(const string& name, const uint32_t* place) { d_get32bitpointers[name]=place; } -void addGetStat(const string& name, const uint64_t* place) -{ - d_get64bitpointers[name]=place; -} -void addGetStat(const string& name, const std::atomic* place) +static void addGetStat(const string& name, const std::atomic* place) { d_getatomics[name]=place; } - -void addGetStat(const string& name, function f ) +static void addGetStat(const string& name, function f ) { d_get64bitmembers[name]=f; } - std::atomic* getDynMetric(const std::string& str) { Lock l(&d_dynmetricslock); @@ -930,6 +925,7 @@ void registerAllStats() addGetStat("outgoing-timeouts", &SyncRes::s_outgoingtimeouts); addGetStat("outgoing4-timeouts", &SyncRes::s_outgoing4timeouts); addGetStat("outgoing6-timeouts", &SyncRes::s_outgoing6timeouts); + addGetStat("auth-zone-queries", &SyncRes::s_authzonequeries); addGetStat("tcp-outqueries", &SyncRes::s_tcpoutqueries); addGetStat("all-outqueries", &SyncRes::s_outqueries); addGetStat("ipv6-outqueries", &g_stats.ipv6queries); diff --git a/pdns/recursordist/docs/metrics.rst b/pdns/recursordist/docs/metrics.rst index 73de56f1ea..9f83cc3a13 100644 --- a/pdns/recursordist/docs/metrics.rst +++ b/pdns/recursordist/docs/metrics.rst @@ -144,6 +144,10 @@ auth6-answers100-1000 ^^^^^^^^^^^^^^^^^^^^^ counts the number of queries answered by auth6s within 1 second (4.0) +auth-zone-queries +^^^^^^^^^^^^^^^^^ +counts the number of queries to locally hosted authoritative zones (:ref:`setting-auth-zones`) since starting + cache-bytes ^^^^^^^^^^^ size of the cache in bytes diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 883a87be42..16755ec936 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -57,6 +57,7 @@ unsigned int SyncRes::s_packetcachettl; unsigned int SyncRes::s_packetcacheservfailttl; unsigned int SyncRes::s_serverdownmaxfails; unsigned int SyncRes::s_serverdownthrottletime; +std::atomic SyncRes::s_authzonequeries; std::atomic SyncRes::s_queries; std::atomic SyncRes::s_outgoingtimeouts; std::atomic SyncRes::s_outgoing4timeouts; @@ -323,6 +324,7 @@ int SyncRes::AuthDomain::getRecords(const DNSName& qname, uint16_t qtype, std::v bool SyncRes::doOOBResolve(const AuthDomain& domain, const DNSName &qname, const QType &qtype, vector&ret, int& res) { d_authzonequeries++; + s_authzonequeries++; res = domain.getRecords(qname, qtype.getCode(), ret); return true; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index b297eac079..45afc5667e 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -669,6 +669,7 @@ public: static std::atomic s_outgoing6timeouts; static std::atomic s_throttledqueries; static std::atomic s_dontqueries; + static std::atomic s_authzonequeries; static std::atomic s_outqueries; static std::atomic s_tcpoutqueries; static std::atomic s_nodelegated; -- 2.47.2