From 28c3cc112b64e36801c06f2d81c393e90a881130 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 7 Jun 2019 13:03:03 +0200 Subject: [PATCH] Simple blacklist handler for StatBag. Not configurable but that could easily be added if necessary. --- pdns/dynhandler.cc | 33 +++++++++++++++++---------------- pdns/statbag.cc | 6 +++++- pdns/statbag.hh | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index e1ea81f82a..7f4449cefd 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -83,23 +83,24 @@ string DLPingHandler(const vector&parts, Utility::pid_t ppid) return "PONG"; } -string DLShowHandler(const vector&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&parts, Utility::pid_t ppid) { + std::set 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) diff --git a/pdns/statbag.cc b/pdns/statbag.cc index c4f46a5b1f..697226e92b 100644 --- a/pdns/statbag.cc +++ b/pdns/statbag.cc @@ -48,17 +48,21 @@ void StatBag::exists(const string &key) } } -string StatBag::directory() +string StatBag::directory(const std::set& skip) { string dir; ostringstream o; for(const auto& i: d_stats) { + if (skip.find(i.first) != skip.end()) + continue; o<& skip); //!< Returns a list of all data stored vector 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 -- 2.47.2