]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdns_control: add show <prefix> 9549/head
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 28 Sep 2020 11:18:01 +0000 (13:18 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Mon, 28 Sep 2020 11:18:15 +0000 (13:18 +0200)
docs/manpages/pdns_control.1.rst
pdns/dynhandler.cc
pdns/statbag.cc
pdns/statbag.hh

index 79e7d8b3fb8b494aa008cd4a01aca34c3ff31918..1a4e3bcc14572c6b828a6747895be3871ad3f67b 100644 (file)
@@ -77,7 +77,7 @@ when the server is running in guardian mode.
 list
 ^^^^
 
-Dump all variables and their values in a comma separated list,
+Dump all statistics and their values in a comma separated list,
 equivalent to ``show *``.
 
 list-zones [master,slave,native]
@@ -160,12 +160,18 @@ set *VARIABLE* *VALUE*
 Set the configuration parameter *VARIABLE* to *VALUE*. Currently
 only the query-logging can be set.
 
-show *VARIABLE*
-^^^^^^^^^^^^^^^
+show *STATISTIC*
+^^^^^^^^^^^^^^^^
 
 Show a single statistic, as present in the output of the list
 command.
 
+show *STATISTIC-PREFIX*\*
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Show all statistics which names start with the supplied *STATISTIC-PREFIX*,
+as a comma-separated list. Only one (ending) wildcard is allowed.
+
 status
 ^^^^^^
 
index 5614f9c212a95af75a4891684fecec5941b42b8b..936d2e49583cdbab692c90144ea00b765a5ab6d3 100644 (file)
@@ -96,6 +96,8 @@ string DLShowHandler(const vector<string>&parts, Utility::pid_t ppid) {
     if (parts.size() == 2) {
       if (parts[1] == "*")
         ret = S.directory();
+      else if (parts[1].length() && parts[1][parts[1].length() - 1 ] == '*')
+        ret = S.directory(parts[1].substr(0, parts[1].length() - 1));
       else
         ret = S.getValueStr(parts[1]);
     }
index 521530d6a2661a53136e0da13e3ec1367bd927e1..7a2b2e8922e9613ca78c392581362815dca74598 100644 (file)
@@ -49,28 +49,31 @@ void StatBag::exists(const string &key)
     }
 }
 
-string StatBag::directory()
+string StatBag::directory(const string &prefix)
 {
   string dir;
   ostringstream o;
 
-  for(const auto& i: d_stats) {
-    if (d_blacklist.find(i.first) != d_blacklist.end())
+  for(const auto& val : d_stats) {
+    if (d_blacklist.find(val.first) != d_blacklist.end())
       continue;
-    o<<i.first<<"="<<*(i.second)<<",";
+    if (val.first.find(prefix) != 0)
+      continue;
+    o << val.first<<"="<<*(val.second)<<",";
   }
 
 
   for(const funcstats_t::value_type& val :  d_funcstats) {
     if (d_blacklist.find(val.first) != d_blacklist.end())
       continue;
+    if (val.first.find(prefix) != 0)
+      continue;
     o << val.first<<"="<<val.second(val.first)<<",";
   }
   dir=o.str();
   return dir;
 }
 
-
 vector<string>StatBag::getEntries()
 {
   vector<string> ret;
index 611712c223a8bfa6ab05c3b48dc83be0eecc3aa7..f1af4d9a5be06c0d0b9f59b2fb136a417a531b35 100644 (file)
@@ -134,7 +134,7 @@ public:
   uint64_t getRingSize(const string &name);
   uint64_t getRingEntriesCount(const string &name);
 
-  string directory(); //!< Returns a list of all data stored
+  string directory(const string &prefix = ""); //!< Returns a list of all data stored. If prefix is given, only stats named with this prefix are returned.
   vector<string> getEntries(); //!< returns a vector with datums (items)
   string getDescrip(const string &item); //!< Returns the description of this datum/item
   StatType getStatType(const string &item); //!< Returns the stats type for the metrics endpoint