Skip to content

Commit

Permalink
Convert ws-auth to produce numerical stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfowlewebs committed Jan 16, 2017
1 parent c5414ea commit dd539ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pdns/ws-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ void apiServerStatistics(HttpRequest* req, HttpResponse* resp) {
if(req->method != "GET")
throw HttpMethodNotAllowedException();

map<string,string> items;
map<string,int> items;
productServerStatisticsFetch(items);

Json::array doc;
typedef map<string, string> items_t;
typedef map<string, int> items_t;
for(const items_t::value_type& item : items) {
doc.push_back(Json::object {
{ "type", "StatisticItem" },
Expand Down
2 changes: 1 addition & 1 deletion pdns/ws-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ void apiCheckQNameAllowedCharacters(const string& name);
DNSName apiNameToDNSName(const string& name);

// To be provided by product code.
void productServerStatisticsFetch(std::map<string,string>& out);
void productServerStatisticsFetch(std::map<string,int>& out);

#endif /* PDNS_WSAPI_HH */
6 changes: 3 additions & 3 deletions pdns/ws-auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) {
resp->setBody(doc);
}

void productServerStatisticsFetch(map<string,string>& out)
void productServerStatisticsFetch(map<string,int>& out)
{
vector<string> 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<DNSResourceRecord>& new_records, vector<DNSResourceRecord>& new_ptrs) {
Expand Down

0 comments on commit dd539ca

Please sign in to comment.