From cf5dcae9759445153802c0c20ce034802a474b7c Mon Sep 17 00:00:00 2001
From: bert hubert <bert.hubert@powerdns.com>
Date: Mon, 18 Sep 2017 11:21:52 +0200
Subject: [PATCH] add dynamic cache size metrics & documentation

---
 pdns/rec_channel_rec.cc            |  4 +++-
 pdns/recursordist/docs/metrics.rst | 10 +++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc
index 51436a0c8..0e6b34854 100644
--- a/pdns/rec_channel_rec.cc
+++ b/pdns/rec_channel_rec.cc
@@ -843,7 +843,9 @@ void registerAllStats()
 
   addGetStat("cache-hits", doGetCacheHits);
   addGetStat("cache-misses", doGetCacheMisses); 
-  addGetStat("cache-entries", doGetCacheSize); 
+  addGetStat("cache-entries", doGetCacheSize);
+  addGetStat("max-cache-entries", []() { return g_maxCacheEntries.load(); });
+  addGetStat("max-packetcache-entries", []() { return g_maxPacketCacheEntries.load();}); 
   addGetStat("cache-bytes", doGetCacheBytes); 
   
   addGetStat("packetcache-hits", doGetPacketCacheHits);
diff --git a/pdns/recursordist/docs/metrics.rst b/pdns/recursordist/docs/metrics.rst
index 0d7e93043..760b06e73 100644
--- a/pdns/recursordist/docs/metrics.rst
+++ b/pdns/recursordist/docs/metrics.rst
@@ -246,7 +246,15 @@ counts all end-user initiated queries with the RD   bit set, received over IPv6
 
 malloc-bytes
 ^^^^^^^^^^^^
-returns the number of bytes allocated by the   process (broken, always returns 0)
+returns the number of bytes allocated by the process (broken, always returns 0)
+
+max-cache-entries
+^^^^^^^^^^^^^^^^^
+currently configured maximum number of cache entries
+
+max-packetcache-entries
+^^^^^^^^^^^^^^^^^
+currently configured maximum number of packet cache entries
 
 max-mthread-stack
 ^^^^^^^^^^^^^^^^^
-- 
2.40.0