From 3ef5fc26b33f4b19a168ccb069a67bfa5dabc5b6 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Mon, 28 Sep 2020 13:18:01 +0200 Subject: [PATCH] pdns_control: add show --- docs/manpages/pdns_control.1.rst | 12 +++++++++--- pdns/dynhandler.cc | 2 ++ pdns/statbag.cc | 13 ++++++++----- pdns/statbag.hh | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/manpages/pdns_control.1.rst b/docs/manpages/pdns_control.1.rst index 79e7d8b3fb..1a4e3bcc14 100644 --- a/docs/manpages/pdns_control.1.rst +++ b/docs/manpages/pdns_control.1.rst @@ -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 ^^^^^^ diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 5614f9c212..936d2e4958 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -96,6 +96,8 @@ string DLShowHandler(const vector&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]); } diff --git a/pdns/statbag.cc b/pdns/statbag.cc index 521530d6a2..7a2b2e8922 100644 --- a/pdns/statbag.cc +++ b/pdns/statbag.cc @@ -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<StatBag::getEntries() { vector ret; diff --git a/pdns/statbag.hh b/pdns/statbag.hh index 611712c223..f1af4d9a5b 100644 --- a/pdns/statbag.hh +++ b/pdns/statbag.hh @@ -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 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 -- 2.47.2