]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Simple blacklist handler for StatBag. Not configurable but that
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 7 Jun 2019 11:03:03 +0000 (13:03 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 7 Jun 2019 11:03:03 +0000 (13:03 +0200)
could easily be added if necessary.

pdns/dynhandler.cc
pdns/statbag.cc
pdns/statbag.hh

index e1ea81f82a5afeca3618150e5341a01ea7aab5d6..7f4449cefd64ce1ece3e2b36d3f5f07dd707ea65 100644 (file)
@@ -83,23 +83,24 @@ string DLPingHandler(const vector<string>&parts, Utility::pid_t ppid)
   return "PONG";
 }
 
-string DLShowHandler(const vector<string>&parts, Utility::pid_t ppid)
-try
-{
-  extern StatBag S;
-  string ret("Wrong number of parameters");
-  if(parts.size()==2) {
-    if(parts[1]=="*")
-      ret=S.directory();
-    else
-      ret=S.getValueStr(parts[1]);
-  }
+string DLShowHandler(const vector<string>&parts, Utility::pid_t ppid) {
+  std::set<string> blacklist;
+  blacklist.insert("special-memory-usage");
+  try {
+    extern StatBag S;
+    string ret("Wrong number of parameters");
+    if (parts.size() == 2) {
+      if (parts[1] == "*")
+        ret = S.directory(blacklist);
+      else
+        ret = S.getValueStr(parts[1]);
+    }
 
-  return ret;
-}
-catch(...)
-{
-  return "Unknown";
+    return ret;
+  }
+  catch (...) {
+    return "Unknown";
+  }
 }
 
 void setStatus(const string &str)
index c4f46a5b1f8fc70a62cb183f2d7fa7097c34c86d..697226e92b241dcc4c9ad61e531c312e0aa933b7 100644 (file)
@@ -48,17 +48,21 @@ void StatBag::exists(const string &key)
     }
 }
 
-string StatBag::directory()
+string StatBag::directory(const std::set<string>& skip)
 {
   string dir;
   ostringstream o;
 
   for(const auto& i: d_stats) {
+    if (skip.find(i.first) != skip.end())
+      continue;
     o<<i.first<<"="<<*(i.second)<<",";
   }
 
 
   for(const funcstats_t::value_type& val :  d_funcstats) {
+    if (skip.find(val.first) != skip.end())
+      continue;
     o << val.first<<"="<<val.second(val.first)<<",";
   }
   dir=o.str();
index 2c8ca2850dfd4d7ed7caa23cda8ac7fc8b3aa385..e1a3998649fcbbada5b3ea67e5ed8721c34be183 100644 (file)
@@ -120,7 +120,7 @@ public:
   void resizeRing(const string &name, unsigned int newsize);
   unsigned int getRingSize(const string &name);
 
-  string directory(); //!< Returns a list of all data stored
+  string directory(const std::set<string>& skip); //!< Returns a list of all data stored
   vector<string> getEntries(); //!< returns a vector with datums (items)
   string getDescrip(const string &item); //!< Returns the description of this datum/item
   void exists(const string &key); //!< call this function to throw an exception in case a key does not exist