From dd539cad1651f472bc055bd77982951fdf0f2784 Mon Sep 17 00:00:00 2001 From: Matthew Fowle Date: Mon, 16 Jan 2017 16:31:28 -0500 Subject: [PATCH] Convert ws-auth to produce numerical stats. --- pdns/ws-api.cc | 4 ++-- pdns/ws-api.hh | 2 +- pdns/ws-auth.cc | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pdns/ws-api.cc b/pdns/ws-api.cc index bb2ee8e20c4aa..a5e6b03e2d193 100644 --- a/pdns/ws-api.cc +++ b/pdns/ws-api.cc @@ -195,11 +195,11 @@ void apiServerStatistics(HttpRequest* req, HttpResponse* resp) { if(req->method != "GET") throw HttpMethodNotAllowedException(); - map items; + map items; productServerStatisticsFetch(items); Json::array doc; - typedef map items_t; + typedef map items_t; for(const items_t::value_type& item : items) { doc.push_back(Json::object { { "type", "StatisticItem" }, diff --git a/pdns/ws-api.hh b/pdns/ws-api.hh index 1bbd6b55c297e..a62bbeef14833 100644 --- a/pdns/ws-api.hh +++ b/pdns/ws-api.hh @@ -41,6 +41,6 @@ void apiCheckQNameAllowedCharacters(const string& name); DNSName apiNameToDNSName(const string& name); // To be provided by product code. -void productServerStatisticsFetch(std::map& out); +void productServerStatisticsFetch(std::map& out); #endif /* PDNS_WSAPI_HH */ diff --git a/pdns/ws-auth.cc b/pdns/ws-auth.cc index a3d75464e71f6..682414b9ab5f1 100644 --- a/pdns/ws-auth.cc +++ b/pdns/ws-auth.cc @@ -424,15 +424,15 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) { resp->setBody(doc); } -void productServerStatisticsFetch(map& out) +void productServerStatisticsFetch(map& out) { vector items = S.getEntries(); for(const string& item : items) { - out[item] = std::to_string(S.read(item)); + out[item] = std::stoi(std::to_string(S.read(item))); } // add uptime - out["uptime"] = std::to_string(time(0) - s_starttime); + out["uptime"] = time(0) - s_starttime; } static void gatherRecords(const Json container, const DNSName& qname, const QType qtype, const int ttl, vector& new_records, vector& new_ptrs) {