]> granicus.if.org Git - pdns/commitdiff
implement & document packetcache-bytes and cache-bytes, which return the estimated...
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 14 Dec 2010 13:35:44 +0000 (13:35 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 14 Dec 2010 13:35:44 +0000 (13:35 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1750 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/docs/pdns.sgml
pdns/rec_channel_rec.cc
pdns/recpacketcache.cc
pdns/recpacketcache.hh

index 44639a5665e8ddf4fc0ff70d9386a02c5b96b132..220e853e32a241ef747644ff878bfe61fce3e884 100644 (file)
@@ -9807,6 +9807,7 @@ answers100-1000     counts the number of queries answered within 1 second
 answers10-100       counts the number of queries answered within 100 miliseconds
 answers1-10         counts the number of queries answered within 10 miliseconds
 answers-slow        counts the number of queries answered after 1 second
+cache-bytes         Size of the cache in bytes (since 3.3.1)
 cache-entries       shows the number of entries in the cache
 cache-hits          counts the number of cache hits since starting
 cache-misses        counts the number of cache misses since starting
@@ -9823,6 +9824,7 @@ nsset-invalidations number of times an nsset was dropped because it no longer wo
 nxdomain-answers    counts the number of times it answered NXDOMAIN since starting
 outgoing-timeouts   counts the number of timeouts on outgoing UDP queries since starting
 over-capacity-drops Questions dropped because over maximum concurrent query limit (since 3.2)
+packetcache-bytes   Size of the packet cache in bytes (since 3.3.1)
 packetcache-entries Size of packet cache (since 3.2)
 packetcache-hits    Packet cache hits (since 3.2)
 packetcache-misses  Packet cache misses (since 3.2)
index 8f196cc281e73aaa20a5d1842f0a85f0262184a9..233f193fc329960884dbaaa84521d461e9ff95d2 100644 (file)
@@ -298,11 +298,22 @@ uint64_t* pleaseGetCacheSize()
   return new uint64_t(t_RC->size());
 }
 
+uint64_t* pleaseGetCacheBytes()
+{
+  return new uint64_t(t_RC->bytes());
+}
+
+
 uint64_t doGetCacheSize()
 {
   return broadcastAccFunction<uint64_t>(pleaseGetCacheSize);
 }
 
+uint64_t doGetCacheBytes()
+{
+  return broadcastAccFunction<uint64_t>(pleaseGetCacheBytes);
+}
+
 uint64_t* pleaseGetCacheHits()
 {
   return new uint64_t(t_RC->cacheHits);
@@ -324,18 +335,28 @@ uint64_t doGetCacheMisses()
 }
 
 
-
-
 uint64_t* pleaseGetPacketCacheSize()
 {
   return new uint64_t(t_packetCache->size());
 }
 
+uint64_t* pleaseGetPacketCacheBytes()
+{
+  return new uint64_t(t_packetCache->bytes());
+}
+
+
 uint64_t doGetPacketCacheSize()
 {
   return broadcastAccFunction<uint64_t>(pleaseGetPacketCacheSize);
 }
 
+uint64_t doGetPacketCacheBytes()
+{
+  return broadcastAccFunction<uint64_t>(pleaseGetPacketCacheBytes);
+}
+
+
 uint64_t* pleaseGetPacketCacheHits()
 {
   return new uint64_t(t_packetCache->d_hits);
@@ -356,6 +377,13 @@ uint64_t doGetPacketCacheMisses()
   return broadcastAccFunction<uint64_t>(pleaseGetPacketCacheMisses);
 }
 
+uint64_t doGetMallocated()
+{
+  // this turned out to be broken
+/*  struct mallinfo mi = mallinfo();
+  return mi.uordblks; */
+  return 0;
+}
 
 RecursorControlParser::RecursorControlParser()
 {
@@ -365,12 +393,14 @@ RecursorControlParser::RecursorControlParser()
   addGetStat("cache-hits", doGetCacheHits);
   addGetStat("cache-misses", doGetCacheMisses); 
   addGetStat("cache-entries", doGetCacheSize); 
+  addGetStat("cache-bytes", doGetCacheBytes); 
   
   addGetStat("packetcache-hits", doGetPacketCacheHits);
   addGetStat("packetcache-misses", doGetPacketCacheMisses); 
   addGetStat("packetcache-entries", doGetPacketCacheSize); 
+  addGetStat("packetcache-bytes", doGetPacketCacheBytes); 
   
-  
+  addGetStat("malloc-bytes", doGetMallocated);
   
   addGetStat("servfail-answers", &g_stats.servFails);
   addGetStat("nxdomain-answers", &g_stats.nxDomains);
@@ -456,6 +486,8 @@ static void doExit()
 
 static void doExitNicely()
 {
+  //extern void printCallers();
+  // printCallers();
   doExitGeneric(true);
 }
 
@@ -530,8 +562,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="quit-nicely") {
     *command=&doExitNicely;
     return "bye nicely\n";
-  }
-  
+  }  
 
   if(cmd=="dump-cache") 
     return doDumpCache(begin, end);
@@ -577,6 +608,6 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="reload-zones") {
     return reloadAuthAndForwards();
   }
-
+  
   return "Unknown command '"+cmd+"'\n";
 }
index 37a1af51c4fab042c7abeae1ebc20206106069b3..4c80435c39de0c0d84ddccb0466786fea477f915 100644 (file)
@@ -1,4 +1,5 @@
 #include <iostream>
+#include <boost/foreach.hpp>
 #include "recpacketcache.hh"
 #include "cachecleaner.hh"
 #include "dns.hh"
@@ -62,6 +63,16 @@ uint64_t RecursorPacketCache::size()
   return d_packetCache.size();
 }
 
+uint64_t RecursorPacketCache::bytes()
+{
+  uint64_t sum=0;
+  BOOST_FOREACH(const struct Entry& e, d_packetCache) {
+    sum += sizeof(e) + e.d_packet.length() + 4;
+  }
+  return sum;
+}
+
+
 void RecursorPacketCache::doPruneTo(unsigned int maxCached)
 {
   pruneCollection(d_packetCache, maxCached);
index a35f36a3a9cb1e4f193233bc99a74d34c14c861b..881ff8a28afd1c866632cab2d75938a8dc7969f9 100644 (file)
@@ -26,6 +26,7 @@ public:
   void prune();
   uint64_t d_hits, d_misses;
   uint64_t size();
+  uint64_t bytes();
 
 private: