]> granicus.if.org Git - pdns/commitdiff
hook up packet cache statistics to the new boost::multi_index code
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 18 Nov 2008 20:38:05 +0000 (20:38 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 18 Nov 2008 20:38:05 +0000 (20:38 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1304 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/packetcache.cc

index b006b6f31049cc697dc1bc274fb65cba8ac22a3c..a8cfad472cbd4c87906f5075077224e606961aa2 100644 (file)
@@ -260,12 +260,30 @@ bool PacketCache::getEntry(const string &qname, const QType& qtype, CacheEntryTy
   return ret;
 }
 
-// FIXME: must be converted to boost multi index
 map<char,int> PacketCache::getCounts()
 {
   ReadLock l(&d_mut);
 
   map<char,int>ret;
+  int recursivePackets=0, nonRecursivePackets=0, queryCacheEntries=0, negQueryCacheEntries=0;
+
+  enum CacheEntryType { PACKETCACHE, QUERYCACHE, NEGCACHE};
+  for(cmap_t::const_iterator iter = d_map.begin() ; iter != d_map.end(); ++iter) {
+    if(iter->ctype == PACKETCACHE)
+      if(iter->meritsRecursion)
+       recursivePackets++;
+      else
+       nonRecursivePackets++;
+    else if(iter->ctype == QUERYCACHE)
+      queryCacheEntries++;
+    else if(iter->ctype == NEGCACHE)
+      negQueryCacheEntries++;
+  }
+
+  ret['!']=negQueryCacheEntries;
+  ret['Q']=queryCacheEntries;
+  ret['n']=nonRecursivePackets;
+  ret['r']=recursivePackets;
   return ret;
 }